0001 function [x1, x2] = measure_homologeous_Points_with_s_and_d(f1, f2, I1, I2, N, cs)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 if nargin<6
0037 cs = 'matlabimagecs';
0038 end
0039 if nargin<5
0040 N = 1;
0041 end
0042
0043
0044 x = {zeros(4, N);
0045 zeros(4, N)};
0046 y = {zeros(2, N);
0047 zeros(2, N)};
0048
0049 I = {I1;I2};
0050 f = {f1;f2};
0051
0052 b = 100;
0053 for n = 1 : N
0054 for i = 1 : numel(I)
0055 if n>1 && i==1
0056 close(f_tmp{:})
0057 end
0058 figure(f{i})
0059 hold off
0060 title('Identify rough position for zoom, or klick right to exit.')
0061 disp(['Identify rough position for zoom in image ',num2str(i),' or right klick to exit.'])
0062
0063 [x0,y0,button] = ginput_10(1);
0064 if button == 3
0065 x1 = -1;
0066 x2 = -1;
0067 return
0068 end
0069
0070 xrange = round( max(x0 - b, 1) : min(x0 + b, size(I{i}, 2)) );
0071 yrange = round( max(y0 - b, 1) : min(y0 + b, size(I{i}, 1)) );
0072
0073 imshow(I{i}(yrange, xrange, :), ...
0074 'Border', 'tight', 'InitialMagnification', 'fit', ...
0075 'XData', xrange, 'YData', yrange);
0076
0077 title('Measure exact position.')
0078 disp(['Measure exact position in image ',num2str(i)])
0079 [x0,y0,button] = ginput_10(1);
0080 if button == 3
0081 x1 = -1;
0082 x2 = -1;
0083 return
0084 end
0085 xy=[x0;y0];
0086
0087 title('Measure tip of array for 3*scale and direction.')
0088 disp(['Measure tip of array for 3*scale and direction ',num2str(i)])
0089 [x0,y0,button] = ginput_10(1); if button == 3
0090 x1 = -1;
0091 x2 = -1;
0092 return
0093 end
0094 sd=[x0;y0];
0095
0096 diff = sd-xy;
0097 s = norm(diff)/3;
0098
0099 switch cs
0100 case 'matlabimagecs'
0101 d = atan2(diff(2),diff(1));
0102 x{i}(:, n) = [xy(1); xy(2); s; d];
0103 case 'xy'
0104 d = atan2(diff(1),diff(2));
0105 x{i}(:, n) = [xy(2); xy(1); s; d];
0106 case 'xy_bl'
0107 d = atan2(diff(2),-diff(1));
0108 x{i}(:, n) = [xy(1); size(I, 1)-xy(2)+1; s; d];
0109 otherwise
0110 error('Unknown coordinate system')
0111 end
0112 y{i}(:, n) = [xy(1); xy(2)];
0113
0114
0115
0116
0117 imshow(I{i}, 'Border', 'tight', 'InitialMagnification', 'fit');
0118 hold on
0119 for m = 1:n
0120 plot_circle_direction_with_background(y{i}(1, m),y{i}(2, m),3*s,d,8,4)
0121
0122 end
0123
0124 fp = get(gcf,'Position');
0125 ss = get(0,'ScreenSize');
0126 if ss(4)-(fp(4)+fp(2)) < fp(2)
0127
0128 fs = ss(4)-fp(4);
0129 f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, 10, fs, 2/3*fs]);
0130 else
0131 fs = ss(4)-(fp(4)+fp(2));
0132 f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, ss(4)-fs, fs, fs]);
0133 end
0134 imshow(I{i}(yrange, xrange, :))
0135 hold on
0136 plot_circle_direction_with_background(y{i}(1, m)-min(xrange),y{i}(2, m)-min(yrange),3*s,d,8,4)
0137
0138 end
0139
0140 if n < N
0141 figure(f{1})
0142 disp('For next point click into image 1')
0143 w = waitforbuttonpress;
0144 if w == 0
0145 continue
0146 else
0147 continue
0148 end
0149 end
0150 end
0151
0152 [x1, x2] = deal(x{:});
0153
0154