-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdriftImage_unitTest.m
More file actions
64 lines (59 loc) · 1.88 KB
/
Copy pathdriftImage_unitTest.m
File metadata and controls
64 lines (59 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function success = driftImage_unitTest()
%driftImage_unitTest tests all functionality of driftImage.
success = 0;
fprintf('\nTesting smi_vis.GenerateImages.driftImage...\n');
SaveDir = smi_helpers.mkSMITETmpDir('unitTest', 'driftImage');
% create random input
fprintf('Creating data...\n');
rng('default')
pointsPerPoint = 400;
X = 1 + 37*rand(pointsPerPoint,1);
Y = 1 + 27*rand(pointsPerPoint,1);
% simulate drift
SMR.X = zeros(10*pointsPerPoint,1);
SMR.Y = zeros(10*pointsPerPoint,1);
SMR.XSize = 40;
SMR.YSize = 30;
SMR.DatasetNum = zeros(10*pointsPerPoint,1);
SMR.FrameNum = zeros(size(SMR.X));
for ii = 1 : 10
SMR.X(((ii-1)*pointsPerPoint)+1 : ii*pointsPerPoint) = X + (ii-1)/10;
SMR.Y(((ii-1)*pointsPerPoint)+1 : ii*pointsPerPoint) = Y + (ii-1)/10;
SMR.DatasetNum(((ii-1)*pointsPerPoint)+1 : ii*pointsPerPoint) = ii;
SMR.FrameNum(((ii-1)*pointsPerPoint)+1 : ii*pointsPerPoint) = 1:1:pointsPerPoint;
end
% input parameters
SRImageZoom = 4;
% test with no output
fprintf('Testing with no output...\n');
smi_vis.GenerateImages.driftImage(SMR,SRImageZoom);
%diptruesize(gcf,200);
saveas(gcf, fullfile(SaveDir, 'dI1.png'));
pause(3);
close gcf
% test with single output variable
fprintf('Testing with single output variable...\n');
[driftIm] = smi_vis.GenerateImages.driftImage(SMR,SRImageZoom);
h = figure; imshow(driftIm);
%diptruesize(h,200);
saveas(gcf, fullfile(SaveDir, 'dI2.png'));
pause(3)
close(h)
% test with 2 output variables
fprintf('Testing with two output variables...\n');
[driftIm,driftImRGB] = smi_vis.GenerateImages.driftImage(SMR,SRImageZoom);
h1 = figure; imshow(driftIm);
saveas(gcf, fullfile(SaveDir, 'dI3.png'));
%diptruesize(h1,200);
h2 = figure; imshow(driftImRGB);
saveas(gcf, fullfile(SaveDir, 'dI4.png'));
%diptruesize(h2,200);
%pos = h2.Position;
%pos(2) = pos(2)-300;
%h2.Position = pos;
pause(3)
close(h1,h2)
% finish
fprintf('Done, test successful!\n\n');
success = 1;
end