Home > 13-Two-View-Geometry > Functions > 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  
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             % show zoom window below current figure
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]); %#ok<*AGROW>
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

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005