Home > 13-Two-View-Geometry > Functions > measure_Point.m

measure_Point

PURPOSE ^

This function enables the user to measure points in an image

SYNOPSIS ^

function [x] = measure_Point(f, I, N, cs)

DESCRIPTION ^

 This function enables the user to measure points in an image

 Inputs:
   f - figure handle
   I - image
   N - number of points to measure, default 1
   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:
   x - measured coordinates
       dimension 2xN

 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 [x] = measure_Point(f, I, N, cs)
0002 % This function enables the user to measure points in an image
0003 %
0004 % Inputs:
0005 %   f - figure handle
0006 %   I - image
0007 %   N - number of points to measure, default 1
0008 %   cs - coordinate system
0009 %        'matlabimagecs' - default, Matlab image coordinatesystem
0010 %                          (0,0) top left
0011 %                          1.dim to the left, 2.dim top down
0012 %        'xy'              righthandside coord.system
0013 %                          (0,0) top left
0014 %                          1.dim top down, 2.dim to the left
0015 %        'xy_bl'           righthandside coord.system
0016 %                          (0,0) bottom left
0017 %                          1.dim to the left, 2.dim bottom up
0018 %
0019 % Outputs:
0020 %   x - measured coordinates
0021 %       dimension 2xN
0022 %
0023 % Author:
0024 %   Falko Schindler (falko.schindler@uni-bonn.de)
0025 %   Susanne Wenzel (swenzel@igg.unibonn.de)
0026 %
0027 % Date:
0028 %   December 2010
0029 % Last change
0030 %   April 2018 Susanne Wenzel  (swenzel@igg.unibonn.de)
0031 
0032 if nargin<4
0033     cs = 'matlabimagecs';
0034 end
0035 if nargin<3
0036     N = 1;
0037 end
0038 
0039 figure(f) 
0040 
0041 %% measure coordinates
0042 x = zeros(2,N);
0043 
0044 b = 100;
0045 for n = 1 : N   
0046        
0047     title('Identify rough position for zoom, or right klick to exit.')
0048     hold off
0049     
0050     [x0,y0,button] = ginput_10(1);
0051     if button == 3
0052         x = -1;
0053         return 
0054     end
0055     
0056     xrange = round(max(x0 - b, 1) : min(x0 + b, size(I, 2)));
0057     yrange = round(max(y0 - b, 1) : min(y0 + b, size(I, 1)));
0058     
0059     imshow(I(yrange, xrange, :), ...
0060         'Border', 'tight', 'InitialMagnification', 'fit', ...
0061         'XData', xrange, 'YData', yrange);
0062     title('Measure image point')
0063     
0064     xy = ginput_10(1);
0065     
0066     switch cs
0067         case 'matlabimagecs'
0068             x(:, n) = [xy(1); xy(2)];
0069         case 'xy'
0070             x(:, n) = [xy(2); xy(1)];
0071         case 'xy_bl'
0072             x(:, n) = [xy(1); size(I, 1)-xy(2)+1];
0073         otherwise
0074             error('Unknown coordinate system')            
0075     end
0076         
0077 end
0078 
0079 imshow(I, 'Border', 'tight', 'InitialMagnification', 'fit');
0080 hold on

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