curvelet matlab示例代碼理解
1. fdct_wrapping
function C = fdct_wrapping(x, is_real, finest, nbscales, nbangles_coarse)
% fdct_wrapping.m - Fast Discrete Curvelet Transform via wedge wrapping - Version 1.0
%
% Inputs
% x M-by-N matrix 輸入為MxN的矩陣
%
% Optional Inputs
% is_real Type of the transform 轉化的類型
% 0: complex-valued curvelets 復數值的曲波變化
% 1: real-valued curvelets 實數值的曲波變化
% [default set to 0] 默認設置為0
% finest Chooses one of two possibilities for the coefficients at the
% finest level: 選擇一種表示方式計算最優級的系數
% 1: curvelets 曲波變化
% 2: wavelets 小波變化
% [default set to 2] 默認設置為2
% nbscales number of scales including the coarsest wavelet level
% 包含最粗小波級在內的伸縮數
% [default set to ceil(log2(min(M,N)) - 3)]
% nbangles_coarse
% number of angles at the 2nd coarsest level, minimum 8,
% 第二粗糙級的角度數,最小為8
% must be a multiple of 4. [default set to 16]
% 必須為4的倍數,默認為16
% Outputs
% C Cell array of curvelet coefficients.
% C{j}{l}(k1,k2) is the coefficient at
% - scale j: integer, from finest to coarsest scale,
% 從最佳尺度到最粗尺度
% - angle l: integer, starts at the top-left corner and
% increases clockwise,
% 從左上角開始順時針增長
% - position k1,k2: both integers, size varies with j
% and l.
% If is_real is 1, there are two types of curvelets,
% ‘cosine’ and ‘sine’。 For a given scale j, the ‘cosine’
% coefficients are stored in the first two quadrants (low
% values of l), the ‘sine’ coefficients in the last two
% quadrants (high values of l)。
%
% See also ifdct_wrapping.m, fdct_wrapping_param.m
%
% By Laurent Demanet, 200412345678910111213141516171819202122232425262728293031323334353637383940414243
2. DCT基本示例代碼理解
% fdct_wrapping_demo_basic.m -- Displays a curvelet both in the spatial and frequency domains.
m = 1024;
n = 1024;
X = zeros(m,n);
%forward curvelet transform
disp(‘Take curvelet transform: fdct_wrapping’);
tic; C = fdct_wrapping(X,0,2,8,64); toc; %tic toc配合使用測量程序運行時間
%specify one curvelet
s = 7; %從1開始增大,空間域變細,頻率域變粗
w = 10;%從1(左上角)開始增大,空間域順時針旋轉,與笛卡爾corona相對應
?。跘,B] = size(C{s}{w});%尺度為s,方向為w,的矩陣大小
a = ceil((A+1)/2);
b = ceil((B+1)/5);
C{s}{w}(a,b) = 1; %該尺度、方向中心位置元素設置為1
%adjoint curvelet transform
disp(‘Take adjoint curvelet transform: ifdct_wrapping’);
tic; Y = ifdct_wrapping(C,0); toc;%進行反曲波變化,得到空間域圖像
%display the curvelet
F = ifftshift(fft2(fftshift(Y)));
subplot(1,2,1); colormap gray; imagesc(real(Y)); axis(‘image’); 。。。
title(‘a curvelet: spatial viewpoint’);
subplot(1,2,2); colormap gray; imagesc(abs(F)); axis(‘image’); 。。。
title(‘a curvelet: frequency viewpoint’);
%get parameters
[SX,SY,FX,FY,NX,NY] = fdct_wrapping_param(C);
評論
查看更多