-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcropAfterCircularShift3D.m
executable file
·98 lines (80 loc) · 1.44 KB
/
cropAfterCircularShift3D.m
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
% % Ali Ozgur Argunsah
% % 03.01.2014 CCU
% % Crop Images After Circular Shift Followed by Registration
% % v1
%
% function imCropped = cropAfterCircularShift(im,maxx,maxy,minx,miny)
%
% imSizeY = size(im,1);
% imSizeX = size(im,2);
%
% x1 = 1;
% x2 = size(im,2);
% y1 = 1;
% y2 = size(im,2);
%
% if miny < 0 & maxy < 0
% y2 = imSizeY+maxy ;
% end
% if miny < 0 & maxy > 0
% y1 = maxy;
% y2 = imSizeY + miny;
% end
% if miny > 0 & maxy > 0
% y1 = maxy;
% end
%
% if minx < 0 & maxx < 0
% x2 = imSizeX + minx;
% end
% if minx < 0 & maxx > 0
% x1 = maxx;
% x2 = imSizeX + minx;
% end
% if minx > 0 & maxx > 0
% x1 = maxx;
% end
%
% imCropped = im(y1:y2,x1:x2);
% Ali Ozgur Argunsah
% 21.04.2014 CCU
% Crop Images After Circular Shift Followed by Registration
% v2
function imCropped = cropAfterCircularShift3D(imStack,maxx,maxy,minx,miny)
imSizeY = size(imStack,1);
imSizeX = size(imStack,2);
x1 = 1;
x2 = size(imStack,2);
y1 = 1;
y2 = size(imStack,2);
if minx < 0 && maxx <= 0
x1 = 1;
x2 = imSizeX+minx;
end
if minx < 0 && maxx > 0
x1 = maxx;
x2 = imSizeX+minx;
end
if minx >= 0 && maxx > 0
x1 = maxx+1;
x2 = imSizeX;
end
if miny < 0 && maxy <= 0
y1 = 1;
y2 = imSizeY+miny;
end
if miny < 0 && maxy > 0
y1 = maxy;
y2 = imSizeY+miny;
end
if miny >= 0 && maxy > 0
y1 = maxy+1;
y2 = imSizeY;
end
if y1<1
y1 = 1;
end
if x1<1
x1 = 1;
end
imCropped = imStack(y1:y2,x1:x2,:);