标签:0.00 图像处理 demo eth home 信号 ast size blog
一般FFT在通信等领域都做的一维变换就能够了。可是在图像处理方面,须要做二维变换,这个时候就须要用到FFT2.
在利用Octave(或者matlab)里面的fft2()函数的时候,观察频率领域的图像还是要点额外的技巧的.以下的图像是我们想要的,也是我们人类才干够理解的(图片的中心表示低频区域,越是远离中心。频率越高,这里以下图片中,中心区域非常亮,value非常高,中心周围越来越暗,表示低频信号强,高频信号慢慢减弱)
>> result = fft2(dark_channel);
>> imshow(uint8(real(result)));
直接输出fft2的结果例如以下(正常人应该看不出什么吧~)
怎么得到之前我们给出的结果呢?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % code writer : EOF % code date : 2014.09.27 % code file : fft2_demo.m % e-mail : jasonleaster@gmail.com % % If there is something wrong with my code, please % touch me by e-mail. Thank you :) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all clc Original_img = imread('/home/jasonleaster/Picture/hand.png'); float_Orignal_img = double(Original_img); F64_WHITE = 255.0; F64_BLACK = 0.000; Original_img_row = size(Original_img,1); Original_img_col = size(Original_img,2); Original_img_channel = size(Original_img,3); for row = 1:Original_img_row for col = 1:Original_img_col min_piexl = F64_WHITE; for channel = 1: Original_img_channel if(min_piexl > Original_img(row,col,channel)) min_piexl = Original_img(row,col,channel); end end dark_channel(row,col) = min_piexl; end end result = fft2(dark_channel); %spectrum = fftshift(abs(result)); spectrum = result; figure(1); spectrum = spectrum*255/max(spectrum(:)); imshow(spectrum);
这里一定记得fftshift,不然会出现以下的结果,低频结果分散在四个角落
正确结果例如以下
标签:0.00 图像处理 demo eth home 信号 ast size blog
原文地址:http://www.cnblogs.com/gccbuaa/p/7152019.html