matlab图像处理

    xiaoxiao2021-12-14  21

    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(‘进行中值滤波’);

    转载请注明原文地址: https://ju.6miu.com/read-969027.html

    最新回复(0)