MATLAB图像的基本处理

    xiaoxiao2021-12-14  20

    1、图像文件读写和显示 close all; clear all; clc; I=imread('ee','jpeg');%图像文件的读写 B=rgb2gray(I);%图像文件转换 figure(1);%画图 subplot(2,2,1);imshow(B,[60,120]);%图像文件的显示并指定灰度值的范围 subplot(2,2,2);image([50 300],[50 200],B);%调整图像的坐标 subplot(2,2,3);imagesc(B,[50 200]);%显示灰度拉伸后的图像 subplot(2,2,4);imshow(B,[]);colorbar('east');%添加彩色条,在图像内侧 figure(2); [x,y,z]=sphere; warp(x,y,z,I);%把图像映射到三维空间中 grid; figure(3); r=[104 156 129]; c=[12 146 410]; pixel1=impixel(I);%用鼠标选取特定坐标的像素 disp(pixel1); pixel2=impixel(I,c,r);%在某个范围内显示像素信息 disp(pixel2); 2、图像增强 close all; clear all; clc; %直方图均衡化 I=imread('ee.jpg'); B=rgb2gray(I); J=histeq(B); figure(1); subplot(2,2,1);imshow(B); subplot(2,2,2);imshow(J); subplot(2,2,3);imhist(B); subplot(2,2,4);imhist(J); %直方图规定化 hgram=ones(1,25); J2=histeq(B,hgram); figure(2); subplot(1,2,1);imshow(J2); subplot(1,2,2);imhist(J2); 3、图像分割 close all; clear all; clc; I=imread('ee.jpg'); I=rgb2gray(I); [J,thresh]=edge(I,'sobel',[],'both'); [K,thresh]=edge(K,'canny'); figure; subplot(1,3,1);imshow(I); subplot(1,3,2);imshow(J); subplot(1,3,3);imshow(K); 4、图像变换 close all; clear all; clc; I=imread('ee.jpg'); I=rgb2gray(I); BW=edge(I,'canny'); [H,theta,rho]=hough(BW,'RhoResolution',0.5,'ThetaResolution',0.5); figure; subplot(121);imshow(BW); subplot(122);imshow(imadjust(mat2gray(H))); axis normal;
    转载请注明原文地址: https://ju.6miu.com/read-969716.html

    最新回复(0)