Skip to content

Commit 53e28ba

Browse files
committed
Add commands 2
1 parent 6646c29 commit 53e28ba

File tree

1 file changed

+321
-0
lines changed

1 file changed

+321
-0
lines changed
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
# Matlab常用图像处理命令108例(二)
2+
3+
## 11.bwselect
4+
5+
功能:在二进制图像中选择对象。语法:
6+
7+
```matlab
8+
BW2 = bwselect(BW1,c,r,n)
9+
10+
BW2 = bwselect(BW1,n)
11+
12+
[BW2,idx] = bwselect(...)
13+
```
14+
15+
举例
16+
17+
```matlab
18+
BW1 = imread('text.tif');
19+
20+
c = [16 90 144];
21+
22+
r = [85 197 247];
23+
24+
BW2 = bwselect(BW1,c,r,4);
25+
26+
imshow(BW1)
27+
28+
figure, imshow(BW2)
29+
```
30+
31+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-21-47-14-1678542432.png)
32+
33+
相关命令:
34+
35+
bwfill, bwlabel, impixel, roipoly, roifill
36+
37+
## 12.cmpermute
38+
39+
功能:调整颜色映像表中的颜色。
40+
41+
语法:
42+
43+
```matlab
44+
[Y,newmap] = cmpermute(X,map)
45+
46+
[Y,newmap] = cmpermute(X,map,index)
47+
```
48+
49+
举例
50+
51+
```matlab
52+
To order a colormap by luminance, use:
53+
54+
ntsc = rgb2ntsc(map);
55+
56+
[dum,index] = sort(ntsc(:,1));
57+
58+
[Y,newmap] = cmpermute(X,map,index);
59+
```
60+
61+
相关命令: randperm
62+
63+
## 13.cmunique
64+
65+
功能:查找颜色映像表中特定的颜色及相应的图像。语法:
66+
67+
```matlab
68+
[Y,newmap] = cmunique(X,map)
69+
70+
[Y,newmap] = cmunique(RGB)
71+
72+
[Y,newmap] = cmunique(I)
73+
```
74+
75+
相关命令:
76+
gray2ind, rgb2ind
77+
78+
## 14.col2im
79+
80+
功能:将矩阵的列重新组织到块中。语法:
81+
82+
```matlab
83+
A = col2im(B,[m n],[mm nn],block_type)
84+
A = col2im(B,[m n],[mm nn])
85+
```
86+
87+
相关命令:
88+
blkproc, colfilt, im2col, nlfilter
89+
90+
## 15.colfilt
91+
92+
利用列相关函数进行边沿操作。语法:
93+
94+
```matlab
95+
B = colfilt(A,[m n],block_type,fun)
96+
B = colfilt(A,[m n],block_type,fun,P1,P2,...)
97+
B = colfilt(A,[m n],[mblock nblock],block_type,fun,...)
98+
B = colfilt(A,'indexed',...)
99+
```
100+
101+
相关命令:
102+
blkproc, col2im, im2col, nlfilter
103+
104+
## 16.colorbar
105+
106+
功能:显示颜色条。语法:
107+
108+
```matlab
109+
colorbar('vert')
110+
111+
colorbar('horiz')
112+
113+
colorbar(h)
114+
115+
colorbar
116+
h = colorbar(...)
117+
```
118+
119+
举例
120+
121+
```matlab
122+
I = imread('blood1.tif');
123+
124+
h = fspecial('log');
125+
I2 = filter2(h,I);
126+
imshow(I2,[]), colormap(jet(64)), colorbar
127+
```
128+
129+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-21-51-45-1678542704.png)
130+
131+
## 17.conv2
132+
133+
功能:进行二维卷积操作。语法:
134+
135+
```matlab
136+
C = conv2(A,B)
137+
C = conv2(hcol,hrow,A)
138+
C = conv2(...,shape)
139+
```
140+
141+
举例
142+
143+
```matlab
144+
A = magic(5)
145+
146+
A =
147+
17 24 1 8 15
148+
149+
23 5 7 14 16
150+
4 6 13 20 22
151+
10 12 19 21 3
152+
11 18 25 2 9
153+
B = [1 2 1;0 2 0;3 1 3]
154+
155+
B =
156+
1 2 1
157+
0 2 0
158+
3 1 3
159+
C = conv2(A,B)
160+
161+
C =
162+
17 58 66 34 32 38 15
163+
23 85 88 35 67 76 16
164+
55 149 117 163 159 135 67
165+
79 78 160 161 187 129 51
166+
23 82 153 199 205 108 75
167+
30 68 135 168 91 84 9
168+
33 65 126 85 104 15 27
169+
```
170+
171+
相关命令:
172+
filter2
173+
174+
## 18.convmtx2
175+
176+
功能:计算二维卷积矩阵。语法:
177+
178+
```matlab
179+
T = convmtx2(H,m,n)
180+
181+
T = convmtx2(H,[m n])
182+
```
183+
184+
相关命令:
185+
conv2
186+
187+
## 19.convn
188+
189+
功能:计算n 维卷积。
190+
191+
语法:
192+
193+
```matlab
194+
C = convn(A,B)
195+
C = convn(A,B,shape)
196+
```
197+
198+
相关命令: conv2
199+
200+
## 20.corr2
201+
202+
功能:计算两个矩阵的二维相关系数。
203+
204+
语法:
205+
206+
```matlab
207+
r = corr2(A,B)
208+
```
209+
210+
相关命令: std2
211+
212+
## 21.dct2
213+
214+
功能:进行二维离散余弦变换。语法:
215+
216+
```matlab
217+
B = dct2(A)
218+
B = dct2(A,m,n)
219+
B = dct2(A,[m n])
220+
```
221+
222+
举例
223+
224+
```matlab
225+
RGB = imread('autumn.tif');
226+
I = rgb2gray(RGB);
227+
J = dct2(I);
228+
imshow(log(abs(J)),[]), colormap(jet(64)), colorbar
229+
```
230+
231+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-21-54-41-1678542880.png)
232+
233+
```matlab
234+
J(abs(J) < 10) = 0;
235+
K = idct2(J)/255;
236+
imshow(K)
237+
```
238+
239+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-21-55-13-1678542912.png)
240+
241+
相关命令:
242+
fft2, idct2, ifft2
243+
244+
## 22.dctmtx
245+
246+
功能:计算离散余弦变换矩阵。
247+
语法:
248+
249+
```matlab
250+
D = dctmtx(n)
251+
```
252+
253+
相关命令: dct2
254+
255+
## 23.dilate
256+
257+
功能:放大二进制图像。语法:
258+
259+
```matlab
260+
BW2 = dilate(BW1,SE)
261+
BW2 = dilate(BW1,SE,alg) BW2 = dilate(BW1,SE,...,n)
262+
```
263+
264+
举例
265+
266+
```matlab
267+
BW1 = imread('text.tif');
268+
SE = ones(6,2);
269+
BW2 = dilate(BW1,SE);
270+
imshow(BW1)
271+
figure, imshow(BW2)
272+
```
273+
274+
![](https://raw.githubusercontent.com/timerring/scratchpad2023/main/2023/03/11-21-56-56-1678543010.png)
275+
276+
相关命令:
277+
bwmorph, erode
278+
279+
## 24.dither
280+
281+
功能:通过抖动增加外观颜色分辨率,转换图像。
282+
语法:
283+
284+
```matlab
285+
X = dither(RGB,map)
286+
BW = dither(I)
287+
```
288+
289+
相关命令:
290+
rgb2ind
291+
292+
## 25.double
293+
294+
功能:转换数据为双精度型。
295+
语法:
296+
297+
```matlab
298+
B = double(A)
299+
```
300+
301+
举例
302+
303+
```matlab
304+
A = imread('saturn.tif');
305+
B = sqrt(double(A));
306+
```
307+
308+
相关命令:
309+
im2double, im2uint, uint8
310+
311+
参考文献:
312+
313+
[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)
314+
315+
[2] [阮秋琦. 数字图像处理(MATLAB版)[M]. 北京:电子工业出版社, 2014.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(MATLAB_version).pdf)
316+
317+
[3] [冈萨雷斯. 数字图像处理(第三版)[M]. 北京:电子工业出版社, 2011.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(Third_Edition).pdf)
318+
319+
320+
321+
[返回首页](https://github.com/timerring/digital-image-processing-matlab)

0 commit comments

Comments
 (0)