📄 testbestpartition.m
字号:
function TestBestPartition(name,D,Entropy,EntPar)
%
% Ridgelet Packet Analysis in Adaptively Chosen Basis
%
% Inputs
% name name of a 2-d image (loaded from WaveLab); size n by n, n dyadic
% Allowed names are 'Barton', 'Canaletto', 'Coifman', 'Daubechies',...
% 'Fingerprint', 'Lincoln', 'Lenna', 'MRIScan', 'Phone'
% D D = [D1,D2] maximum depth of splitting -- Range D1=2,3,4,5,6; D2=2,3,4,5,6;
% Entropy type of entropy to record in tree: options are
% 'Entropy' -- Coifman-Wickerhauser
% 'Log' -- sum log |th_i|
% 'l^p' -- sum |th_i|^p, 0 < p < 2, p = par
% 'N(eps)' -- #>= eps, eps = par
% 'Risk' -- sum min(th_i^2,eps^2), eps=par
% 'Sum' -- sum th_i
% 'SURE' -- SURE(Thresholding), thresh = par
% EntPar extra parameter, depends on type of entropy$
%
% Description
% Perform an adaptive anisotropic Radial Polar packet analysis on the given image,
% selecting the best anisotropic partitioning basis then plotting the RP coefficients
% for this basis along with the image overlaid by its 2-d polar partition.
%
%Example TestBestPart('Lenna',[3,3],'l^p',1.5)
% check input parameters
if nargin < 3
error('Usage: TestBestPartition(name,D,Entropy[,EntPar])');
end;
if nargin < 4,
EntPar=[];
end
%
if length(D)==1,
D = [ D D];
end
%------------------------------------------
% to supress the output text by ReadImage.m
global WLVERBOSE %set by BeamPath.m
WLVERBOSE = 'No';
%------------------------------------------
im = ReadImage(name);
[s1,s2]=size(im);
if s1~=s2
if min(s1,s2)<=256
im = im(1:min(s1,s2),1:min(s1,s2));
else
im = im(1:256,1:256);
end
end
subplot(1,3,1)
imagesc(im)
axis image;set (gca,'XTick',[]);
set (gca,'YTick',[]);
im = im ./max(im(:));
img0 = im - mean(mean(im));
RPFTGlobal= fft2_rp(img0);
RPFTGlobalShow = RPFTGlobal([2:size(RPFTGlobal,1)/2+1,size(RPFTGlobal,1)/2+1:size(RPFTGlobal,1)],:);
FFTGlobal = fftshift(fft2(im));
FFTGlobalShow = FFTGlobal([2:size(FFTGlobal,1)/2+1,size(FFTGlobal,1)/2+1:size(FFTGlobal,1)],:);
% build a best basis for this image
RPPkt = CalcRPPktTable(RPFTGlobal,D,'Sine');
RPtree = CalcRPStatTree(RPPkt,D,Entropy,EntPar);
bb = BestRPBasis(RPtree,D);
subplot(1,3,2)
AutoImageInv(abs(RPFTGlobalShow));
Polrax = axis; hold on;
PlotRPPartition(bb,'r',Polrax,D);
% calculate statistics
coef = FPT2_RPkt(bb,img0,D);
e = CalcEntropy(coef,Entropy,EntPar);
set(gca,'XTick',[]);
set(gca,'YTick',[]);
% show the fft domain with the best bases
subplot(1,3,3)
AutoImageInv(log(1+abs(FFTGlobalShow)));
Polrax = axis; hold on;
PlotRectoPolarRPPartition(bb,'r',Polrax,D);
set(gca,'XTick',[]);
set(gca,'YTick',[]);
colormap(hot)
%------------------
WLVERBOSE = 'Yes';
%------------------
%% Part of BeamLab Version:200% Built:Friday,23-Aug-2002 00:00:00% This is Copyrighted Material% For Copying permissions see COPYING.m% Comments? e-mail beamlab@stat.stanford.edu%%% 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 + -