赞
踩
记载一些Matlab中处理图像的简单函数
[filename pathname]=uigetfile('*.*,*.png','文件选择','*.png')
im = imread([pathname filename]);
imshow(im);
title('原图');
im = imread('rabbit.jpg');
imshow(im);
title('原图');
[x,map] = imread('rabbit.jpg');
imshow(x);
title('原图');
imshow('girl.jpg');
im=getimage;
[x,map] = imread('rabbit.jpg');
imshow(x);
title('原图');
colorbar;
bw1=zeros(100,100);
bw1(2:2:98,2:2:98)=1;
imshow(bw1);
运行结果:
bw1 = zeros(100,100);
bw1(2:2:98,2:2:98)=1;
bw2 = uint8(bw1);
imshow(bw2,[]);
colorbar;
load trees;
[x2,map2]=imread('girl.jpg');
subplot(2,1,1),subimage(X,map);colorbar;
subplot(2,1,2),subimage(x2);colorbar ;
load trees; %读取二进制数据文件
[x2,map2]=imread('girl.jpg');
subplot(2,1,1),imshow(x2,map2);colorbar
subplot(2,1,2),imshow(X,map);colorbar
代码如下(示例):
[x,map] = imread('girl.jpg');
imwrite(x,'girl.tif');
imfinfo('girl.jpg')
im = imread('girl.jpg');
if ndims(im) == 3
im = rgb2gray(im); %如果非灰度图像,则转换为灰度图像
end
imhist(im);
I = imread('girl.jpg');
J = imadjust(I,[0.3 0.7],[]);
subplot(1,2,1);
imshow(I);
title('原图');
subplot(1,2,2);
imshow(J);
title('对比度增强后');
I=imread('F:\已学专业课\大三专业课\数字图像处理\作业\实验\02\image\girl.jpg');
J1=imnoise(I, 'gaussian',0,0.02);
J2=imnoise(I, 'salt & pepper',0.02);
J3=imnoise(I, 'speckle',0.02);
subplot(2,2,1),imshow(I),title('原图像');
subplot(2,2,2),imshow(J1),title('加高斯噪声');
subplot(2,2,3),imshow(J2),title('加椒盐噪声');
subplot(2,2,4),imshow(J3),title('加乘性噪声')
I=imread('rabbit.jpg');
J = imresize(I,10);
imshow(I),title('原图像')
figure,imshow(J),title('放大后的图像');
I=imread('girl.jpg');
J=imrotate(I,30,'bilinear');
subplot(1,2,1);imshow(I);title('原图像')
subplot(1,2,2);imshow(J);title('旋转后的图像');
load imdemos saturn2
imshow(saturn2);title('原图');
B = fftshift(fft2(saturn2));
figure;
imshow(log(abs(B)),[]);title('傅里叶变换后');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。