日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数字图像处理之频率域图像增强

發布時間:2024/4/14 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数字图像处理之频率域图像增强 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
圖像進行傅立葉運算的物理意義

http://met.fzu.edu.cn/dip/chapter4.html
http://www.360doc.com/content/10/1128/20/2226925_73234298.shtml
http://blog.csdn.net/depraved_survival/article/details/1739743
http://www.360doc.com/content/12/0218/13/8795013_187569365.shtml
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
理想低通濾波器,過濾圖像中的高頻成分即噪聲(但是也包含邊緣)
function out = imidealflpf(I, freq) % imidealflpf函數 構造理想的頻域低通濾波器 % I參數 輸入的灰度圖像 % freq參數 低通濾波器的截止頻率 % 返回值:out – 指定的理想低通濾波器 [M,N] = size(I); out = ones(M,N); for i=1:Mfor j=1:Nif (sqrt(((i-M/2)^2+(j-N/2)^2))>freq)out(i,j)=0;endend end function out = imfreqfilt(I, ff) % imfreqfilt函數 對灰度圖像進行頻域濾波 % 參數I 輸入的空域圖像 % 參數ff 應用的與原圖像等大的頻域濾鏡if (ndims(I)==3) && (size(I,3)==3) % RGB圖像I = rgb2gray(I); endif (size(I) ~= size(ff))msg1 = sprintf('%s: 濾鏡與原圖像不等大,檢查輸入', mfilename);msg2 = sprintf('%s: 濾波操作已經取消', mfilename);eid = sprintf('Images:%s:ImageSizeNotEqual',mfilename);error(eid,'%s %s',msg1,msg2); end% 快速傅立葉變換 f = fft2(I);% 移動原點 s = fftshift(f);% 應用濾鏡及反變換 out = s .* ff; %對應元素相乘實現頻域濾波 out = ifftshift(out); out = ifft2(out);% 求模值 out = abs(out);% 歸一化以便顯示 out = out/max(out(:));I=imread('baby_noise.bmp'); figure(1);subplot(1,4,1);imshow(I);title('source'); %求源圖像的fft頻譜圖 temp=fft2(I);%做fft變換 temp=fftshift(temp);%將零點移到中心 temp=log(1+abs(temp));%對幅值做對數變換,以壓縮動態范圍 figure(2);subplot(1,4,1);imshow(temp,[]);title('I');%temp是double array,是浮點數,需要[].ff=imidealflpf(I,20);%生成濾鏡,頻率是20即0-20之間的低頻帶被保留,大于20的高頻帶丟失 out=imfreqfilt(I,ff);%應用濾鏡,即執行fft figure(1);subplot(1,4,2);imshow(out);title('ideal lpf ,20'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,2);imshow(temp,[]);title('20');ff=imidealflpf(I,40); out=imfreqfilt(I,ff); figure(1);subplot(1,4,3);imshow(out);title('ideal lpf ,40'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,3);imshow(temp,[]);title('40');ff=imidealflpf(I,60); out=imfreqfilt(I,ff); figure(1);subplot(1,4,4);imshow(out);title('ideal lpf ,60'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,4);imshow(temp,[]);title('60');


、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
高斯低通濾波器

將上面的函數imidealflpf換成imgaussflpf,如下
function out = imgaussflpf(I, sigma) % imgaussflpf函數 構造頻域高斯低通濾波器 % I參數 輸入的灰度圖像 % sigma參數 高斯函數的Sigma參數[M,N] = size(I); out = ones(M,N); for i=1:Mfor j=1:Nout(i,j) = exp(-((i-M/2)^2+(j-N/2)^2)/2/sigma^2);end endI=imread('baby_noise.bmp'); figure(1);subplot(1,4,1);imshow(I);title('source'); %求源圖像的fft頻譜圖 temp=fft2(I); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,1);imshow(temp,[]);title('I');ff=imgaussflpf(I,20);%生成濾鏡,sigma=20,sigma越大保留的信息越多 out=imfreqfilt(I,ff);%應用濾鏡,即執行fft figure(1);subplot(1,4,2);imshow(out);title('gauss lpf ,20'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,2);imshow(temp,[]);title('20');ff=imgaussflpf(I,40); out=imfreqfilt(I,ff); figure(1);subplot(1,4,3);imshow(out);title('gauss lpf ,40'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,3);imshow(temp,[]);title('40');ff=imgaussflpf(I,60); out=imfreqfilt(I,ff); figure(1);subplot(1,4,4);imshow(out);title('gauss lpf ,60'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,4);imshow(temp,[]);title('60');


