Matlab常用图像处理命令108例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Matlab常用图像处理命令108例相关的知识,希望对你有一定的参考价值。

文章和代码以及样例图片等相关资源,已经归档至【Github仓库:​​digital-image-processing-matlab​​】或者公众号【AIShareLab】回复 数字图像处理 也可获取。

1.applylut

在二进制图像中利用lookup 表进行边沿操作。

语法:

A = applylut(BW,lut)

举例

lut = makelut(sum(x(:)) == 4,2); 

BW1 = imread(text.tif);

BW2 = applylut(BW1,lut);

imshow(BW1)

figure, imshow(BW2)

Matlab常用图像处理命令108例(一)_图像处理

相关命令: makelut

2.bestblk

功能:确定进行块操作的块大小。

语法:

siz = bestblk([m n],k) 

[mb,nb] = bestblk([m n],k)

举例

siz = bestblk([640 800],72) 

siz = 64 50

相关命令: Blkproc

3.blkproc

功能:实现图像的显式块操作。

语法:

B = blkproc(A,[m n],fun) 

B = blkproc(A,[m n],fun,P1,P2,...)

B = blkproc(A,[m n],[mborder nborder],fun,...)

B = blkproc(A,indexed,...)

举例

I = imread(alumgrns.tif);

I2 = blkproc(I,[8 8],std2(x)*ones(size(x)));

imshow(I)

figure, imshow(I2,[]);

Matlab常用图像处理命令108例(一)_MATLAB_02

相关命令:

colfilt, nlfilter,inline

4.brighten

功能:增加或降低颜色映像表的亮度。

语法:

brighten(beta)
newmap = brighten(beta)
newmap = brighten(map,beta)
brighten(fig,beta)

相关命令:

imadjust, rgbplot

5.bwarea

功能:计算二进制图像对象的面积。

语法:

total = bwarea(BW)

举例

BW = imread(circles.tif);
imshow(BW);

Matlab常用图像处理命令108例(一)_MATLAB_03

bwarea(BW) 

ans =

15799

相关命令: bweuler, bwperim

6.bweuler

功能:计算二进制图像的欧拉数。

语法:

eul = bweuler(BW,n)

举例

BW = imread(circles.tif); 

imshow(BW);

bweuler(BW)

ans = –2

相关命令: bwmorph, bwperim

7.bwfill

功能:填充二进制图像的背景色。

语法:

BW2
= bwfill(BW1,c,r,n) BW2 =
bwfill(BW1,n) [BW2,idx] = bwfill(...)

BW2
= bwfill(x,y,BW1,xi,yi,n) [x,y,BW2,idx,xi,yi]
= bwfill(...) BW2 =
bwfill(BW1,holes,n) [BW2,idx] = bwfill(BW1,holes,n)

举例

BW1 =[1 0 0 0 0 0 0 0

1 1 1 1 1 0 0 0

1 0 0 0 1 0 1 0

1 0 0 0 1 1 1 0

1 1 1 1 0 1 1 1

1 0 0 1 1 0 1 0

1 0 0 0 1 0 1 0

1 0 0 0 1 1 1 0]

BW2 = bwfill(BW1,3,3,8)

BW2 =

1 0 0 0 0 0 0 0

1 1 1 1 1 0 0 0

1 1 1 1 1 0 1 0

1 1 1 1 1 1 1 0

1 1 1 1 0 1 1 1

1 0 0 1 1 0 1 0

1 0 0 0 1 0 1 0

1 0 0 0 1 1 1 0

I = imread(blood1.tif); BW3
= ~im2bw(I);

BW4
= bwfill(BW3,holes); imshow(BW3)

figure, imshow(BW4)

Matlab常用图像处理命令108例(一)_图像处理_04

相关命令: bwselect, roifill

8.bwlabel

功能:标注二进制图像中已连接的部分。

语法:

L = bwlabel(BW,n) [L,num] = bwlabel(BW,n) 举例 
BW = [1 1 1 0 0 0 0 0
1 1 1 0 1 1 0 0
1 1 1 0 1 1 0 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 1 1 0
1 1 1 0 0 0 0 0]
L = bwlabel(BW,4) L =
1 1 1 0 0 0 0 0
1 1 1 0 2 2 0 0
1 1 1 0 2 2 0 0
1 1 1 0 0 0 3 0
1 1 1 0 0 0 3 0

1 1 1 0 0 0 3 0
1 1 1 0 0 3 3 0
1 1 1 0 0 0 0 0
[r,c] = find(L==2); rc = [r c]
rc = 2 5
3 5
2 6
3 6

相关命令: bweuler, bwselect

9.bwmorph

功能:提取二进制图像的轮廓。

语法:

BW2 = bwmorph(BW1,operation) 
BW2 = bwmorph(BW1,operation,n)

举例

BW1 = imread(circles.tif);
imshow(BW1);

Matlab常用图像处理命令108例(一)_图像处理_05

BW2 = bwmorph(BW1,remove); 
BW3 = bwmorph(BW1,skel,Inf);
imshow(BW2)
figure, imshow(BW3)

Matlab常用图像处理命令108例(一)_图像处理_06

相关命令:

bweuler, bwperim, dilate, erode

10.bwperim

功能:计算二进制图像中对象的周长。

语法:

BW2 = bwperim(BW1,n)

举例

BW1 = imread(circbw.tif); 

BW2 = bwperim(BW1,8);

imshow(BW1)

figure, imshow(BW2)

Matlab常用图像处理命令108例(一)_图像处理_07

相关命令:

bwarea, bweuler, bwfill

参考文献:

[1] ​​Rafael C. Gonzalez, Richard E. Woods, and Steven L. Eddins. 2003. Digital Image Processing Using MATLAB. Prentice-Hall, Inc., USA.​

[2] ​​阮秋琦. 数字图像处理(MATLAB版)[M]. 北京:电子工业出版社, 2014.​

[3] ​​冈萨雷斯. 数字图像处理(第三版)[M]. 北京:电子工业出版社, 2011.​

以上是关于Matlab常用图像处理命令108例的主要内容,如果未能解决你的问题,请参考以下文章

Matlab常用图像处理命令108例

Matlab常用图像处理命令108例

基于SVM的图像分割-真彩色图像分割

OpenCV3编程入门_毛星云编著_电子工业出版下载 񕄥

边缘计算活动月丨承包你所有关于边缘计算的想法

如何用matlab来实现绘制工业摄像机站位的