⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_guifun.m

📁 此为基于图像配准的傅立叶变换源代码
💻 M
📖 第 1 页 / 共 2 页
字号:
                        data.input2 = rotsclIm;     data.input2_windowed = window2d(size(rotsclIm,1),size(rotsclIm,2),data.windowType).*rotsclIm;
                    elseif (size_rs(1)==size_in1(1))&(size_rs(2)==size_in1(2))   % then no need to crop anything
                        data.input2 = rotsclIm;     data.input2_windowed = window2d(size(rotsclIm,1),size(rotsclIm,2),data.windowType).*rotsclIm;
                        data.input1 = in1ref;   data.input1_windowed = window2d(size(in1ref,1),size(in1ref,2),data.windowType).*in1ref;                    
                    else
                        disp('fm_guifun.m (290ish): AUTOCROP does not currently work on these types of images (ie, certain rectangle shapes)........')   
                    end
                end
                
            end                
        end
        
        set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes2'));
        data.h2 =  findobj(gcbf,'Tag','Axes2');
        
        cla;
        set(gcbf,'Userdata',data);
        
        updateImage(1,0);
        updateImage(2,0); 
        data = get(gcbf,'Userdata'); 
        
        vel1 = size(data.input1_windowed);      
        vel2 = size(data.input2_windowed);      
        
        set(findobj(gcbf,'Tag','Ref_im_c'),'String',[data.filename1 ',   ' int2str(vel1(1)) ' x ' int2str(vel1(2))],'ForegroundColor','k'); 
        set(findobj(gcbf,'Tag','Sens_im_c'),'String',[data.filename2 ',   ' int2str(vel2(1)) ' x ' int2str(vel2(2))],'ForegroundColor','k'); 
        set(gcbf,'Userdata',data);
        
        dispTag('Sens_im','k');
        dispText('','b');
        
    else
        disp('Cannot rotate/scale a non-existent image')
    end
    
    if data.performanceLevel==1
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peak)']);
    else
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peaks)']);
    end
    set(gcbf,'Userdata',data); 
    
    
case('dispText')
    data = get(gcbf,'Userdata');
    val = get(findobj(gcbf,'Tag','cb_dispText'),'Value');
    if val==1 
        data.dispText = 1;
    else
        data.dispText = 0;
    end
    set(gcbf,'Userdata',data);    
    
case('register')    
    data = get(gcbf,'Userdata');
    set(findobj(gcbf,'Tag','Pushbutton1'),'String','please wait...');  
    
    if ((size(data.input2reference,1)>0)&(size(data.input2reference,1)>0)&(size(data.input1,1)>0)&(size(data.input1,2)>0))
        [data.registered,data.input1registered,data.input2registered,reg_output,data.pc_rs,data.pc_trans] = fourier_mellin(data);
        
        regImDims = size(data.registered);      
        data.regInfo = reg_output;
        set(findobj(gcbf,'Tag','TransOut'),'String',[num2str(data.regInfo.translation(1)) 'x' num2str(data.regInfo.translation(2))],'ForegroundColor','k'); 
        set(findobj(gcbf,'Tag','RotOut'),'String',num2str(data.regInfo.rotation),'ForegroundColor','k'); 
        set(findobj(gcbf,'Tag','ScaleOut'),'String',num2str(data.regInfo.scale),'ForegroundColor','k'); 
        set(findobj(gcbf,'Tag','TransPeakOut'),'String',num2str(data.regInfo.trans_peak),'ForegroundColor','k'); 
        set(findobj(gcbf,'Tag','RSPeakOut'),'String',num2str(data.regInfo.rs_peak),'ForegroundColor','k'); 
        
        set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes3'));
        data.h2 =  findobj(gcbf,'Tag','Axes3');
    end
    if data.performanceLevel==1
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peak)']);
    else
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peaks)']);
    end
    
    set(gcbf,'Userdata',data);    	
    dispText('','b');
    
case('setPerformanceLevel')
    data = get(gcbf,'Userdata');
    data.performanceLevel = floor(get(findobj(gcbf,'Tag','performLevel'),'Value'));
    if data.performanceLevel==1
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peak)']);
    else
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peaks)']);
    end
    set(gcbf,'Userdata',data);    	
    
    
    % invoke help window
