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

📄 viewthreshcurvelet2.m

📁 beamlet变化的工具箱
💻 M
字号:
function ViewThreshCurvelet2(dir,subdir,name,ifprint)
% ViewThreshCurvelet2 -- View Results of Thresholding Curvelet Expansion
% 	Usage
%		ViewThreshCurvelet2(dir,subdir,name,name2,name3,ifprint)
%	Inputs
%		dir		string -- pathname of directory containing inputs
%		subdir	string -- pathname of directory containing outputs
%		name	string -- name of .mat file containing image
%		ifprint number -- if > 0, create .eps files.
%	Description
%		Assumes PrepareThreshCurvelet and either DoUnifThreshCurvelet 
%		or DoLocalThreshCurvelet have been applied.
%
%		Extracts information from appropriate .mat files,
%		displays figures, and optionally, prints
%
%	Example
%		% create folder curvelets:Barbara in Macintosh Finder
%		unix('mkdir ~mduncan/matlab/curvelets/Barbara')
%		cd('~mduncan/matlab/curvelets/Barbara') 
%		barbara = ReadRaw('Barbara')
%		save barbara barbara
%%	Example
%		% create folder curvelets:Barbara in Macintosh Finder
%		unix('mkdir ~mduncan/matlab/curvelets/Barbara')
%		PrepareThreshCurvelet('~mduncan/matlab/curvelets/Barbara', ...
%			'barbara','ReadRaw(''Barbara'');')			
% 		% create folder curvelets:Barbara:Thresh_2000_400
%		unix('mkdir ~mduncan/matlab/curvelets/Barbara/Thresh_2000_400')
%		DoUnifThreshCurvelet('~mduncan/matlab/curvelets/Barbara','Thresh_2000_400', ...
%			,'barbara', 2000,400,0,0)
%		%Subfolder ~mduncan/matlab/curvelets/Barbara/Thresh_2000_400 will contain results
%		ViewThreshCurvelet2('~mduncan/matlab/curvelets/Barbara','Thresh_2000_400', ...
%			,'barbara',ifprint)
%
% See Also: 
%        ViewThreshCurvelet
%
	if nargin < 4,
		error('Usage: ViewThreshCurvelet2(dir,subdir,name,ifprint)')
		return
	end 
	mycolor = 'hot';
%
%	load curvelets at band 3; ASSUMES VERSION 2 FILES
%
	if ~isempty(dir),
		cd(dir);
	end

	load([name '_s3'],'MSRT3','bandpass3')
	MSRT3 = double(MSRT3);
	bandpass3 = double(bandpass3);
	
%
%	load thresholded curvelets at band 3
%	
	if ~isempty(subdir),
		cd(subdir);
	end
	load([name '_r3'],'Level3','Thresh3','Recon3');
	Thresh3 = double(Thresh3);
   Recon3  = double(Recon3);
   Level3  = double(Level3);
%
%	parse thresholding method
%
	if prod(size(Level3)) > 1,
		load([name '_r3'],'Method','Local3');
		if length(Method) == length('energy'),
			MethTxt3 = 'energy %=';
			MethNum3  = floor(100*Local3);
		else
			MethTxt3 = 'sparsity %=';
			MethNum3  = floor(100*Local3);
		end
	else
		MethTxt3 = 'size exceeding';
		MethNum3  = Level3;
	end
		
%
%
%
if 0*0
subplot(3,4,5)
Image = ReadRaw1(name);
GrayImage(Image, 255);
axis off
end
		%figure; 
        subplot(3,4,9)
        spy(Thresh3(:,:,1)); hold;
		PlotDyadGrid(512,4,'r');
		%title(sprintf('Scale s=3 Curvelet Coeff. [%s %5.0f] (NS)',MethTxt3,MethNum3));hold off;axis off
        title('Ridgelet Coeff, s=3');
        axis off;
		if ifprint,
			print -deps2 CCoefs3NS.eps
		end 
		%figure; 
