function fm_guifun(action)
% GUI functions for Fourier-Mellin transform GUI
%
% Adam Wilmer, aiw99r@ecs.soton.ac.uk
% Colormap
m = gray(256);
switch(action)
% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case('create')
data.pathname = 'C:\Documents and Settings\aiw99r\My Documents\My Pictures\'; % path pointing to data
% ------------------- window handle storage --------------------
data.hmain = get(findobj(gcbf,'Tag','Fig1'));
% --------- IMAGE 1 ---------------------------------------------------
data.input1reference = [];
data.input1 = []; % image data
data.input1_windowed = [];
data.input1_freq = [];
data.input1_magSpec = [];
data.input1_freq_lp = [];
data.windowed_input1_freq_lp = [];
data.logmagspec_lp_ms1 = [];
data.filename1 = []; % filename corresponding to image 1
% --------- IMAGE 2 ------------------------------------------------------
data.input2reference = [];
data.input2 = [];
data.input2_windowed = [];
data.input2_freq = [];
data.input2_magSpec = [];
data.input2_freq_lp = [];
data.windowed_input2_freq_lp = [];
data.logmagspec_lp_ms2 = [];
data.filename2 = []; % filename corresponding to image 2
% -------- SOME FOURIER-MELLIN PARAMETERS ------------------------
data.logpolarScaleRes = 256; % arguments for imlogpolar() function - they control resolution of the log-polar plot
data.logpolarAngleRes = 256;
data.autocrop = 0; % automatically crop inputs after resizing
data.windowType = 'none'; % default window type
data.RotInterp = 'nearest'; % the default interpolations to use
data.SclInterp = 'nearest';
data.LogInterp = 'nearest';
data.dispText = 0;
data.performanceLevel = 1;
data.windowScale = 0;
% -------- REGISTERED IMAGE --------------------------------------
data.registered = []; % registered image matrix
data.input1registered = [];
data.input2registered = [];
data.pc_rs = []; % phase correlation for the log-polar form
data.pc_trans = [];
set(gcbf,'Userdata',data);
set(findobj(gcbf,'Tag','CropInput2'),'String',[num2str(100) '%']);
% Load image 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case('loadA')
dispText('','b');
data = get(gcbf,'Userdata');
pathname = data.pathname;
dispTag('Ref_im','r'); % this stuff isn't that apparent in the aplication??!!
dispText('Loading image 1','b');
[filename, pathname] = uigetfile([pathname '*.*'], 'Load image 1'); % GUI file browser
if filename~=0 % if we have a file
if isempty(findstr(filename,'pgm')) % if not a PGM
[M1,ma] = imread([pathname, filename]);
if isind(M1) & ~isempty(ma)
M1 = 256*double(ind2gray(M1,ma));
else
if isgray(M1)
M1 = double(M1);
else
M1 = double(rgb2gray(M1));
end;
end;
else % if it is a PGM
cesta=strrep([pathname, filename],'.pgm',''); % strip off the .pgm bit for some reason
M1=readpgm(cesta); % special pgm reader?!!
end;
data.input1reference = M1;
data.input1 = M1;
data.input1_windowed = window2d(size(M1,1),size(M1,2),data.windowType).*M1;
set(gcbf,'Userdata',data);
updateImage(1,0); % update all the other plots...
data = get(gcbf,'Userdata');
imDims = size(M1); % dimensions
set(findobj(gcbf,'Tag','Ref_im_c'),'String',[filename ', ' int2str(imDims(1)) ' x ' int2str(imDims(2))],'ForegroundColor','k');
data.pathname = pathname; % save pathname of this file
data.filename1 = filename;
set(gcbf,'Userdata',data);
dispTag('Ref_im','k');
dispText('','b');
end;
% Load image 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case('loadB')
dispText('','b');
data = get(gcbf,'Userdata');
pathname = data.pathname;
dispTag('Sens_im','r');
dispText('Loading image 2','b');
[filename, pathname] = uigetfile([pathname '*.*'], 'Load image 2');
if filename~=0
if isempty(findstr(filename,'pgm'))
[M2,ma] = imread([pathname, filename]);
if isind(M2) & ~isempty(ma)
M2 = 256*double(ind2gray(M2,ma));
else
if isgray(M2)
M2 = double(M2);
else
M2 = double(rgb2gray(M2));
end;
end;
else
cesta=strrep([pathname, filename],'.pgm','');
M2=readpgm(cesta);
end;
data.input2reference = M2;
data.input2 = M2;
data.input2_windowed = window2d(size(M2,1),size(M2,2),data.windowType).*M2;
set(gcbf,'Userdata',data);
updateImage(2,0);
data = get(gcbf,'Userdata');
vel=size(M2);
set(findobj(gcbf,'Tag','Sens_im_c'),'String',[filename ', ' int2str(vel(1)) ' x ' int2str(vel(2))],'ForegroundColor','k');
data.pathname = pathname;
set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes2'));
data.h2 = findobj(gcbf,'Tag','Axes2');
dispTag('Sens_im','k');
data.filename2 = filename;
set(gcbf,'Userdata',data);
dispText('','b');
set(findobj(gcbf,'Tag','RotInput2'),'String',num2str(0)); % set the rotate input2 value to ZERO
set(findobj(gcbf,'Tag','SclInput2'),'String',num2str(1)); % set the scale input2 value to ONE
set(findobj(gcbf,'Tag','CropInput2'),'String',[num2str(100) '%']); % set the crop % input2 value to 100
end;
case('SetRotInterp')
data = get(gcbf,'Userdata');
rotStrings = get(findobj(gcbf,'Tag','RotInterp'),'String');
rotInterp = rotStrings(get(findobj(gcbf,'Tag','RotInterp'),'Value'),:); % this is a character array possibly with spaces in
rotInterp(rotInterp==' ') = ''; % get rid of any spaces
data.RotInterp = rotInterp;
set(gcbf,'Userdata',data);
case('SetSclInterp')
data = get(gcbf,'Userdata');
sclStrings = get(findobj(gcbf,'Tag','SclInterp'),'String');
sclInterp = sclStrings(get(findobj(gcbf,'Tag','SclInterp'),'Value'),:); % this is a character array with 8 characters in it
sclInterp(sclInterp==' ') = ''; % get rid of any spaces
data.SclInterp = sclInterp;
set(gcbf,'Userdata',data);
case('SetLogPolInterp')
data = get(gcbf,'Userdata');
set(findobj(gcbf,'Tag','Pushbutton1'),'String','please wait...');
lpStrings = get(findobj(gcbf,'Tag','LogPolInterp'),'String');
lpInterp = lpStrings(get(findobj(gcbf,'Tag','LogPolInterp'),'Value'),:); % this is a character array with 8 characters in it
lpInterp(lpInterp==' ') = ''; % get rid of any spaces
data.LogInterp = lpInterp;
set(gcbf,'Userdata',data);
updateImage(1,1); % only update the log-polar plots and related plots...
updateImage(2,1);
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
case('autocrop')
data = get(gcbf,'Userdata');
data.autocrop = get(findobj(gcbf,'Tag','cb_autocrop'),'Value');
set(gcbf,'Userdata',data);
case('SelectWindow')
data = get(gcbf,'Userdata');
- 1
- 2
- 3
- 4
- 5
前往页