matlab图像处理基础实例 联系客服

发布时间 : 星期六 文章matlab图像处理基础实例更新完毕开始阅读4f97b806a6c30c2259019e94

得到图像边界,并计算周长、面积和重心坐标 >> a=imread('lbxx.bmp'); >> a1=bwperim(a); >> l=0;

>> [m,n]=size(a1); >> for i=1:m*n if(a1(i)==1) l=l+1; end end

>> [m,n]=size(a);s=0; >> for i=1:m*n if(a(i)==1) s=s+1; end end

>> x=0;y=0; >> for i=1:m for j=1:n if(a(i,j)==1) x=i+x;y=j+y; end end end

>> x=x/s;y=y/s; >> l,s,x,y

>> a=imread('trees.tif')%么有加;号

33 33 33 33 33 33 33 19 33 28 33 33 33 33 33 33 33 33 33 19 33 33 19 33 19 33 33 33 19 21 33 33 33 33 33 33 33 33 33 28 33 33 33 19 33 33 33 33 33 21 33 33 33 33 45 57 57 33 33 10 45 33 33 45 45 45 45 33 33 19 33 45 33 33 45 45 33 33 33 19 57 33 33 33 45 33 33 33 33 28 33 33 33 33 57 33 33 33 33 33 57 45 33 45 45 33 33 33 19 19 45 33 45 33 33 45 33 33 33 33 45 45 33 57 45 33 33 33 33 19 。。。。。。。。。。。。。。。。。。。 >> a=imread('trees.tif'); >> imshow(a) >> subplot(211) >> imshow(a) >> subplot(212) >> imshow(~a)

>> [x,map]=imread('trees.tif'); >> image(x);%显示矩阵x图像

>> Colormap(map)%设置颜色映射表,这样才可以将tif文件显示成彩色的????

>> i=imread('trees.tif'); >> j=filter2([1 2 -1 -2],i); >> imshow(j,[])

>> i=imread('rice.png'); >> subplot(121)

>> imshow(i,[100 200]);%灰度范围为[100 200] >> subplot(122)

>> imshow(i,20)%灰度等级为20

>> load trees

>> a=[10 60];imagesc(X,a);Colormap(gray)

imshow rice.png %直接从磁盘显示,无需单独读入

>> a=imread('onion.png'); >> i=rgb2gray(a);

>> h=[1 2 1;0 0 0;-1 -2 -1];

>> i2=filter2(h,i);%使用二维滤波器h进行滤波 >> imshow(i2,[]) >> colorbar

显示单帧图像

>> mri=uint8(zeros(128,128,1,27)); >> for frame=1:27

[mri(:,:,:,frame),map]=imread('mri.tif',frame); end

>> imshow(mri(:,:,:,3),map);%显示第三帧

problem:如何知道一幅图像有几帧???????? 显示多帧图像

>> montage(mri,map)