貌似在抑制噪聲的同時,圖像的模糊程度更低了,比理想低通濾波器的效果好一點。
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
高斯高通濾波器
function out = imgaussfhpf(I, sigma) % imgaussfhpf函數 構造頻域高斯高通濾波器 % I參數 輸入的灰度圖像 % sigma參數 高斯函數的Sigma參數[M,N] = size(I); out = ones(M,N); for i=1:Mfor j=1:Nout(i,j) = 1 - exp(-((i-M/2)^2+(j-N/2)^2)/2/sigma^2);end end I=imread('baby_noise.bmp'); figure(1);subplot(1,4,1);imshow(I);title('source'); %求源圖像的fft頻譜圖 temp=fft2(I); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,1);imshow(temp,[]);title('I');ff=imgaussfhpf(I,20);%生成濾鏡,sigma=20,sigma越大,邊緣提取越精確 out=imfreqfilt(I,ff);%應用濾鏡,即執行fft figure(1);subplot(1,4,2);imshow(out);title('gauss hpf ,20'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,2);imshow(temp,[]);title('20');ff=imgaussfhpf(I,40); out=imfreqfilt(I,ff); figure(1);subplot(1,4,3);imshow(out);title('gauss hpf ,40'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,3);imshow(temp,[]);title('40');ff=imgaussfhpf(I,60); out=imfreqfilt(I,ff); figure(1);subplot(1,4,4);imshow(out);title('gauss hpf ,60'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,4,4);imshow(temp,[]);title('60');


、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

拉普拉斯濾波器
function out = imlapf(I) % imlapff函數 構造頻域拉普拉斯濾波器 % I參數 輸入的灰度圖像[M,N] = size(I); out = ones(M,N); for i=1:Mfor j=1:Nout(i,j) = -((i-M/2)^2+(j-N/2)^2);end endI=imread('baby_noise.bmp'); figure(1);subplot(1,2,1);imshow(I);title('source'); %求源圖像的fft頻譜圖 temp=fft2(I); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,2,1);imshow(temp,[]);title('I');ff=imlapf(I);%生成濾鏡 out=imfreqfilt(I,ff);%應用濾鏡,即執行fft figure(1);subplot(1,2,2);imshow(out);title('lap'); %求out的fft頻譜圖 temp=fft2(out); temp=fftshift(temp); temp=log(1+abs(temp)); figure(2);subplot(1,2,2);imshow(temp,[]);title('lap');



、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
添加周期噪聲。使用帶阻濾波器消除之p230.
II=imread('lena.gif'); figure(1);subplot(1,2,1);imshow(II);title('source'); %顯視頻譜圖 ii_f=fft2(II); ii_f=fftshift(ii_f); ii_f=abs(ii_f); ii_f=log(1+ii_f); figure(2);subplot(1,2,1);imshow(ii_f,[]);title('source');%加周噪 [M,N]=size(II); I=double(II); for i=1:M for j=1:NI(i,j)=I(i,j) + 20*sin(20*i) + 20*sin(20*j); end end I=uint8(I); figure(1);subplot(1,2,2);imshow(I);title('add noise'); %顯視頻譜圖 i_f=fft2(I); i_f=fftshift(i_f); i_f=abs(i_f); i_f=log(1+i_f); figure(2);subplot(1,2,2);imshow(i_f,[]);title('add noise');


周期性圖像的傅立葉頻譜中出現了兩對相對于坐標軸對稱的亮點,它們分別對應于圖形圖像中水平和豎直方向的正弦噪聲。

轉載于:https://www.cnblogs.com/-song/archive/2012/03/25/3331883.html

總結

以上是生活随笔為你收集整理的数字图像处理之频率域图像增强的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。