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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

数字图像处理之空间域图像增强

發布時間:2024/4/14 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数字图像处理之空间域图像增强 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
濾波過程就是在圖像f(x,y)中逐點移動模板(即濾波器),使模板中心和點(x,y)重合,濾波器在每一點的響應是根據模板的具體內容并通過預先定義的關系計算的。

將圖像的模板在圖像中逐像素移動,并對每個像素進行指定數量的計算的過程就是卷積過程。

包括圖像的平滑和銳化。平滑用于去除噪聲,銳化用于加強邊緣。
在平滑處理中平滑的對象是噪聲而不是邊緣,在銳化處理中銳化的對象是邊緣而不是噪聲。
包括平滑濾波器(低通濾波器)和銳化濾波器(高通濾波器) p171
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

5.3圖像平滑

imfilter濾波
>> help imfilterIMFILTER Multidimensional image filtering.B = IMFILTER(A,H) filters the multidimensional array A with themultidimensional filter H. A can be logical or it can be a nonsparse numeric array of any class and dimension. The result, B, has the same size and class as A.Each element of the output, B, is computed using double-precisionfloating point. If A is an integer or logical array, then output elements that exceed the range of the given type are truncated, and fractional values are rounded.B = IMFILTER(A,H,OPTION1,OPTION2,...) performs multidimensionalfiltering according to the specified options. Option arguments canhave the following values:- Boundary optionsX Input array values outside the bounds of the arrayare implicitly assumed to have the value X. When noboundary option is specified, IMFILTER uses X = 0.'symmetric' Input array values outside the bounds of the arrayare computed by mirror-reflecting the array acrossthe array border.'replicate' Input array values outside the bounds of the arrayare assumed to equal the nearest array bordervalue.'circular' Input array values outside the bounds of the arrayare computed by implicitly assuming the input arrayis periodic.- Output size options(Output size options for IMFILTER are analogous to the SHAPE optionin the functions CONV2 and FILTER2.)'same' The output array is the same size as the inputarray. This is the default behavior when no outputsize options are specified.'full' The output array is the full filtered result, and sois larger than the input array.- Correlation and convolution'corr' IMFILTER performs multidimensional filtering usingcorrelation, which is the same way that FILTER2performs filtering. When no correlation orconvolution option is specified, IMFILTER usescorrelation.'conv' IMFILTER performs multidimensional filtering usingconvolution.Example -------------rgb = imread('flowers.tif'); h = fspecial('motion',50,45); rgb2 = imfilter(rgb,h); imshow(rgb), title('Original') figure, imshow(rgb2), title('Filtered') rgb3 = imfilter(rgb,h,'replicate'); figure, imshow(rgb3), title('Filtered with boundary replication')See also CONV2, CONVN, FILTER2.
平均模板濾波器
??? I=imread('baby_noise.bmp');????? ?subplot(1,4,1);;imshow(I);title('source');?? ?h=fspecial('average',3);%3x3模板?? ?I3=imfilter(I,h,'corr','replicate');%執行濾波,replicate重復??? ?subplot(1,4,2);;imshow(I3);title('3');?? ?h=fspecial('average',5);%5x5模板?? ?I5=imfilter(I,h,'corr','replicate');?? ?subplot(1,4,3);;imshow(I5);title('5');?? ?h=fspecial('average',7);%7x7模板?? ?I7=imfilter(I,h,'corr','replicate');?? ?subplot(1,4,4);;imshow(I7);title('7');??

高斯模板:由于平均模板對鄰域內的像素一視同仁,為了減少平滑處理中的模糊,得到更自然的平滑效果,則會很自然的想到適當加大模板中點的權重,隨著遠離中心點,權重迅速減少,從而可以確保中心點看起來更接近與他距離更近的點,基于這種考慮的模板是高斯模板。
高斯模板的名字由來是二維高斯函數,即二維正態分布函數。方差是sigma。
sigma過小,偏離中心的所有像素的權重將會非常小,相當于沒有濾波效果。反之相反。

I=imread('baby_noise.bmp');?? ? subplot(1,4,1);imshow(I);title('source'); h=fspecial('gaussian',3,0.5);%3是板數0.5是sigma ? I3_5=imfilter(I,h); ? subplot(1,4,2);imshow(I3_5);title('3_5'); ?h=fspecial('gaussian',3,0.8); ? I3_8=imfilter(I,h); ? subplot(1,4,3);imshow(I3_8);title('3_8'); ?h=fspecial('gaussian',5,0.8); ? I5_8=imfilter(I,h); ? subplot(1,4,4);imshow(I5_8);title('5_8');

