資源描述:
《數(shù)字圖像處理MATLAB相關(guān)代碼.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、1.圖像反轉(zhuǎn)MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp');J=double(I);J=-J+(256-1);????????????????%圖像反轉(zhuǎn)線性變換H=uint8(J);subplot(1,2,1),imshow(I);subplot(1,2,2),imshow(H);2.灰度線性變換MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp');subplot(2,2,1),imshow(I);title('原始圖像');axis([50,250,50,200]);axison;?????????????????
2、%顯示坐標(biāo)系I1=rgb2gray(I);subplot(2,2,2),imshow(I1);title('灰度圖像');axis([50,250,50,200]);axison;?????????????????%顯示坐標(biāo)系J=imadjust(I1,[0.10.5],[]);%局部拉伸,把[0.10.5]內(nèi)的灰度拉伸為[01]subplot(2,2,3),imshow(J);title('線性變換圖像[0.10.5]');axis([50,250,50,200]);gridon;?????????????????%顯示網(wǎng)格線axison;????
3、?????????????%顯示坐標(biāo)系K=imadjust(I1,[0.30.7],[]);%局部拉伸,把[0.30.7]內(nèi)的灰度拉伸為[01]subplot(2,2,4),imshow(K);title('線性變換圖像[0.30.7]');axis([50,250,50,200]);gridon;?????????????????%顯示網(wǎng)格線axison;?????????????????%顯示坐標(biāo)系3.非線性變換MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp');I1=rgb2gray(I);subplot(1,2,1),imsh
4、ow(I1);title('灰度圖像');axis([50,250,50,200]);gridon;?????????????????%顯示網(wǎng)格線axison;?????????????????%顯示坐標(biāo)系J=double(I1);J=40*(log(J+1));H=uint8(J);subplot(1,2,2),imshow(H);title('對(duì)數(shù)變換圖像');axis([50,250,50,200]);gridon;?????????????????%顯示網(wǎng)格線axison;?????????????????%顯示坐標(biāo)系4.直方圖均衡化MATL
5、AB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp');I=rgb2gray(I);figure;subplot(2,2,1);imshow(I);subplot(2,2,2);imhist(I);I1=histeq(I);figure;subplot(2,2,1);imshow(I1);subplot(2,2,2);imhist(I1);5.線性平滑濾波器用MATLAB實(shí)現(xiàn)領(lǐng)域平均法抑制噪聲程序:I=imread('xian.bmp');subplot(231)imshow(I)title('原始圖像')I=rgb2gray(I);I1=imn
6、oise(I,'salt&pepper',0.02);subplot(232)imshow(I1)title('添加椒鹽噪聲的圖像')k1=filter2(fspecial('average',3),I1)/255;?????????%進(jìn)行3*3模板平滑濾波k2=filter2(fspecial('average',5),I1)/255;?????????%進(jìn)行5*5模板平滑濾波k3=filter2(fspecial('average',7),I1)/255;?????????%進(jìn)行7*7模板平滑濾波k4=filter2(fspecial('aver
7、age',9),I1)/255;?????????%進(jìn)行9*9模板平滑濾波subplot(233),imshow(k1);title('3*3模板平滑濾波');subplot(234),imshow(k2);title('5*5模板平滑濾波');subplot(235),imshow(k3);title('7*7模板平滑濾波');subplot(236),imshow(k4);title('9*9模板平滑濾波');6.中值濾波器用MATLAB實(shí)現(xiàn)中值濾波程序如下:I=imread('xian.bmp');I=rgb2gray(I);J=imnoise
8、(I,'salt&pepper',0.02);subplot(231),imshow(I);title('原