0001 function [x1, x2] = measure_homologeous_Points(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 if nargin<6
0035 cs = 'matlabimagecs';
0036 end
0037 if nargin<5
0038 N = 1;
0039 end
0040
0041
0042 x = {zeros(2, N);
0043 zeros(2, N)};
0044
0045 I = {I1;I2};
0046 f = {f1;f2};
0047
0048 b = 100;
0049 for n = 1 : N
0050 for i = 1 : numel(I)
0051 if n>1 && i==1
0052 close(f_tmp{:})
0053 end
0054 figure(f{i})
0055 hold off
0056 title('Identify rough position for zoom, or klick right to exit.')
0057 disp(['Identify rough position for zoom in image ',num2str(i),' or right klick to exit.'])
0058
0059 [x0,y0,button] = ginput_10(1);
0060 if button == 3
0061 x1 = -1;
0062 x2 = -1;
0063 return
0064 end
0065
0066 xrange = round( max(x0 - b, 1) : min(x0 + b, size(I{i}, 2)) );
0067 yrange = round( max(y0 - b, 1) : min(y0 + b, size(I{i}, 1)) );
0068
0069 imshow(I{i}(yrange, xrange, :), ...
0070 'Border', 'tight', 'InitialMagnification', 'fit', ...
0071 'XData', xrange, 'YData', yrange);
0072
0073 title('Measure exact position.')
0074 disp(['Measure exact position in image ',num2str(i)])
0075 xy = ginput_10(1);
0076
0077 switch cs
0078 case 'matlabimagecs'
0079 x{i}(:, n) = [xy(1); xy(2)];
0080 case 'xy'
0081 x{i}(:, n) = [xy(2); xy(1)];
0082 case 'xy_bl'
0083 x{i}(:, n) = [xy(1); size(I, 1)-xy(2)+1];
0084 otherwise
0085 error('Unknown coordinate system')
0086 end
0087
0088 imshow(I{i}, 'Border', 'tight', 'InitialMagnification', 'fit');
0089 hold on
0090 for m = 1:n
0091 plot_square_with_background(x{i}(1, m),x{i}(2, m),50,8,4);
0092 end
0093
0094 fp = get(gcf,'Position');
0095 ss = get(0,'ScreenSize');
0096 if ss(4)-(fp(4)+fp(2)) < fp(2)
0097
0098 fs = ss(4)-fp(4);
0099 f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, 10, fs, 2/3*fs]);
0100 else
0101 fs = ss(4)-(fp(4)+fp(2));
0102 f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, ss(4)-fs, fs, fs]);
0103 end
0104 imshow(I{i}(yrange, xrange, :))
0105 hold on
0106 plot_square_with_background(xy(1)-min(xrange), xy(2)-min(yrange),50,8,4);
0107 end
0108
0109 figure(f{1})
0110 disp('For next point click into image 1')
0111 w = waitforbuttonpress;
0112 if w == 0
0113 continue
0114 else
0115 continue
0116 end
0117 end
0118
0119 [x1, x2] = deal(x{:});
0120
0121