中值濾波
I=imread('lena.gif');%灰度圖像 subplot(1,4,1);imshow(I3);title('I'); J=imnoise(I,'salt & pepper');%添加椒鹽噪聲。黑點同胡椒,白點同鹽粒。subplot(1,4,2);imshow(J);title('J'); h=fspecial('average',3);%3x3模板 I3=imfilter(I,h,'corr','replicate');%執行濾波,replicate重復 subplot(1,4,3);imshow(I3);title('3X3平均'); J=medfilt2(J,[3,3]);%中值濾波subplot(1,4,4);imshow(I3);title('medfilt2');

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
5.5圖像銳化

圖像銳化主要用于增強圖像中的灰度跳變部分,這一點與圖像平滑對灰度跳變的抑制作用剛好相反。事實上從平滑與銳化的兩種運算算子上也能看出,線性平滑都是基于對圖像鄰域的加權求和或積分運算,而銳化則是其逆運算導數(梯度)或有限差分來實現。
噪聲和邊緣都會使圖像產生灰度跳變,需要將噪聲和邊緣區分。
在平滑處理中平滑的對象是噪聲而不是邊緣,在銳化處理中銳化的對象是邊緣而不是噪聲。
5.5.2.基于一階導數的圖像增強--梯度算子
1.robert交叉梯度
--需要兩次濾波,然后求和
i=imread('bacteria.BMP'); subplot(1,4,1);imshow(i); title('source') ;i=double(i); w1=[-1,0;0,1]; %對正45度方向的邊緣有較強響應,從圖g1可以看出w2=[0,-1;1,0]; %對負45度方向的邊緣有較強響應,從圖g2可以看出g1=imfilter(i,w1,'corr','replicate');%正45度濾波 g2=imfilter(i,w2,'corr','replicate');%負45度濾波g=abs(g1)+abs(g2); subplot(1,4,2);imshow(abs(g1),[]);title('g1') ;subplot(1,4,3);imshow(abs(g2),[]);title('g2');subplot(1,4,4);imshow(g,[]);title('g') ;

2.sobel梯度

5.5.3.基于2階微分的圖像增強--拉普拉斯算子。由于各向同性,所以只需一次濾波。
I=imread('bacteria.BMP'); subplot(1,4,1);imshow(I); title('source') ; I=double(I); w1=[0 -1 0;-1 4 -1;0 -1 0];L1=imfilter(I,w1,'corr','replicate');subplot(1,4,2);imshow(abs(L1),[]); title('w1模板') ; w2=[-1 -1 -1;-1 8 -1;-1 -1 -1];L2=imfilter(I,w2,'corr','replicate');subplot(1,4,3);imshow(abs(L2),[]); title('w2模板') ; w3=[1 4 1;4 -20 4;1 4 1];%加權模板L3=imfilter(I,w3,'corr','replicate');subplot(1,4,4);imshow(abs(L3),[]); title('w3模板') ;
5.5.5高頻提升濾波機器實現
無論是基于一階微分的robert還是基于二階微分的拉普拉斯的模板,其中各系數和均為0。這說明算子在灰度恒定的區域響應為0,即在銳化處理后的圖像中,源圖像的平滑區近乎于黑色,而原圖中所有的邊緣,細節,和灰度跳變點都在黑背景中顯示出來。在基于銳化的圖像增強中,我們常常希望在增強邊緣和細節的同時,仍然保留原圖像中的信息,而不是將平滑區域的灰度信息丟失。因此可以將源圖像加上銳化后的圖像以得到比較理想的圖像。
p171

5.5.6高斯-拉普拉斯變換 LoG
I=imread('lena.gif'); subplot(1,4,1);imshow(I); title('source') ; I_double=double(I); %濾波前轉化為雙精度 h_lap=[-1 -1 -1;-1 8 -1;-1 -1 -1];%拉普拉斯算子I_lap=imfilter(I_double,h_lap,'corr','replicate');%拉普拉斯銳化subplot(1,4,2);imshow(uint8(abs(I_lap)),[]); title('lap');h_log=fspecial('log',5,0.5);%log模板,sigma=0.5I_log=imfilter(I_double,h_log,'corr','replicate');%log濾波subplot(1,4,3);imshow(uint8(abs(I_lap)),[]); title('log 0.5') ;h_log=fspecial('log',5,2);%log模板,sigma=2I_log=imfilter(I_double,h_log,'corr','replicate');%log濾波subplot(1,4,4);imshow(uint8(abs(I_lap)),[]); title('log 2') ;

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

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

總結

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

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