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