Home > Matching_SYM_LSM > src > Functions > Graphics > measure_homologeous_Points.m

measure_homologeous_Points

PURPOSE ^

This function enables the user to measure homologous points in two

SYNOPSIS ^

function [x1, x2] = measure_homologeous_Points(f1, f2, I1, I2, N, cs)

DESCRIPTION ^

 This function enables the user to measure homologous points in two
 images.

 Inputs:
   f1, f2 - figure handles
   I1, I2 - images
   N - number of points to measure
   cs - coordinate system
        'matlabimagecs' - default, Matlab image coordinatesystem
                          (0,0) top left
                          1.dim to the left, 2.dim top down
        'xy'              righthandside coord.system
                          (0,0) top left
                          1.dim top down, 2.dim to the left
        'xy_bl'           righthandside coord.system
                          (0,0) bottom left
                          1.dim to the left, 2.dim bottom up

 Outputs:
   - x1 and x2  measured coordinates
       dimension 2xN each

 Author:
   Falko Schindler (falko.schindler@uni-bonn.de)
   Susanne Wenzel (swenzel@igg.unibonn.de)

 Date:
   December 2010
 Last change
   April 2018 Susanne Wenzel  (swenzel@igg.unibonn.de)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x1, x2] = measure_homologeous_Points(f1, f2, I1, I2, N, cs)
0002 % This function enables the user to measure homologous points in two
0003 % images.
0004 %
0005 % Inputs:
0006 %   f1, f2 - figure handles
0007 %   I1, I2 - images
0008 %   N - number of points to measure
0009 %   cs - coordinate system
0010 %        'matlabimagecs' - default, Matlab image coordinatesystem
0011 %                          (0,0) top left
0012 %                          1.dim to the left, 2.dim top down
0013 %        'xy'              righthandside coord.system
0014 %                          (0,0) top left
0015 %                          1.dim top down, 2.dim to the left
0016 %        'xy_bl'           righthandside coord.system
0017 %                          (0,0) bottom left
0018 %                          1.dim to the left, 2.dim bottom up
0019 %
0020 % Outputs:
0021 %   - x1 and x2  measured coordinates
0022 %       dimension 2xN each
0023 %
0024 % Author:
0025 %   Falko Schindler (falko.schindler@uni-bonn.de)
0026 %   Susanne Wenzel (swenzel@igg.unibonn.de)
0027 %
0028 % Date:
0029 %   December 2010
0030 % Last change
0031 %   April 2018 Susanne Wenzel  (swenzel@igg.unibonn.de)
0032 
0033 
0034 if nargin<6
0035     cs = 'matlabimagecs';
0036 end
0037 if nargin<5
0038     N = 1;
0039 end
0040 
0041 %% measure coordinates
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             % show zoom window below current figure
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]); %#ok<*AGROW>
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

Generated on Sun 19-Jul-2020 23:00:25 by m2html © 2005