📄 mfusion.asv
字号:
else try switch handles.opfusmet case 1 % no fusion method error errordlg('Please Select Fusion Method','FUSION ERROR','CREATEMODE') case 2 %wavelet fusion esc=handles.opwavesc; mask=handles.opmask; wavcoef=handles.opwavcoef; handles.fusion=wavelet(im1,im2,esc,mask,wavcoef'); handles.title=sprintf(... 'Wavelet Fusion Num. of scales = %d Coef = %s Mask = %d',... esc,wavcoef',mask); Fus_Image_Callback(h, eventdata, handles, varargin); case 3 %CEMIF fusion back=handles.opcembac; siz=handles.opcemsiz; mask=handles.opmask; handles.fusion=cemif(im1,im2,back,siz,mask); handles.title=sprintf(... 'CEMIF Fusion Background = %d Average Size = %d Mask = %1d',back,siz,mask); Fus_Image_Callback(h, eventdata, handles, varargin); case 4 %Spacial Frequency fusion bs=handles.opsfbs; th=handles.opsfth; mask=handles.opmask; handles.fusion=mfocus(im1,im2,bs,th,mask); handles.title=sprintf(... 'SF Fusion Blocksize = %d Threshold = %1.2f Mask = %1d',bs,th,mask); Fus_Image_Callback(h, eventdata, handles, varargin); case 5 %Laplacian Pyramid fusion esc=handles.opwavesc; mask=handles.opmask; a=handles.oplapa; handles.fusion=lap_fus(im1,im2,esc,mask,a); handles.title=sprintf('Laplacian Fusion Num. of scales = %d a = %d Mask = %1d',... esc,a*16,mask); Fus_Image_Callback(h, eventdata, handles, varargin); end catch errordlg(lasterr,'FUSION ERROR','CREATEMODE') end end endendset(handles.text_work,'visible','off')guidata(h,handles) % --------------------------------------------------------------------% Draw Image 1 : Callback% --------------------------------------------------------------------function varargout = Image1_Callback(h, eventdata, handles, varargin)try M1=handles.im1; set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes_im1')) image(M1); axis image colormap(gray(256)); set(findobj(gcbf,'Tag','Axes_im1'),'Xticklabel',[],'Yticklabel',[]) rmse_callback(h, eventdata, handles, varargin); guidata(h,handles)catch errordlg(lasterr,'LOAD ERROR','CREATEMODE')end % --------------------------------------------------------------------% Draw Image 2 : Callback% --------------------------------------------------------------------function varargout = Image2_Callback(h, eventdata, handles, varargin)try M1=handles.im2; set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes_im2')) image(M1); axis image colormap(gray(256)); set(findobj(gcbf,'Tag','Axes_im2'),'Xticklabel',[],'Yticklabel',[]) rmse_callback(h, eventdata, handles, varargin); guidata(h,handles) catch errordlg(lasterr,'LOAD ERROR','CREATEMODE')end% --------------------------------------------------------------------% Select Image Button : Callback% --------------------------------------------------------------------function varargout = pushbutton_Im_Callback(h, eventdata, handles, varargin)try pathname = handles.pathname; [filename, pathname] = uigetfile([pathname '*.*'], 'Load input image'); if filename~=0 M1=0; try [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; catch end if M1==0 M1=readimg([pathname, filename]); end handles.im=M1; handles.reference=1; if (~isfield(handles,'im1')) handles.im1=M1; handles.im1b=M1; end if (~isfield(handles,'im2')) handles.im2=M1; handles.im2b=M1; end handles.pathname=pathname; set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes_im')) image(M1); axis image colormap(gray(256)); set(findobj(gcbf,'Tag','Axes_im1'),'Xticklabel',[],'Yticklabel',[]) set(handles.vie_im1,'visible','on') set(handles.fr_viewim1,'visible','on') guidata(h,handles) rmse_callback(h, eventdata, handles, varargin) Image1_Callback(h, eventdata, handles, varargin); Image2_Callback(h, eventdata, handles, varargin); endcatch errordlg(lasterr,'LOAD ERROR','CREATEMODE')end% --------------------------------------------------------------------% Select Image 1 Button : Callback% --------------------------------------------------------------------function varargout = pushbutton_Im1_Callback(h, eventdata, handles, varargin)try pathname = handles.pathname; [filename, pathname] = uigetfile([pathname '*.*'], 'Load input image'); if filename~=0 M1=0; try [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; catch end if M1==0 M1=readimg([pathname, filename]); end handles.im1=M1; handles.im1b=M1; handles.pathname=pathname; guidata(h,handles) Image1_Callback(h, eventdata, handles, varargin); endcatch errordlg(lasterr,'LOAD ERROR','CREATEMODE')end% --------------------------------------------------------------------% Select Image 2 Button : Callback% --------------------------------------------------------------------function varargout = pushbutton_Im2_Callback(h, eventdata, handles, varargin)try pathname = handles.pathname; [filename, pathname] = uigetfile([pathname '*.*'], 'Load input image'); if filename~=0 M1=0; try [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; catch end if M1==0 M1=readimg([pathname, filename]); end handles.im2=M1; handles.im2b=M1; handles.pathname=pathname; guidata(h,handles) Image2_Callback(h, eventdata, handles, varargin); endcatch errordlg(lasterr,'LOAD ERROR','CREATEMODE')end% --------------------------------------------------------------------% Save Fusion Image : Callback% --------------------------------------------------------------------function varargout = Save_Fusion(h, eventdata, handles, varargin)pathname = handles.pathname;[filename, pathname] = uiputfile([pathname '*.*'], 'Save Fusion Image');file=sprintf('%s%s',pathname,filename);imwrite(uint8(handles.fusion),file);guidata(h,handles) % --------------------------------------------------------------------% Reset : Callback% --------------------------------------------------------------------function varargout = Reset_Callback(h, eventdata, handles, varargin)close allmfusion% --------------------------------------------------------------------% View Fusion Button : Callback% --------------------------------------------------------------------function varargout = pushbutton_New_Callback(h, eventdata, handles, varargin)try figure,image(handles.fusion),colormap(gray(256)) axis image title(handles.title);catch close errordlg('There Is No Fused Image To Display','VIEW ERROR','CREATEMODE')end% --------------------------------------------------------------------% Reset Referenece Image Button : Callback% --------------------------------------------------------------------function varargout = pushbutton_ResetIm_Callback(h, eventdata, handles, varargin)try handles.reference=0; set(gcbf,'CurrentAxes',findobj(gcbf,'Tag','Axes_im')) image(175*ones(size(handles.im))); axis image colormap(gray(256)); set(findobj(gcbf,'Tag','Axes_im1'),'Xticklabel',[],'Yticklabel',[]) set(handles.vie_im1,'visible','off') set(handles.fr_viewim1,'visible','off') guidata(h,handles) rmse_callback(h, eventdata, handles, varargin)catch errordlg(lasterr,'RESET ERROR','CREATEMODE')end% --------------------------------------------------------------------% View Referenece Image : Callback% --------------------------------------------------------------------function varargout = pushbutton_viewIm_Callback(h, eventdata, handles, varargin)try figure,image(handles.im),colormap(gray(256)) title('Original Image') axis imagecatch close errordlg('Please Select Image First','VIEW ERROR','CREATEMODE')end% --------------------------------------------------------------------% View Image 1 : Callback% --------------------------------------------------------------------function varargout = pushbutton_viewIm1_Callback(h, eventdata, handles, varargin)try figure,image(handles.im1),colormap(gray(256)) title('Input Image 1') axis imagecatch close errordlg('Please Select Image First','VIEW ERROR','CREATEMODE')end% --------------------------------------------------------------------% View Image 2 : Callback% --------------------------------------------------------------------function varargout = pushbutton_viewIm2_Callback(h, eventdata, handles, varargin)try figure,image(handles.im2),colormap(gray(256)) title('Input Image 2') axis imagecatch close errordlg('Please Select Image First','VIEW ERROR','CREATEMODE')end% --------------------------------------------------------------------% Help About : Callback% --------------------------------------------------------------------function varargout = help_about(h, eventdata, handles, varargin)mfusion_help% --------------------------------------------------------------------% Calculate RMSE : Callback% --------------------------------------------------------------------function varargout = rmse_callback(h, eventdata, handles, varargin)set(handles.text_rmse1,'visible','off')set(handles.text_rmse1b,'visible','off')set(handles.text_rmse2,'visible','off')set(handles.text_rmse2b,'visible','off')set(handles.text_rmsef,'visible','off')set(handles.text_rmsefb,'visible','off') if handles.reference & ... all(size(handles.im1)==size(handles.im2)) & ... all(size(handles.im1)==size(handles.im)) if (isfield(handles,'im1')) RMSE=rmse(handles.im,handles.im1); RMSE=['RMSE: ',num2str(RMSE)]; set(handles.text_rmse1,'string',RMSE); set(handles.text_rmse1,'visible','on') set(handles.text_rmse1b,'visible','on') end if (isfield(handles,'im2')) RMSE=rmse(handles.im,handles.im2); RMSE=['RMSE: ',num2str(RMSE)]; set(handles.text_rmse2,'string',RMSE); set(handles.text_rmse2,'visible','on') set(handles.text_rmse2b,'visible','on') end if (isfield(handles,'fusion')) & all(size(handles.im)==size(handles.fusion)) RMSE=rmse(handles.im,handles.fusion); RMSE=['RMSE: ',num2str(RMSE)]; set(handles.text_rmsef,'string',RMSE); set(handles.text_rmsef,'visible','on') set(handles.text_rmsefb,'visible','on') endelseif (isfield(handles,'fusion')) & ... all(size(handles.im1)==size(handles.fusion)) & ... all(size(handles.im2)==size(handles.fusion)) RMSE=rmse(handles.fusion,handles.im1); RMSE=['RMSE: ',num2str(RMSE)]; set(handles.text_rmse1,'string',RMSE); set(handles.text_rmse1,'visible','on') set(handles.text_rmse1b,'visible','on') RMSE=rmse(handles.fusion,handles.im2); RMSE=['RMSE: ',num2str(RMSE)]; set(handles.text_rmse2,'string',RMSE); set(handles.text_rmse2,'visible','on') set(handles.text_rmse2b,'visible','on')end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -