Matlab常用图像处理命令108例-matlab图像处理第28期(附完整代码)

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

26. edge

功能:识别强度图像中的边界。

语法

BW = edge(I, 'sobel')
BW = edge(I, 'sobel', thresh)
BW = edge(I, 'sobel', thresh, direction) 
[BW, thresh] = edge(I, 'sobel', ...)
BW = edge(I, 'prewitt')
BW = edge(I, 'roberts')
BW = edge(I, 'log')
BW = edge(I, 'zerocross', thresh, h) 
BW = edge(I, 'canny')
BW = edge(I, 'canny', thresh, sigma)

在这里插入图片描述

举例

I = imread('rice.tif');
BW1 = edge(I, 'prewitt');
BW2 = edge(I, 'canny');
imshow(BW1);
figure, imshow(BW2);

相关命令fspecial, conv2
在这里插入图片描述


27. erode

功能:弱化二值图像的边界(腐蚀操作)。

语法

BW2 = erode(BW1, SE)
BW2 = erode(BW1, SE, alg) 
BW2 = erode(BW1, SE, ..., n)

举例

BW1 = imread('text.tif');
SE = ones(3, 1);
BW2 = erode(BW1, SE);
imshow(BW1);
figure, imshow(BW2);

相关命令dilate, bwmorph
在这里插入图片描述


28. fft2

功能:进行二维快速傅里叶变换。

语法

B = fft2(A)
B = fft2(A, m, n)

举例

I = imread('saturn.tif');
B = fftshift(fft2(I));
imshow(log(abs(B)), []), colormap(jet(64)), colorbar;

相关命令fftshift, ifft2, dct2


29. fftn

功能:进行 N 维快速傅里叶变换。

语法

B = fftn(A)
B = fftn(A, siz)

相关命令fft2, ifftn


30. fftshift

功能:将傅里叶变换的 DC 组件移动到光谱中心。

语法

B = fftshift(A)

举例

B = fftn(A);
C = fftshift(B);

相关命令ifftshift, fft2


31. filter2

功能:进行二维线性过滤操作。

语法

B = filter2(h, A)
B = filter2(h, A, shape)

举例

A = magic(6);
h = fspecial('sobel');
B = filter2(h, A, 'valid');
disp(B);

相关命令conv2, fspecial


32. freqspace

功能:确定二维频率响应的频率空间。

语法

[f1, f2] = freqspace(n) 
[f1, f2] = freqspace([m n])
[x1, y1] = freqspace(..., 'meshgrid') 
f = freqspace(N)
f = freqspace(N, 'whole')

相关命令fsamp2, fwind1


33. freqz2

功能:计算二维频率响应。

语法

[H, f1, f2] = freqz2(h, n1, n2)
[H, f1, f2] = freqz2(h, [n2 n1])
[H, f1, f2] = freqz2(h, f1, f2)

举例

Hd = zeros(16, 16); 
Hd(5:12, 5:12) = 1;
Hd(7:10, 7:10) = 0;
h = fwind1(Hd, bartlett(16)); 
colormap(jet(64));
freqz2(h, [32 32]); 
axis([-1 1 -1 1 0 1]);

相关命令fsamp2, filter2
在这里插入图片描述


34. fsamp2

功能:用频率采样法设计二维 FIR 滤波器。

语法

h = fsamp2(Hd)
h = fsamp2(f1, f2, Hd, [m n])

举例

[f1, f2] = freqspace(21, 'meshgrid'); 
Hd = ones(21);
r = sqrt(f1.^2 + f2.^2); 
Hd((r < 0.1) | (r > 0.5)) = 0;
colormap(jet(64));
mesh(f1, f2, Hd);

相关命令ftrans2, conv2
在这里插入图片描述


35. fspecial

功能:创建预定义滤波器。

语法

h = fspecial(type)
h = fspecial(type, parameters)

举例

I = imread('saturn.tif');
h = fspecial('unsharp', 0.5);
I2 = filter2(h, I) / 255;
imshow(I);
figure, imshow(I2);

相关命令filter2, conv2


36. ftrans2

功能:通过频率转换设计二维 FIR 滤波器。

语法

h = ftrans2(b, t)
h = ftrans2(b)

举例

b = remez(10, [0 0.05 0.15 0.55 0.65 1], [0 0 1 1 0 0]);
[H, w] = freqz(b, 1, 128, 'whole'); 
plot(w / pi - 1, fftshift(abs(H)));

相关命令fsamp2, filter2


参考文献

  1. [Rafael C. Gonzalez, Richard E. Woods, and Steven L. Eddins. 2003. Digital Image Processing Using MATLAB. Prentice-Hall, Inc., USA.]
  2. [阮秋琦. 数字图像处理(MATLAB版). 北京:电子工业出版社, 2014.
  3. [冈萨雷斯. 数字图像处理(第三版). 北京:电子工业出版社, 2011.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值