if 0*0
        subplot(3,4,2)
        spy(Thresh3(:,:,2)); hold;
		PlotDyadGrid(512,4,'r');
		title(sprintf('Scale s=3 Curvelet Coeff. [%s %5.0f] (EW)',MethTxt3,MethNum3));hold off ;axis off
		
		if ifprint,
			print -deps2 CCoefs3EW.eps
		end 
		%drawnow;


		%figure; 
        subplot(3,4,10)        
        imagesc(Recon3); 
		axis('square'); colormap(mycolor);axis off
		%title(sprintf('Sparsified Bandpass %s Band s=3, [%s %5.0f]',name,MethTxt3,MethNum3))
		title('Bandpass, s=3');
        if ifprint,
			print -deps2 Recon_s3.eps
		end 
		%drawnow;
end
		MSPT = MonoScalePartition(Recon3,4);
		%figure; 

        
        subplot(3,4,10);
        imagesc(MSPT)
		axis('square'); colormap(mycolor);axis off
		%title(sprintf('Sparse Curvelet Components, %s Band s=3, [%s %5.0f]',name,MethTxt3,MethNum3))
        title('Squares, s=3');
		hold; PlotDyadGrid(512,4,'r');hold off
		if ifprint,
			print -deps2 SComponents_s3.eps
		end 
		%drawnow;
if 0*0
		resid3 = bandpass3 - Recon3;
		%figure; 
        subplot(3,4,1);     
        imagesc(resid3)
		axis('square'); colormap(mycolor);axis off
		title(sprintf('Unrepresented Features, %s Band s=3, [%s %5.0f]',name,MethTxt3,MethNum3));
		if ifprint,
			print -deps2 UnrepFeatures_s3.eps
		end 
end
		%drawnow;
%
%	load band 2; ASSUMES VERSION 2 files
%
	if ~isempty(dir),
		cd(dir);
	end

	load([name '_s2'],'MSRT2','bandpass2')
	MSRT2 = double(MSRT2);
	bandpass2 = double(bandpass2);

%
%	load thresholded coefficients at band 2
%
	if ~isempty(subdir),
		cd(subdir);
	end
	
%
	load([name '_r2'],'Level2','Thresh2','Recon2');
	Thresh2 = double(Thresh2);
   Recon2  = double(Recon2);
   Level2  = double(Level2);
%
%	parse thresholding method
%
	if prod(size(Level2)) > 1,
		load([name '_r2'],'Method','Local2');
		if length(Method) == length('energy'),
			MethTxt2 = 'energy %=';
			MethNum2  = floor(100*Local2);
		else
			MethTxt2 = 'sparsity %=';
			MethNum2  = floor(100*Local2);
		end
	else
		MethTxt2 = 'size exceeding';
		MethNum2  = Level3;
	end

%
		%figure; 

        subplot(3,4,5);
        spy(Thresh2(:,:,1)); hold;
		%title(sprintf('Scale s=2 Curvelet Coeff. [%s %5.0f] (NS)',MethTxt2,MethNum2)) 
        title('Ridgelet Coeff, s=2');
		PlotDyadGrid(512,3,'r') ;hold off;axis off
		if ifprint,
			print -deps2 CCoefs2NS.eps
		end 
		%drawnow;

if 0*0
		%figure; 
        subplot(3,4,2)
        spy(Thresh2(:,:,2)); hold
		PlotDyadGrid(512,3,'r');axis off
		title(sprintf('Scale s=2 Curvelet Coeff. [%s %5.0f] (EW)',MethTxt2,MethNum2)) ;hold off
		if ifprint,
			print -deps2 CCoefs2EW.eps
		end 
	
       %drawnow;
end