case('help')
    data	= get(gcbf,'Userdata');
    
    dispText('','b');
    global FM_PATH;
    web(['file:///' FM_PATH 'help/help_fm.html']);
    
    % BELOW IS THE SELECTIONS FOR THE ANALYSIS WINDOW    
case('input1Select')   
    data = get(gcbf,'Userdata');  
    set(findobj(gcbf,'Tag','Pushbutton1'),'String','please wait...'); 
    sel = get(findobj(gcbf,'Tag','input1analysis'),'Value');
    
    if (sel==1)   % input image 'Input|Magnitude Spectrum|Phase Spectrum|Log-Polar'
        mx = data.input1;
    elseif (sel==2)
        mx = data.input1_windowed;
    elseif(sel==3)  % magnitude spectrum
        mx = data.input1_magSpec;
    elseif(sel==4)  % phase spectrum
        mx = angle(data.input1_freq);
    elseif(sel==5)  % log-polar
        mx = data.input1_freq_lp;
    elseif(sel==6)  % windowed log-polar
        mx = data.windowed_input1_freq_lp;
    elseif(sel==7)   % invariant
        mx = data.logmagspec_lp_ms1;
    else
        disp('input1Select: Should never get here')
    end
    
    set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes1'));    % move to the correct axes
    
    cla;       % clear the image corresponding to these axes
    imagesc(mx);   % display image
    axis image;   % fit axis box tightly around image
    axis ij;      % puts MATLAB into its "matrix" axes mode.  The coordinate system origin is at the upper left corner.  The i axis is vertical and is numbered from top to bottom.  The j axis is horizontal and is numbered from left to right.
    axis off;   % turns off labelling
    colormap('gray');    % not sure where 'm' is coming from
    vel = size(data.input1);
    set(findobj(gcbf,'Tag','Ref_im_c'),'String',[data.filename1 ',   ' int2str(vel(1)) ' x ' int2str(vel(2))],'ForegroundColor','k');     
    
    if data.performanceLevel==1
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peak)']);
    else
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peaks)']);
    end
    
    set(gcbf,'Userdata',data);    	
    
case('input2Select')
    data = get(gcbf,'Userdata');   
    set(findobj(gcbf,'Tag','Pushbutton1'),'String','please wait...'); 
    sel = get(findobj(gcbf,'Tag','input2analysis'),'Value');
    
    if (sel==1)   % input image 'Input|Magnitude Spectrum|Phase Spectrum|Log-Polar|Invariant'
        mx = data.input2;
    elseif(sel==2)
        mx = data.input2_windowed;
    elseif(sel==3)  % magnitude spectrum
        mx = data.input2_magSpec;
    elseif(sel==4)  % phase spectrum
        mx = angle(data.input2_freq);
    elseif(sel==5)  % log-polar
        mx = data.input2_freq_lp;
    elseif(sel==6)  % windowed log-polar
        mx = data.windowed_input2_freq_lp;
    elseif(sel==7)   % invariant
        mx = data.logmagspec_lp_ms2;
    else
        disp('input2Select: Should never get here')
    end
    
    set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes2'));    % move to the correct axes
    
    cla;       % clear the image corresponding to these axes
    imagesc(mx);   % display image
    axis image;   % fit axis box tightly around image
    axis ij;      % puts MATLAB into its "matrix" axes mode.  The coordinate system origin is at the upper left corner.  The i axis is vertical and is numbered from top to bottom.  The j axis is horizontal and is numbered from left to right.
    axis off;   % turns off labelling
    colormap('gray');    % not sure where 'm' is coming from
    if data.performanceLevel==1
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peak)']);
    else
        set(findobj(gcbf,'Tag','Pushbutton1'),'String',['REGISTER (' num2str(data.performanceLevel) 'peaks)']);
    end
    
    set(gcbf,'Userdata',data);    	
    
