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

measure_homologeous_Points_with_s_and_d

PURPOSE ^

This function enables the user to measure homologous points

SYNOPSIS ^

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

DESCRIPTION ^

 This function enables the user to measure homologous points 
 with scale and direction 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 with scale and direction
       dimension 4xN each

 Author:
   Falko Schindler (falko.schindler@uni-bonn.de)
   Susanne Wenzel (swenzel@igg.unibonn.de)
   Wolfgang Förstner (wf@ipb.uni-bonn.de)

 Date:
   December 2010
 Last change
   April 2018 Susanne Wenzel  (swenzel@igg.unibonn.de)
   Novemeber 2018 Wolfgang Förstner  (wf@ipb.uni-bonn.de)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x1, x2] = measure_homologeous_Points_with_s_and_d(f1, f2, I1, I2, N, cs)
0002 % This function enables the user to measure homologous points
0003 % with scale and direction in two 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 with scale and direction
0022 %       dimension 4xN each
0023 %
0024 % Author:
0025 %   Falko Schindler (falko.schindler@uni-bonn.de)
0026 %   Susanne Wenzel (swenzel@igg.unibonn.de)
0027 %   Wolfgang Förstner (wf@ipb.uni-bonn.de)
0028 %
0029 % Date:
0030 %   December 2010
0031 % Last change
0032 %   April 2018 Susanne Wenzel  (swenzel@igg.unibonn.de)
0033 %   Novemeber 2018 Wolfgang Förstner  (wf@ipb.uni-bonn.de)
0034 
0035 
0036 if nargin<6
0037     cs = 'matlabimagecs';
0038 end
0039 if nargin<5
0040     N = 1;
0041 end
0042 
0043 %% measure coordinates
0044 x = {zeros(4, N);
0045      zeros(4, N)};
0046 y = {zeros(2, N);
0047      zeros(2, N)};
0048  
0049 I = {I1;I2};
0050 f = {f1;f2};
0051 
0052 b = 100;
0053 for n = 1 : N
0054     for i = 1 : numel(I)
0055         if n>1 && i==1
0056             close(f_tmp{:})
0057         end
0058         figure(f{i})  
0059         hold off     
0060         title('Identify rough position for zoom, or klick right to exit.')
0061         disp(['Identify rough position for zoom in image ',num2str(i),' or right klick to exit.'])
0062         
0063         [x0,y0,button] = ginput_10(1);
0064         if button == 3
0065             x1 = -1;
0066             x2 = -1;
0067             return 
0068         end
0069         
0070         xrange = round( max(x0 - b, 1) : min(x0 + b, size(I{i}, 2)) );
0071         yrange = round( max(y0 - b, 1) : min(y0 + b, size(I{i}, 1)) );
0072         
0073         imshow(I{i}(yrange, xrange, :), ...
0074             'Border', 'tight', 'InitialMagnification', 'fit', ...
0075             'XData', xrange, 'YData', yrange);
0076         
0077         title('Measure exact position.')
0078         disp(['Measure exact position in image ',num2str(i)])
0079         [x0,y0,button] = ginput_10(1);  
0080         if button == 3
0081             x1 = -1;
0082             x2 = -1;
0083             return 
0084         end
0085         xy=[x0;y0];
0086         
0087         title('Measure tip of array for 3*scale and direction.')
0088         disp(['Measure tip of array for 3*scale and direction ',num2str(i)])
0089         [x0,y0,button] = ginput_10(1); if button == 3
0090             x1 = -1;
0091             x2 = -1;
0092             return 
0093         end
0094         sd=[x0;y0];
0095         
0096         diff = sd-xy;
0097         s    = norm(diff)/3;
0098         
0099         switch cs
0100             case 'matlabimagecs'
0101                 d          = atan2(diff(2),diff(1));
0102                 x{i}(:, n) = [xy(1); xy(2); s; d];
0103             case 'xy'
0104                 d          = atan2(diff(1),diff(2));
0105                 x{i}(:, n) = [xy(2); xy(1); s; d];
0106             case 'xy_bl'
0107                 d          = atan2(diff(2),-diff(1));
0108                 x{i}(:, n) = [xy(1); size(I, 1)-xy(2)+1; s; d];
0109             otherwise
0110                 error('Unknown coordinate system')            
0111         end
0112         y{i}(:, n) = [xy(1); xy(2)];
0113         
0114         
0115         
0116         
0117         imshow(I{i}, 'Border', 'tight', 'InitialMagnification', 'fit');   
0118         hold on
0119         for m = 1:n           
0120             plot_circle_direction_with_background(y{i}(1, m),y{i}(2, m),3*s,d,8,4)
0121            %plot_square_with_background(y{i}(1, m),y{i}(2, m),3*s,8,4);
0122         end
0123         
0124         fp = get(gcf,'Position');
0125         ss = get(0,'ScreenSize');
0126         if ss(4)-(fp(4)+fp(2)) < fp(2)
0127             % show zoom window below current figure
0128             fs = ss(4)-fp(4);
0129             f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, 10, fs, 2/3*fs]); %#ok<*AGROW>
0130         else
0131             fs = ss(4)-(fp(4)+fp(2));
0132             f_tmp{i} = figure('name','Last point, detail','Position',[(fp(1)+fp(3))/2-fs/2, ss(4)-fs, fs, fs]);
0133         end
0134         imshow(I{i}(yrange, xrange, :))
0135         hold on            
0136         plot_circle_direction_with_background(y{i}(1, m)-min(xrange),y{i}(2, m)-min(yrange),3*s,d,8,4)
0137        %plot_square_with_background(xy(1)-min(xrange), xy(2)-min(yrange),3*s,8,4);
0138     end
0139     
0140     if n < N
0141         figure(f{1})
0142         disp('For next point click into image 1')
0143         w = waitforbuttonpress;
0144         if w == 0
0145             continue
0146         else
0147             continue
0148         end
0149     end
0150 end
0151     
0152 [x1, x2] = deal(x{:});
0153 
0154

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