matlab圖像處理

matlab的基礎圖像處理步驟:
1.圖像的讀入、顯示及信息查詢:
(1)I=imread (‘lena.jpg’) %圖像讀入
imshow(I) %圖像顯示

(2)inf=imfinfo(‘lena.jpg’) % 圖像信息查詢
2.圖像的常用處理語句:
(1) X=rgb2gray(I) ; imshow(X) %彩色圖像轉灰度圖像
(2)X2=grayslice(I,64) ; imshow(X2,hot(64)) %將灰度圖像轉爲索引色圖像
(3) X3=im2bw(X1) ; imshow(X3) %將圖像轉二值圖像

3.圖像濾波:
clear all
g0==imread(‘F:\PICTURE\cat2.bmp’)
g0 = g0(:,:,2); %三維轉二維

figure(1);imshow(g0) ;title(‘原圖’)
g1=imnoise(g0,’salt & pepper’,0.2)
g1=im2double(g1);
figure(2);imshow(g1);title(‘加入椒鹽噪聲’)
h1=fspecial(‘gaussian’,4,0.3)
g2=filter2(h1,g1,’same’)
figure(3);imshow(g2);title(‘進行高斯濾波’)
h2=fspecial(‘sobel’)
g3=filter2(h2,g1,’same’)
figure(4);imshow(g3);title(‘進行sobel濾波’)
h3=fspecial(‘prewitt’)
g4=filter2(h3,g1,’same’)
figure(5);imshow(g4);title(‘進行prewitt濾波’)
h4=fspecial(‘laplacian’,0.5);
g5=filter2(h4,g1,’same’);
figure(6);imshow(g5);title(‘進行拉普拉斯濾波’);
h5=fspecial(‘log’,4,0.3);
g6=filter2(h5,g1,’same’);figure(7);
imshow(g6);title(‘進行高斯拉普拉斯濾波’);
h6=fspecial(‘average’);
g7=filter2(h6,g1,’same’);figure(8);
imshow(g7);title(‘進行均值濾波’);

h7=fspecial(‘unsharp’,0.3);
g8=filter2(h7,g1,’same’);
figure(9);imshow(g8);title(‘進行模糊濾波’);
h8=[0 -1 0;-1 5 -1;0 -1 0];
g9=filter2(h8,g1,’same’);
figure(10);imshow(g9);title(‘進行高通高斯濾波’);
h9=g1;g10=medfilt2(h9);
figure(11);imshow(g10);title(‘進行中值濾波’);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章