matlAB图像处理程序与实操解析.docx

  1. 1、本文档共38页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1图像处理基础 1.1图像读取 %图像的读取、显示 clear all; clc; f = imread(pout.tif); %读 [M,N] = size(f); %大小291×240 whos f; %附加信息 imwrite(f,pout,tif); %写 figure(1);%显示多张图片 imshow(f);%原图像, figure(2);%显示多张图片 imshow(f,[])%[]修正 1.2格式转换 f = imread(f.png , png); imwrite(f , f.bmp , bmp); 1.3图像数据类型转换 %MatlAB读入的数据类型是uint8,而在矩阵中使用的数据类型是double,如果不转换,在对uint8进行加减时会产生溢出 f = imread(rice.png); I = im2double(f); J = im2uint8(I); K = im2uint16(J); subplot(2,2,1); imshow(f); subplot(2,2,2); imshow(I); subplot(2,2,3); imshow(J); subplot(2,2,4); imshow(K); %在MatlAB中,我们常使用imshow()函数来显示图像,而此时的图像可能经过了某种运算。在MatlAB中,为了保证精度,经过了运算的图像矩阵I其类型会从uint8型变成double型。如果直接运行imshow(I),会发现显示的是一个白色图像。这是因为imshow()显示图像时默认double型在0~1范围内,即大于1时都显示为白色,而imshow显示uint8型图像是在0~255范围内。法一:利用imshow(1/256)将图像矩阵转化到0~1之间;法二:利用imshow(I,[])自动调整数据的显示范围以便于显示 1.4图像之间的转换 %索引图像与灰度图像之间的转换代码 clear all; clc; I = imread(pout.tif); subplot(1,3,1);imshow(I); [I1 , map1] = gray2ind(I , 28); [I2 , map2] = gray2ind(I , 16); subplot(1,3,2);imshow(I1 , map1); subplot(1,3,3);imshow(I2 , map2); %RGB图像与灰度图像之间的转换代码 clear all; clc; RGB = imread(autumn.tif); subplot(1,2,1);imshow(RGB); I = rgb2gray(RGB); subplot(1,2,2);imshow(I); %RGB图像与索引图像之间的转换代码 clear all; clc; RGB = imread(autumn.tif); subplot(1,3,1);imshow(RGB); [I , map] = rgb2ind(RGB , 228); subplot(1,3,2);imshow(I , map); subplot(1,3,3);imshow(I ); colormap(map); %灰度图像与二进制图像之间的转换代码 clear all; clc; I = imread(eight.tif); subplot(1,2,1);imshow(I); BW = im2bw(I , 0.5); subplot(1,2,2);imshow(BW); 1.5图像的点运算 %线性点运算 clear all;clc; A = imread(lena.jpg); B1 = A + 50; %图像灰度值增加50 subplot(3,2,1);imshow(A); subplot(3,2,2);imshow(B1); B2 = 1.5*A; %图像对比度增大 subplot(3,2,3);imshow(B2); B3 = 0.8*A; %图像对比度减小 subplot(3,2,4);imshow(B3); B4 = -double(A) + 255; % 求补 subplot(3,2,5);imshow(uint8(B4)); %非线性点运算 clear all; clc; A = imread(lena.jpg); subplot(2,2,1); imshow(A); x = 1 : 255; y = x + x .* (255 - x) / 255; subplot(2,2,2); plot(x,y); B1 = double(A) + 0.005 * double(A) .* (255 - double(A));%非线性处理 subplot(2,2,3);imsh

您可能关注的文档

文档评论(0)

yaocen + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档