case('regSelect')    
    data = get(gcbf,'Userdata');   
    sel = get(findobj(gcbf,'Tag','reganalysis'),'Value');
    
    if (sel==1)   % regiistered image 'Registered|Registered Image 2|Log-Polar PC|Spatial PC'
        mx = data.registered;
    elseif(sel==2)
        mx = data.input1registered;
    elseif(sel==3)  % magnitude spectrum
        mx = data.input2registered;
    elseif(sel==4)  % phase spectrum
        mx = data.pc_rs;
    elseif(sel==5)  % log-polar
        mx = data.pc_trans;
    else
        disp('input2Select: Should never get here')
    end
    
    set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes3'));    % move to the correct axes
    
    cla;       % clear the image corresponding to these axes
    imagesc(mx);   % display image
    axis image;   % fit axis box tightly around image
    axis ij;      % puts MATLAB into its "matrix" axes mode.  The coordinate system origin is at the upper left corner.  The i axis is vertical and is numbered from top to bottom.  The j axis is horizontal and is numbered from left to right.
    axis off;   % turns off labelling
    %    colormap(m);    % not sure where 'm' is coming from

    
    set(gcbf,'Userdata',data);    	
    %  dispTag('Ref_im','k');
    %  dispText('','b');
    
otherwise
    disp(['fm_guifun.m: trying to call non-existent switch...',action])
end

% ------------------------------------------------------------------------------------
% *************************** auxilliary functions

function dispText(txt,colr);

set(findobj(gcbf,'Tag','MessText'),'String',txt,'ForegroundColor',colr); 

% ------------------------------------------------------------------------------------
function vr=vrat(ktery);

idx = get(findobj(gcbf,'Tag',ktery),'value');
val = get(findobj(gcbf,'Tag',ktery),'String');
vr=str2num(val(idx));


% ------------------------------------------------------------------------------------
function ramek(kde,barva);

set(findobj(gcbf,'Tag',kde),'XColor',barva);
set(findobj(gcbf,'Tag',kde),'YColor',barva);
set(findobj(gcbf,'Tag',kde),'ZColor',barva);

% ------------------------------------------------------------------------------------
function dispTag(txt,colr);

set(findobj(gcbf,'Tag',txt),'ForegroundColor',colr); 

% ------------------------------------------------------------------------------------
function updateImage(im,LP_ONLY)
% USAGE: updateImage(im,LP_ONLY)        A.I.Wilmer, 2002
%
% function to update magnitude spectra, log-polar plots etc of image 'im'
% LP_ONLY : only update the log-polar plot and stuff dependent on it

data = get(gcbf,'Userdata');  

if (im==1)                  % then update image 1 information
    if (~LP_ONLY)       % if log-polar setting is changed then don't need to do the next couple of lines
        data.input1_freq = fftshift(fft2(data.input1_windowed));
        data.input1_magSpec = hipass_filter(size(data.input1_freq,1),size(data.input1_freq,2)).*abs(data.input1_freq);  
%        data.input1_magSpec = log10(abs(data.input1_freq));  
    end
    data.input1_freq_lp = imlogpolar(data.input1_magSpec,data.logpolarScaleRes,data.logpolarAngleRes,data.LogInterp);
    data.windowed_input1_freq_lp = repmat(window1d(size(data.input1_freq_lp,1),data.windowType),1,size(data.input1_freq_lp,2)).*data.input1_freq_lp;
    data.logmagspec_lp_ms1 = hipass_filter(size(data.input1_freq_lp,1),size(data.input1_freq_lp,2)).*abs(fftshift(fft2(data.input1_freq_lp)));    
elseif (im==2)           % update image 2 plots
    if (~LP_ONLY)    % if log-polar setting is changed then don't need to do the next couple of lines
        data.input2_freq = fftshift(fft2(data.input2_windowed));
        data.input2_magSpec = hipass_filter(size(data.input2_freq,1),size(data.input2_freq,2)).*abs(data.input2_freq);  
%        data.input2_magSpec = log10(abs(data.input2_freq));  
    end
    data.input2_freq_lp = imlogpolar(data.input2_magSpec,data.logpolarScaleRes,data.logpolarAngleRes,data.LogInterp);
    data.windowed_input2_freq_lp = repmat(window1d(size(data.input2_freq_lp,1),data.windowType),1,size(data.input2_freq_lp,2)).*data.input2_freq_lp;
    data.logmagspec_lp_ms2 = hipass_filter(size(data.input2_freq_lp,1),size(data.input2_freq_lp,2)).*abs(fftshift(fft2(data.input2_freq_lp)));    
else
    disp('updateImage(): incorrect image number used.')
end
set(gcbf,'Userdata',data); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -