Skip to content

Commit 6646c29

Browse files
committed
Add commands 1
1 parent cf2b9e0 commit 6646c29

File tree

2 files changed

+359
-14
lines changed

2 files changed

+359
-14
lines changed
Lines changed: 345 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
- [Matlab常用图像处理命令108例(一)](#matlab常用图像处理命令108例一)
2+
- [1.applylut](#1applylut)
3+
- [2.bestblk](#2bestblk)
4+
- [3.blkproc](#3blkproc)
5+
- [4.brighten](#4brighten)
6+
- [5.bwarea](#5bwarea)
7+
- [6.bweuler](#6bweuler)
8+
- [7.bwfill](#7bwfill)
9+
- [8.bwlabel](#8bwlabel)
10+
- [9.bwmorph](#9bwmorph)
11+
- [10.bwperim](#10bwperim)
12+
13+
14+
# Matlab常用图像处理命令108例(一)
15+
16+
## 1.applylut
17+
18+
在二进制图像中利用lookup 表进行边沿操作。
19+
20+
语法:
21+
22+
```matlab
23+
A = applylut(BW,lut)
24+
```
25+
26+
举例
27+
28+
```matlab
29+
lut = makelut('sum(x(:)) == 4',2);
30+
31+
BW1 = imread('text.tif');
32+
33+
BW2 = applylut(BW1,lut);
34+
35+
imshow(BW1)
36+
37+
figure, imshow(BW2)
38+
```
39+
40+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-08-57-55-1678496273.png)
41+
42+
相关命令: makelut
43+
44+
## 2.bestblk
45+
46+
功能:确定进行块操作的块大小。
47+
48+
语法:
49+
50+
```matlab
51+
siz = bestblk([m n],k)
52+
53+
[mb,nb] = bestblk([m n],k)
54+
```
55+
56+
举例
57+
58+
```matlab
59+
siz = bestblk([640 800],72)
60+
61+
siz = 64 50
62+
```
63+
64+
相关命令: Blkproc
65+
66+
## 3.blkproc
67+
68+
功能:实现图像的显式块操作。
69+
70+
语法:
71+
72+
```matlab
73+
B = blkproc(A,[m n],fun)
74+
75+
B = blkproc(A,[m n],fun,P1,P2,...)
76+
77+
B = blkproc(A,[m n],[mborder nborder],fun,...)
78+
79+
B = blkproc(A,'indexed',...)
80+
```
81+
82+
举例
83+
84+
```matlab
85+
I = imread('alumgrns.tif');
86+
87+
I2 = blkproc(I,[8 8],'std2(x)*ones(size(x))');
88+
89+
imshow(I)
90+
91+
figure, imshow(I2,[]);
92+
```
93+
94+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-00-58-1678496456.png)
95+
96+
相关命令:
97+
98+
colfilt, nlfilter,inline
99+
100+
## 4.brighten
101+
102+
功能:增加或降低颜色映像表的亮度。
103+
104+
语法:
105+
106+
```matlab
107+
brighten(beta)
108+
newmap = brighten(beta)
109+
newmap = brighten(map,beta)
110+
brighten(fig,beta)
111+
```
112+
113+
相关命令:
114+
115+
imadjust, rgbplot
116+
117+
## 5.bwarea
118+
119+
功能:计算二进制图像对象的面积。
120+
121+
语法:
122+
123+
```matlab
124+
total = bwarea(BW)
125+
```
126+
127+
举例
128+
129+
```matlab
130+
BW = imread('circles.tif');
131+
imshow(BW);
132+
```
133+
134+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-02-37-1678496556.png)
135+
136+
```matlab
137+
bwarea(BW)
138+
139+
ans =
140+
141+
15799
142+
```
143+
144+
相关命令: bweuler, bwperim
145+
146+
## 6.bweuler
147+
148+
功能:计算二进制图像的欧拉数。
149+
150+
语法:
151+
152+
```matlab
153+
eul = bweuler(BW,n)
154+
```
155+
156+
举例
157+
158+
```matlab
159+
BW = imread('circles.tif');
160+
161+
imshow(BW);
162+
163+
bweuler(BW)
164+
165+
ans = –2
166+
```
167+
168+
相关命令: bwmorph, bwperim
169+
170+
## 7.bwfill
171+
172+
功能:填充二进制图像的背景色。
173+
174+
语法:
175+
176+
```matlab
177+
BW2
178+
= bwfill(BW1,c,r,n) BW2 =
179+
bwfill(BW1,n) [BW2,idx] = bwfill(...)
180+
181+
BW2
182+
= bwfill(x,y,BW1,xi,yi,n) [x,y,BW2,idx,xi,yi]
183+
= bwfill(...) BW2 =
184+
bwfill(BW1,'holes',n) [BW2,idx] = bwfill(BW1,'holes',n)
185+
```
186+
187+
举例
188+
189+
```matlab
190+
BW1 =[1 0 0 0 0 0 0 0
191+
192+
1 1 1 1 1 0 0 0
193+
194+
1 0 0 0 1 0 1 0
195+
196+
1 0 0 0 1 1 1 0
197+
198+
1 1 1 1 0 1 1 1
199+
200+
1 0 0 1 1 0 1 0
201+
202+
1 0 0 0 1 0 1 0
203+
204+
1 0 0 0 1 1 1 0]
205+
206+
BW2 = bwfill(BW1,3,3,8)
207+
208+
BW2 =
209+
210+
1 0 0 0 0 0 0 0
211+
212+
1 1 1 1 1 0 0 0
213+
214+
1 1 1 1 1 0 1 0
215+
216+
1 1 1 1 1 1 1 0
217+
218+
1 1 1 1 0 1 1 1
219+
220+
1 0 0 1 1 0 1 0
221+
222+
1 0 0 0 1 0 1 0
223+
224+
1 0 0 0 1 1 1 0
225+
226+
I = imread('blood1.tif'); BW3
227+
= ~im2bw(I);
228+
229+
BW4
230+
= bwfill(BW3,'holes'); imshow(BW3)
231+
232+
figure, imshow(BW4)
233+
```
234+
235+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-06-43-2023-03-11-09-06-33-image.png)
236+
237+
相关命令:
238+
bwselect, roifill
239+
240+
## 8.bwlabel
241+
242+
功能:标注二进制图像中已连接的部分。
243+
244+
语法:
245+
246+
```matlab
247+
L = bwlabel(BW,n) [L,num] = bwlabel(BW,n) 举例
248+
BW = [1 1 1 0 0 0 0 0
249+
1 1 1 0 1 1 0 0
250+
1 1 1 0 1 1 0 0
251+
1 1 1 0 0 0 1 0
252+
1 1 1 0 0 0 1 0
253+
1 1 1 0 0 0 1 0
254+
1 1 1 0 0 1 1 0
255+
1 1 1 0 0 0 0 0]
256+
L = bwlabel(BW,4) L =
257+
1 1 1 0 0 0 0 0
258+
1 1 1 0 2 2 0 0
259+
1 1 1 0 2 2 0 0
260+
1 1 1 0 0 0 3 0
261+
1 1 1 0 0 0 3 0
262+
263+
1 1 1 0 0 0 3 0
264+
1 1 1 0 0 3 3 0
265+
1 1 1 0 0 0 0 0
266+
[r,c] = find(L==2); rc = [r c]
267+
rc = 2 5
268+
3 5
269+
2 6
270+
3 6
271+
```
272+
273+
相关命令:
274+
bweuler, bwselect
275+
276+
## 9.bwmorph
277+
278+
功能:提取二进制图像的轮廓。
279+
280+
语法:
281+
282+
```matlab
283+
BW2 = bwmorph(BW1,operation)
284+
BW2 = bwmorph(BW1,operation,n)
285+
```
286+
287+
举例
288+
289+
```matlab
290+
BW1 = imread('circles.tif');
291+
imshow(BW1);
292+
```
293+
294+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-08-59-1678496938.png)
295+
296+
```matlab
297+
BW2 = bwmorph(BW1,'remove');
298+
BW3 = bwmorph(BW1,'skel',Inf);
299+
imshow(BW2)
300+
figure, imshow(BW3)
301+
```
302+
303+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-09-26-1678496964.png)
304+
305+
相关命令:
306+
307+
bweuler, bwperim, dilate, erode
308+
309+
## 10.bwperim
310+
311+
功能:计算二进制图像中对象的周长。
312+
313+
语法:
314+
315+
```matlab
316+
BW2 = bwperim(BW1,n)
317+
```
318+
319+
举例
320+
321+
```matlab
322+
BW1 = imread('circbw.tif');
323+
324+
BW2 = bwperim(BW1,8);
325+
326+
imshow(BW1)
327+
328+
figure, imshow(BW2)
329+
```
330+
331+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-09-10-53-1678497051.png)
332+
333+
相关命令:
334+
335+
bwarea, bweuler, bwfill
336+
337+
参考文献:
338+
339+
[1] [Rafael C. Gonzalez, Richard E. Woods, and Steven L. Eddins. 2003. Digital Image Processing Using MATLAB. Prentice-Hall, Inc., USA.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_Using_Matlab.pdf)
340+
341+
[2] [阮秋琦. 数字图像处理(MATLAB版)[M]. 北京:电子工业出版社, 2014.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(MATLAB_version).pdf)
342+
343+
[3] [冈萨雷斯. 数字图像处理(第三版)[M]. 北京:电子工业出版社, 2011.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(Third_Edition).pdf)
344+
345+
[返回首页](https://github.com/timerring/digital-image-processing-matlab)

0 commit comments

Comments
 (0)