matlab grayslice,MATLAB图像处理函数汇总大全(2)

语法:

X = dither(RGB,map)

BW = dither(I)

相关命令:

rgb2ind

25.double

附录 MATLAB图像处理命令 331

功能:转换数据为双精度型.

语法:

B = double(A)

举例

A = imread('saturn.tif');

B = sqrt(double(A));

相关命令:

im2double, im2uint, uint8

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,'prewitt',thresh)

BW = edge(I,'prewitt',thresh,direction)

[BW,thresh] = edge(I,'prewitt',...)

BW = edge(I,'roberts')

BW = edge(I,'roberts',thresh)

[BW,thresh] = edge(I,'roberts',...)

BW = edge(I,'log')

BW = edge(I,'log',thresh)

BW = edge(I,'log',thresh,sigma)

[BW,threshold] = edge(I,'log',...)

BW = edge(I,'zerocross',thresh,h)

[BW,thresh] = edge(I,'zerocross',...)

BW = edge(I,'canny')

BW = edge(I,'canny',thresh)

BW = edge(I,'canny',thresh,sigma)

MATLAB高级应用——图形及影像处理 332

[BW,threshold] = edge(I,'canny',...)

举例

I = imread('rice.tif');

BW1 = edge(I,'prewitt');

BW2 = edge(I,'canny');

imshow(BW1);

figure, imshow(BW2)

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)

相关命令:

bwmorph, dilate

附录 MATLAB图像处理命令 333

28.fft2

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

语法:

B = fft2(A)

B = fft2(A,m,n)

举例

load imdemos saturn2

imshow(saturn2)

B = fftshift(fft2(saturn2));

imshow(log(abs(B)),[]), colormap(jet(64)), colorbar

相关命令:

dct2, fftshift, idct2, ifft2

29.fftn

功能: 进行n维快速傅里叶变换.

语法:

B = fftn(A)

B = fftn(A,siz)

相关命令:

fft2, ifftn

30.fftshift

MATLAB高级应用——图形及影像处理 334

功能:把快速傅里叶变换的DC组件移到光谱中心.

语法:

B = fftshift(A)

举例

B = fftn(A);

C = fftshift(B);

相关命令:

fft2, fftn, ifftshift

31.filter2

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

语法:

B = filter2(h,A)

B = filter2(h,A,shape)

举例

A = magic(6)

A =

35 1 6 26 19 24

3 32 7 21 23 25

31 9 2 22 27 20

8 28 33 17 10 15

30 5 34 12 14 16

4 36 29 13 18 11

h = fspecial('sobel')

h =

1 2 1

0 0 0

-1 -2 -1

B = filter2(h,A,'valid')

B =

-8 4 4 -8

-23 -44 -5 40

-23 -50 1 40

-8 4 4 -8

相关命令:

conv2, roifilt2

32.freqspace

附录 MATLAB图像处理命令 335

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

语法:

[f1,f2] = freqspace(n)

[f1,f2] = freqspace([m n])

[x1,y1] = freqspace(...,'meshgrid')

f = freqspace(N)

f = freqspace(N,'whole')

相关命令:

fsamp2, fwind1, fwind2

33.freqz2

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

语法:

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

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

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

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

[...] = freqz2(h,...,[dx dy])

[...] = freqz2(h,...,dx)

freqz2(...)

举例

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])

34.fsamp2

MATLAB高级应用——图形及影像处理 336

功能:用频率采样法设计二维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((r0.5)) = 0;

colormap(jet(64))

mesh(f1,f2,Hd)

相关命令:

conv2, filter2, freqspace, ftrans2, fwind1, fwind2

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)

相关命令:

conv2, edge, filter2, fsamp2, fwind1, fwind2

36.ftrans2

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

语法:

附录 MATLAB图像处理命令 337

h = ftrans2(b,t)

h = ftrans2(b)

举例

colormap(jet(64))

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)))

相关命令:

conv2, filter2, fsamp2, fwind1, fwind2

37.fwind1

功能:用一维窗口方法设计二维FIR过滤器.

语法:

h = fwind1(Hd,win)

h = fwind1(Hd,win1,win2)

h = fwind1(f1,f2,Hd,...)

举例

[f1,f2] = freqspace(21,'meshgrid');

Hd = ones(21);

r = sqrt(f1.^2 + f2.^2);

Hd((r0.5)) = 0;

colormap(jet(64))

mesh(f1,f2,Hd)

相关命令:

conv2, filter2, fsamp2, freqspace, ftrans2, fwind2

38.fwind2

功能:用二维窗口方法设计二维FIR过滤器.

语法:

h = fwind2(Hd,win)

h = fwind2(f1,f2,Hd,win)

举例

[f1,f2] = freqspace(21,'meshgrid');

Hd = ones(21);

r = sqrt(f1.^2 + f2.^2);

Hd((r0.5)) = 0;

colormap(jet(64))

mesh(f1,f2,Hd)

MATLAB高级应用——图形及影像处理 338

相关命令:

conv2, filter2, fsamp2, freqspace, ftrans2, fwind1

39.getimage

功能:从坐标轴取得图像数据.

语法:

A = getimage(h)

[x,y,A] = getimage(h)

[...,A,flag] = getimage(h)

[...] = getimage

举例

imshow rice.tif

I = getimage;

40.gray2ind

功能:转换灰度图像为索引图像.

语法:

[X,map] = gray2ind(I,n)

相关命令:

ind2gray

41.grayslice

功能:从灰度图像创建索引图像.

语法:

X = grayslice(I,n)

X = grayslice(I,v)

举例

I = imread('ngc4024m.tif');

X = grayslice(I,16);

imshow(I)

figure, imshow(X,jet(16))

附录 MATLAB图像处理命令 339

相关命令:

gray2ind

42.histeq

功能:用柱状图均等化增强对比.

语法:

J = histeq(I,hgram)

J = histeq(I,n)

[J,T] = histeq(I,...)

举例

I = imread('tire.tif');

J = histeq(I);

imshow(I)

figure, imshow(J)

imhist(I,64)

figure; imhist(J,64)

相关命令:

brighten, imadjust, imhist

43.hsv2rgb

功能: 转换HSV值为RGB颜色空间.

语法:

rgbmap = hsv2rgb(hsvmap)

RGB = hsv2rgb(HSV)

相关命令:

MATLAB高级应用——图形及影像处理 340

rgb2hsv, rgbplot

44.idct2

功能:计算二维离散反余弦变换.

语法:

B = idct2(A)

B = idct2(A,m,n)

B = idct2(A,[m n])

相关命令:

dct2, dctmtx, fft2, ifft2

45.ifft2

功能:计算二维快速傅里叶反变换.

语法:

B = ifft2(A)

B = ifft2(A,m,n)

相关命令:

fft2, fftshift, idct2

46.ifftn

功能: 计算n维快速傅里叶反变换.

语法:

B = ifftn(A)

B = ifftn(A,siz)

相关命令:

fft2, fftn, ifft2

47.sim2bw

功能:转换图像为二进制图像.

语法:

BW = im2bw(I,level)

BW = im2bw(X,map,level)

BW = im2bw(RGB,level)

举例

load trees

BW = im2bw(X,map,0.4);

imshow(X,map)

附录 MATLAB图像处理命令 341

figure, imshow(BW)

相关命令:

ind2gray, rgb2gray

48.im2col

功能:重调图像块为列.

语法:

B = im2col(A,[m n],block_type)

B = im2col(A,[m n])

B = im2col(A,'indexed',...)

相关命令:

blkproc, col2im, colfilt, nlfilter

49.im2double

功能:转换图像矩阵为双精度型.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值