curvelet下載的curvelet工具包,有以下三個文件:fdct_usfft_matlab、fdct_wrapping_matlab、mecv三個文件夾添加到matlab路徑中即可。
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, 2004
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相對應 [A,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);
示例代碼流程:
* 首先創建了一副空圖像,對其進行DCT變化,得到其系數C(可以理解為一個四維矩陣,由於每個二維矩陣維度不同,故使用cell數據結構),當然C中的元素全為0。
* 之后將其尺度s、角度為w的二維矩陣C{s}{w}中心元素設置為1,對C進行IDCT變換,得到其空間域的圖像Y。
* 之后對Y做傅里葉變換,得到其頻率域圖像F。繪制Y與F的圖像。
2.1 變化后系數矩陣維度的理解
下表顯示了對圖像做C = fdct_wrapping(X,0,2,6,16);
變換后,得到系數C的詳細信息,其中原始圖片大小為512*512。最內層即Coarse是由低頻系數組成的一個矩陣,最外層Fine是高頻系數組成的矩陣。
層次 | 尺度系數 | 方向參量的個數 | 矩陣的形式 |
---|---|---|---|
Coarse | C{1} | 1 | 21*21 |
Detail | C{2} | 16 | 18*22 16*22 22*18 22*16 |
C{3} | 32 | 34*22 32*22 22*32 22*34 | |
C{4} | 32 | 67*44 64*43 64*44 44*64 43*64 44*67 | |
C{5} | 64 | 131*44 128*43 128*44 44*128 43*128 44*131 | |
Fine | C{6} | 1 | 512*512 |
2.2 尺度數s的影響
下圖顯示了對圖像做C = fdct_wrapping(X,0,2,6,16);
變換后,s=1:6,w=1下的空間域與頻域的圖像。可以看出:
1. 隨着s增大,即尺度由最佳尺度變為最粗尺度時,空間域的“針”圖形組件變細,而頻率域的“針”圖像逐漸變粗。這個可以由空間域和頻率域具有一定的對稱性得知,空間域越“胖”,頻率域越“瘦”。
2. 尺度s值越大,代表的的越是高頻信息。
2.2 角度數w的影響
下圖顯示了對圖像做C = fdct_wrapping(X,0,2,6,16);
變換后,s=5,w=1:10:60下的空間域與頻域的圖像。可以看出:
w=1時,“楔形”位於左上角位置,隨着w增大,“楔形”順時針轉動。由於空間限制,只貼出部分圖片。
2.3 位置a b(其元素值為1)的影響
下圖所示為對原始圖像進行C = fdct_wrapping(X,0,2,total_s,16);
,改變C{5}{1}(a,b)=1;,a b取值變化時所對應空間域與頻率域的圖像,可以看出:
a b的改變並不會對頻率域圖像造成影響,而在空間域上“針”狀物體會根據a b的值發生相應的位移。
3 curvelet的性質
- 小波變換是一種具有較強時、頻局部分析功能的非平穩信號分析方法成功地應用於信號的特征提取領域,曲波變換作為新一代的多尺度幾何分析工具取得了較好的識別效果,它考慮了尺度、位置、角度信息使其在表達圖像中的曲線時明顯優於小波變換。
- Curvelet變換各向異性的特點更適合分析圖像中的曲線或直線狀邊緣特征。
- 符合生理學研究指出的“最優”圖像表示方法應該具有的三種特征,多分辨、帶通、具有方向性。