if 0*0
		%figure; 
        subplot(3,4,6)
        imagesc(Recon2); 
		%title(sprintf('Sparsified Bandpass %s Band s=2, [%s %5.0f]',name,MethTxt2,MethNum2));
        title('Bandpass, s=2');
		axis('square'); colormap(mycolor);axis off
		if ifprint,
			print -deps2 Recon_s2.eps
		end 
		%drawnow;
		
		resid2 = bandpass2 - Recon2;
end		
if 0*0      
 		%figure; 
        subplot(3,4,4)
        imagesc(resid2)
		title(sprintf('Unrepresented Features, %s Band s=2, [%s %5.0f]',name,MethTxt2,MethNum2))
		axis('square'); colormap(mycolor);axis off
		if ifprint,
			print -deps2 UnrepFeatures_s2.eps
		end 
		%drawnow;
end
		MSPT = MonoScalePartition(Recon2,3);
		%figure; 
        subplot(3,4,6);     
        imagesc(MSPT)
		%title(sprintf('Sparse Curvelet Components, %s Band s=2, [%s %5.0f]',name,MethTxt2,MethNum2))
        title('Squares, s=2');
		axis('square'); colormap(mycolor)
		hold; PlotDyadGrid(512,3,'r');hold off;axis off
       
		if ifprint,
			print -deps2 SComponents_s2.eps
		end 
		%drawnow;
%	
%	look at overall reconstruction
%
end

        %figure; 
        subplot(3,4,7)
        imagesc(Recon2)
		%title(sprintf('Sparse reconstruction from s=2 [ %s %d ] & s=3 [ %s %d]',MethTxt2,MethNum2,MethTxt3,MethNum3))
		title('Recon, s=2');
        axis('square'); colormap(mycolor);axis off
		if ifprint,
			print -deps2 SRecon_s23.eps
		end 
        
                %figure; 
        subplot(3,4,11)
        imagesc(Recon3)
		%title(sprintf('Sparse reconstruction from s=2 [ %s %d ] & s=3 [ %s %d]',MethTxt2,MethNum2,MethTxt3,MethNum3))
		title('Recon, s=3');
        axis('square'); colormap(mycolor);axis off
		%drawnow;

%
%		load band1
%
		Level1 = 0;
		if ~isempty(dir),
			cd(dir);
		end
		load(name,name);
		eval(['Recon1 = WaveletBandPass(' name ',-1,3);']);
		if ~isempty(subdir),
			cd(subdir);
		end
%

        %figure; 
	    subplot(3,4,8)
        imagesc(Recon1+Recon2+Recon3);
		%title(sprintf('Reconstruction, s=1 [all]; s=2 [ %s %d ]; s=3 [ %s %d]',MethTxt2,MethNum2,MethTxt3,MethNum3))
		title('Overall Recon');
        axis('square'); colormap(mycolor);axis off
		if ifprint,
			print -deps2 SRecon_s123.eps
		end 
		%drawnow;
if 0*0
		eval(['resid = ' name '- (Recon1+Recon2+Recon3);']);
		%figure; 
        subplot(3,4,8)
		imagesc(resid);
		title(sprintf('Residuals, s=1 [all]; s=2 [ %s %d ]; s=3 [ %s %d]',MethTxt2,MethNum2,MethTxt3,MethNum3));
		axis('square'); colormap(mycolor);axis off
		if ifprint,
			print -deps2 SResid_s123.eps
		end 
 end 
 
        subplot(3,4,3)
        imagesc(Recon1); 
		%title(sprintf('Sparsified Bandpass %s Band s=2, [%s %5.0f]',name,MethTxt2,MethNum2));
        title('Recon, s=1');
		axis('square'); colormap(mycolor);axis off
% Copyright (c) 1999 David L. Donoho

%% Part of BeamLab Version:200% Built:Saturday,14-Sep-2002 00:00:00% This is Copyrighted Material% For Copying permissions see COPYING.m% Comments? e-mail beamlab@stat.stanford.edu%

⌨️ 快捷键说明

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