当前位置:首页 >> 信息与通信 >>

MATLAB图像处理基础


MATLAB
MATLAB MATLAB MATLAB

1.1 MATLAB
MATLAB 1 2 PCX windows paintbrush BMP Windows Bitmap 16 256 1 4 8 16 24

Microsoft Windows BMP

3 4 5

HDF Hierarchical Data Format JPEG Joint Photographic Experts Group TIF Tag Image File Format

8

24

TIF

6 7

XWD X Windows Dump PNG Portable Network Graphics

1.2 MATLAB
1 A=imread 1 MATLAB
MATLAB



.



>> clear;% >> close all;%

>> I=imread('pout.tif');% >> imshow(I);% 1.1

1.1 2 whos 2 whos MATLAB Name Size whos I

pout.tif

Bytes Class

I

291x240

69840 uint8 array

Grand total is 69840 elements using 69840 bytes 3

imwrite (A,’ 3 pout.tif

.

) pout1.png

imwrite(I,’pout1.png’); I1=imread(‘pout1.png’); imshow(I1); 4 imfinfo(‘ 4 imfinfo ’pout1.png’ . ’) pout1.png imfinfo

ans =

Filename: 'pout1.png' FileModDate: '04-Jun-2004 20:57:04' FileSize: 31559 Format: 'png' FormatVersion: [] Width: 240 Height: 291 BitDepth: 8 ColorType: 'grayscale' FormatSignature: [137 80 78 71 13 10 26 10] ……

1.3 MATLAB

MATLAB 1 unit8 unit16 I

0

1

255

65535 MATLAB

1

imagesc

colormap

1.2

>> I=imread('moon.tif');% >> imagesc(I,[0,256]);% >> colormap(gray);%

1.2 2

1.3

2

im2bw

1.3

>> I=imread('moon.tif');% >> J1=im2bw(I);% >> imshow(J1);%

1.4

I=ind2gray(X,map)

map

I

I

4

ind2rgb RGB map X ind2rgb (X map)

5

mat2gray I mat2gray(A,[amin [amin amax] A I amax])

6

graslice X graslice (I n) X graslice (I v ) X graslice (I n) I n X

X graslice (I v ) X 8 rgb2gray

v(

0

1

)

1

I rgb2gray (RGB) 9 rgb2ind [X,map]=rgb2ind(RGB)

1.5
image image imagesc 1.3 4 imagesc

imshow

image

imagesc

imshow X imshow (I) imshow BW

map

imshow RGB imshow filename

RGB

imshow I [low high]

colorbar: getimage: immovie montage movie subimage truesize warp zoom 1

>> I=imread('saturn.tif'); >> h=[1 2 1;0 0 0;-1 -2 -1];% >> J=filter2(h,I);% >> imshow(J,[]); >> colorbar; 1.8

1.8 2 >> load mri >> montage(D,map); 1.9

1.9

1.6
1.6.1

imabsdiff imadd imsubtract immultiply imdivide: imcomplement imlincomb 1 >> clear >> close all >> I=imread('rice.tif'); >> subplot(1,3,1);

>> imshow(I); >> J=imread('cameraman.tif'); >> subplot(1,3,2); >> imshow(J); >> K=imadd(I,J); >> subplot(1,3,3); >> imshow(K); 1.10

1.10

1.6.2
1

imresize imrotate 1 2 2*2 improfile

3

4*4

2 imresize 1 m ’nearest neighber’( B=imresize(A,m,method) A B method ’bicubic’ Method

) ’bilinear’

2

B=imresize(A,[mrows mcols],method)

mrows 3 imrotate 1 B 2 B B=imrotate(A,angle,method) A angle

mcols

B

A

B=imrotate(A,angle,method,’crop’) A angle A 'crop'

4 imcrop 1 2 3 I I2=imcrop(I) X2=imcrop(X,map,rect) RGB2=imcrop(RGB,rect) X RGB [xmin ymin width height] RGB rect

1.7

MATLAB 1 blkproc

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

bestblk([m n],k) 3 col2im

B=col2im(A,[m n],[mm nn],block_type) A block_type distinct A m n block_type sliding

mm nn 4 im2col

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

MATLAB
lookup
A = applylut(BW,lut)

lut = makelut('sum(x(:)) == 4',2); BW1 = imread('text.tif'); BW2 = applylut(BW1,lut); imshow(BW1) figure, imshow(BW2)

makelut

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

siz = bestblk([640 800],72) siz = 64 50

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,[]);

colfilt, nlfilter,inline

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

imadjust, rgbplot

total = bwarea(BW)

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

bwarea(BW) ans =

15799

bweuler, bwperim

eul = bweuler(BW,n)

BW = imread('circles.tif'); imshow(BW); bweuler(BW) ans = –2

bwmorph, bwperim

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 11111000 10001010 10001110 11110111 10011010 10001010 1 0 0 0 1 1 1 0] BW2 = bwfill(BW1,3,3,8)

BW2 = 10000000 11111000 11111010 11111110 11110111

10011010 10001010 10001110 I = imread('blood1.tif'); BW3 = ~im2bw(I); BW4 = bwfill(BW3,'holes'); imshow(BW3) figure, imshow(BW4)

bwselect, roifill

L = bwlabel(BW,n) [L,num] = bwlabel(BW,n)

BW = [1 1 1 0 0 0 0 0 11101100 11101100 11100010 11100010 11100010 11100110 1 1 1 0 0 0 0 0] L = bwlabel(BW,4) L= 11100000 11102200 11102200 11100030 11100030 11100030 11100330 11100000 [r,c] = find(L==2);

rc = [r c] rc = 2 3 2 3 5 5 6 6

bweuler, bwselect

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

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

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

bweuler, bwperim, dilate, erode

BW2 = bwperim(BW1,n)

BW1 = imread('circbw.tif'); BW2 = bwperim(BW1,8); imshow(BW1) figure, imshow(BW2)

bwarea, bweuler, bwfill

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

BW1 = imread('text.tif'); c = [16 90 144]; r = [85 197 247]; BW2 = bwselect(BW1,c,r,4); imshow(BW1) figure, imshow(BW2)

bwfill, bwlabel, impixel, roipoly, roifill

[Y,newmap] = cmpermute(X,map) [Y,newmap] = cmpermute(X,map,index)

To order a colormap by luminance, use:
ntsc = rgb2ntsc(map); [dum,index] = sort(ntsc(:,1)); [Y,newmap] = cmpermute(X,map,index);

randperm

[Y,newmap] = cmunique(X,map) [Y,newmap] = cmunique(RGB) [Y,newmap] = cmunique(I)

gray2ind, rgb2ind

A = col2im(B,[m n],[mm nn],block_type)
A = col2im(B,[m n],[mm nn])

blkproc, colfilt, im2col, nlfilter

B = colfilt(A,[m n],block_type,fun) B = colfilt(A,[m n],block_type,fun,P1,P2,...) B = colfilt(A,[m n],[mblock nblock],block_type,fun,...) B = colfilt(A,'indexed',...)

blkproc, col2im, im2col, nlfilter

colorbar('vert') colorbar('horiz') colorbar(h) colorbar h = colorbar(...)

I = imread('blood1.tif'); h = fspecial('log'); I2 = filter2(h,I); imshow(I2,[]), colormap(jet(64)), colorbar

C = conv2(A,B) C = conv2(hcol,hrow,A) C = conv2(...,shape)

A = magic(5) A= 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 B = [1 2 1;0 2 0;3 1 3] B= 121 020 313 C = conv2(A,B) C=

17 58 66 34 32 38 15 23 85 88 35 67 76 16 55 149 117 163 159 135 67 79 78 160 161 187 129 51 23 82 153 199 205 108 75 30 68 135 168 91 84 9 33 65 126 85 104 15 27

filter2

T = convmtx2(H,m,n) T = convmtx2(H,[m n])

conv2

n
C = convn(A,B) C = convn(A,B,shape)

conv2

r = corr2(A,B)

std2

B = dct2(A) B = dct2(A,m,n) B = dct2(A,[m n])

RGB = imread('autumn.tif'); I = rgb2gray(RGB); J = dct2(I);

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

J(abs(J) < 10) = 0; K = idct2(J)/255; imshow(K)

fft2, idct2, ifft2

D = dctmtx(n)

dct2

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

BW1 = imread('text.tif'); SE = ones(6,2); BW2 = dilate(BW1,SE); imshow(BW1) figure, imshow(BW2)

bwmorph, erode

X = dither(RGB,map) BW = dither(I)

rgb2ind

B = double(A)

A = imread('saturn.tif'); B = sqrt(double(A));

im2double, im2uint, uint8

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) [BW,threshold] = edge(I,'canny',...)

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

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

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

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

fft2, ifftn

DC
B = fftshift(A)

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

fft2, fftn, ifftshift

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= 121 000 –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

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

fsamp2, fwind1, fwind2

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

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)

conv2, filter2, freqspace, ftrans2, fwind1, fwind2

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

FIR
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

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((r<0.1)|(r>0.5)) = 0; colormap(jet(64)) mesh(f1,f2,Hd)

conv2, filter2, fsamp2, freqspace, ftrans2, 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((r<0.1)|(r>0.5)) = 0; colormap(jet(64)) mesh(f1,f2,Hd)

conv2, filter2, fsamp2, freqspace, ftrans2, fwind1

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

imshow rice.tif I = getimage;

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

ind2gray

X = grayslice(I,n) X = grayslice(I,v)

I = imread('ngc4024m.tif'); X = grayslice(I,16); imshow(I) figure, imshow(X,jet(16))

gray2ind

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

HSV

RGB

rgbmap = hsv2rgb(hsvmap) RGB = hsv2rgb(HSV)

rgb2hsv, rgbplot

B = idct2(A) B = idct2(A,m,n) B = idct2(A,[m n])

dct2, dctmtx, fft2, ifft2

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

fft2, fftshift, idct2

n
B = ifftn(A) B = ifftn(A,siz)

fft2, fftn, ifft2

BW = im2bw(I,level) BW = im2bw(X,map,level) BW = im2bw(RGB,level)

load trees BW = im2bw(X,map,0.4); imshow(X,map) figure, imshow(BW)

ind2gray, rgb2gray

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

blkproc, col2im, colfilt, nlfilter

I2 = im2double(I1) RGB2 = im2double(RGB1) BW2 = im2double(BW1) X2 = im2double(X1,'indexed')

double, im2uint8, uint8

8

I2 = im2uint8(I1) RGB2 = im2uint8(RGB1) BW2 = im2uint8(BW1) X2 = im2uint8(X1,'indexed')

im2uint16, double, im2double, uint8, imapprox, uint16

16
I2 = im2uint16(I1) RGB2 = im2uint16(RGB1) X2 = im2uint16(X1,'indexed')

im2uint8, double, im2double, uint8, uint16, imapprox

J = imadjust(I,[low high],[bottom top],gamma) newmap = imadjust(map,[low high],[bottom top],gamma) RGB2 = imadjust(RGB1,...)

I = imread('pout.tif'); J = imadjust(I,[0.3 0.7],[]); imshow(I) figure, imshow(J)

brighten, histeq

[Y,newmap] = imapprox(X,map,n) [Y,newmap] = imapprox(X,map,tol) Y = imapprox(X,map,newmap)

[...] = imapprox(...,dither_option)

cmunique, dither, rgb2ind

imcontour(I,n) imcontour(I,v) imcontour(x,y,...) imcontour(...,LineSpec) [C,h] = imcontour(...)

I = imread('ic.tif'); imcontour(I,3)

clabel, contour, LineSpec

I2 = imcrop(I) X2 = imcrop(X,map) RGB2 = imcrop(RGB)

I2 = imcrop(I,rect) X2 = imcrop(X,map,rect) RGB2 = imcrop(RGB,rect)

[...] = imcrop(x,y,...) [A,rect] = imcrop(...) [x,y,A,rect] = imcrop(...)

I = imread('ic.tif'); I2 = imcrop(I,[60 40 100 90]); imshow(I)

figure, imshow(I2)

zoom

stats = imfeature(L,measurements) stats = imfeature(L,measurements,n)

BW = imread('text.tif'); L = bwlabel(BW); stats = imfeature(L,'all'); stats(23) ans = Area: 89 Centroid: [95.6742 192.9775] BoundingBox: [87.5000 184.5000 16 15] MajorAxisLength: 19.9127 MinorAxisLength: 14.2953 Eccentricity: 0.6961 Orientation: 9.0845 ConvexHull: [28x2 double] ConvexImage: [15x16 uint8 ] ConvexArea: 205 Image: [15x16 uint8 ] FilledImage: [15x16 uint8 ] FilledArea: 122 EulerNumber: 0 Extrema: [ 8x2 double] EquivDiameter: 10.6451 Solidity: 0.4341 Extent: 0.3708 PixelList: [89x2 double]

bwlabel

info = imfinfo(filename,fmt) info = imfinfo(filename)

info = imfinfo('canoe.tif')

info = Filename:'canoe.tif' FileModDate: '25-Oct-1996 22:10:39' FileSize: 69708 Format: 'tif' FormatVersion: [] Width: 346 Height: 207 BitDepth: 8 ColorType: 'indexed' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubfileType: 0 BitsPerSample: 8 Compression: 'PackBits' PhotometricInterpretation: 'RGB Palette' StripOffsets: [ 9x1 double] SamplesPerPixel: 1 RowsPerStrip: 23 StripByteCounts: [ 9x1 double] XResolution: 72 YResolution: 72 ResolutionUnit: 'Inch' Colormap: [256x3 double] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: 255 MinSampleValue: 0 Thresholding: 1

imread, imwrite

imhist(I,n) imhist(X,map) [counts,x] = imhist(...)

I = imread('pout.tif'); imhist(I)

histeq

mov = immovie(X,map)

load mri mov = immovie(D,map);

montage

J = imnoise(I,type) J = imnoise(I,type,parameters)

I = imread('eight.tif'); J = imnoise(I,'salt & pepper',0.02); imshow(I) figure, imshow(J)

rand

P = impixel(I) P = impixel(X,map) P = impixel(RGB) P = impixel(I,c,r) P = impixel(X,map,c,r) P = impixel(RGB,c,r) [c,r,P] = impixel(...) P = impixel(x,y,I,xi,yi) P = impixel(x,y,X,map,xi,yi) P = impixel(x,y,RGB,xi,yi) [xi,yi,P] = impixel(x,y,...)

RGB = imread('flowers.tif'); c = [12 146 410]; r = [104 156 129]; pixels = impixel(RGB,c,r)

pixels = 61 59 101 253 240 0 237 37 44

improfile, pixval

c = improfile c = improfile(n)

c = improfile(I,xi,yi)

c = improfile(I,xi,yi,n)

[cx,cy,c] = improfile(...) [cx,cy,c,xi,yi] = improfile(...)

[...] = improfile(x,y,I,xi,yi) [...] = improfile(x,y,I,xi,yi,n)

[...] = improfile(...,method)

I = imread('alumgrns.tif'); x = [35 338 346 103]; y = [253 250 17 148]; improfile(I,x,y), grid on

impixel, pixval

A = imread(filename,fmt) [X,map] = imread(filename,fmt) [...] = imread(filename) [...] = imread(...,idx) (TIFF only) [...] = imread(...,ref) (HDF only) [...] = imread(...,’BackgroundColor’,BG) (PNG only) [A,map,alpha] = imread(...) (PNG only) [X,map] = imread('flowers.tif',6);

info = imfinfo('skull.hdf'); [X,map] = imread('skull.hdf',info(4).Reference);

bg = [255 0 0]; A = imread('image.png','BackgroundColor',bg);

[A,map,alpha] = imread('image.png');

imfinfo, imwrite,fread,double,uint8,uint16

B = imresize(A,m,method) B = imresize(A,[mrows ncols],method)

B = imresize(...,method,n) B = imresize(...,method,h)

B = imrotate(A,angle,method) B = imrotate(A,angle,method,'crop')

I = imread('ic.tif'); J = imrotate(I,–4,'bilinear','crop'); imshow(I) figure, imshow(J)

imcrop, imresize

imshow(I,n) imshow(I,[low high]) imshow(BW) imshow(X,map) imshow(RGB)

imshow(...,display_option)

imshow(x,y,A,...) imshow filename h = imshow(...)

getimage, imread, iptgetpref, iptsetpref, subimage, truesize, warp

imwrite(A,filename,fmt) imwrite(X,map,filename,fmt) imwrite(...,filename) imwrite(...,Param1,Val1,Param2,Val2...)

imwrite(X,map,'flowers.hdf','Compression','none',... 'WriteMode','append')

imfinfo, imread

I = ind2gray(X,map)

load trees I = ind2gray(X,map); imshow(X,map) figure,imshow(I)

gray2ind, imshow, rgb2ntsc

RGB
RGB = ind2rgb(X,map)

ind2gray, rgb2ind

value = iptgetpref(prefname)

value = iptgetpref('ImshowAxesVisible') value = off

imshow, iptsetpref

iptsetpref(prefname,value)

iptsetpref('ImshowBorder','tight')

imshow, iptgetpref, truesize

Radon
I = iradon(P,theta) I = iradon(P,theta,interp,filter,d,n) [I,h] = iradon(...)

P = phantom(128); R = radon(P,0:179); I = iradon(R,0:179,'nearest','Hann'); imshow(P) figure, imshow(I)

radon, phantom

flag = isbw(A)

isind, isgray, isrgb

flag = isgray(A)

isbw, isind, isrgb

flag = isind(A)

isbw, isgray, isrgb

RGB
flag = isrgb(A)

isbw, isgray, isind

lut = makelut(fun,n) lut = makelut(fun,n,P1,P2,...)

f = inline('sum(x(:)) >= 2'); lut = makelut(f,2)

lut = 0

0 0 1 0 1 1 1 0 1 1 1 1 1 1 1

applylut

I = mat2gray(A,[amin amax]) I = mat2gray(A)

I = imread('rice.tif'); J = filter2(fspecial('sobel'),I); K = mat2gray(J); imshow(I) figure, imshow(K)

gray2ind

b = mean2(A)

std2, mean, std

B = medfilt2(A,[m n]) B = medfilt2(A) B = medfilt2(A,'indexed',...)

I = imread('eight.tif'); J = imnoise(I,'salt & pepper',0.02); K = medfilt2(J); imshow(J) figure, imshow(K)

filter2, ordfilt2, wiener2

montage(I) montage(BW) montage(X,map) montage(RGB) h = montage(...)

load mri montage(D,map)

immovie

B = nlfilter(A,[m n],fun) B = nlfilter(A,[m n],fun,P1,P2,...) B = nlfilter(A,'indexed',...)

B = nlfilter(A,[3 3],'median(x(:))');

blkproc, colfilt

NTSC

RGB

rgbmap = ntsc2rgb(yiqmap) RGB = ntsc2rgb(YIQ)

rgb2ntsc, rgb2ind, ind2rgb, ind2gray

B = ordfilt2(A,order,domain) B = ordfilt2(A,order,domain,S) B = ordfilt2(...,padopt)

medfilt2

P = phantom(def,n) P = phantom(E,n) [P,E] = phantom(...)

P = phantom('Modified Shepp-Logan',200); imshow(P)

radon, iradon

pixval on pixval off pixval pixval(fig,option)

impixel, improfile

S = qtdecomp(I) S = qtdecomp(I,threshold) S = qtdecomp(I,threshold,mindim) S = qtdecomp(I,threshold,[mindim maxdim])

S = qtdecomp(I,fun) S = qtdecomp(I,fun,P1,P2,...)

I=

[1 1 1 1 2 3 6 6 11214568 1 1 1 1 10 15 7 7 1 1 1 1 20 25 7 7

20 22 20 22 1 2 3 4 20 22 22 20 5 6 7 8 20 22 20 20 9 10 11 12 22 22 20 20 13 14 15 16];

S = qtdecomp(I,5);

full(S)

ans = 40002020 00000000 00001120 00001100 40002020 00000000 00002020 00000000

qtgetblk, qtsetblk

[vals,r,c] = qtgetblk(I,S,dim) [vals,idx] = qtgetblk(I,S,dim)

[vals,r,c] = qtgetblk(I,S,4)

vals(:,:,1) = 1111 1121 1111 1111

vals(:,:,2) = 20 22 20 22 20 22 22 20 20 22 20 20 22 22 20 20

r= 1 5

c= 1 1

qtdecomp, qtsetblk

J = qtsetblk(I,S,dim,vals)

newvals = cat(3,zeros(4),ones(4)); J = qtsetblk(I,S,4,newvals)

J= 00002366 00004568 0 0 0 0 10 15 7 7 0 0 0 0 20 25 7 7 11111234 11115678 1 1 1 1 9 10 11 12 1 1 1 1 13 14 15 16

qtdecomp, qtgetblk

Radon
R = radon(I,theta) R = radon(I,theta,n) [R,xp] = radon(...)

iptsetpref('ImshowAxesVisible','on') I = zeros(100,100); I(25:75,25:75) = 1; theta = 0:180; [R,xp] = radon(I,theta); imshow(theta,xp,R,[]), colormap(hot), colorbar

iradon, phantom

RGB
I = rgb2gray(RGB) newmap = rgb2gray(map)

ind2gray, ntsc2rgb, rgb2ind, rgb2ntsc

RGB

HSV

hsvmap = rgb2hsv(rgbmap) HSV = rgb2hsv(RGB)

hsv2rgb, rgbplot

RGB
[X,map] = rgb2ind(RGB,tol) [X,map] = rgb2ind(RGB,n) X = rgb2ind(RGB,map) [...] = rgb2ind(...,dither_option)

RGB = imread('flowers.tif'); [X,map] = rgb2ind(RGB,128); imshow(X,map)

cmunique, dither, imapprox, ind2rgb, rgb2gray

RGB

NTSC

yiqmap = rgb2ntsc(rgbmap) YIQ = rgb2ntsc(RGB)

ntsc2rgb, rgb2ind, ind2rgb, ind2gray

RGB

YcbCr

ycbcrmap = rgb2ycbcr(rgbmap) YCBCR = rgb2ycbcr(RGB)

ntsc2rgb, rgb2ntsc, ycbcr2rgb

rgbplot(map)

rgbplot(jet)

colormap

BW = roicolor(A,low,high) BW = roicolor(A,v)

I = imread('rice.tif'); BW = roicolor(I,128,255); imshow(I); figure, imshow(BW)

roifilt2, roipoly

J = roifill(I,c,r) J = roifill(I)

J = roifill(I,BW) [J,BW] = roifill(...)

J = roifill(x,y,I,xi,yi) [x,y,J,BW,xi,yi] = roifill(...)

I = imread('eight.tif'); c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75]; J = roifill(I,c,r); imshow(I) figure, imshow(J)

roifilt2, roipoly

J = roifilt2(h,I,BW) J = roifilt2(I,BW,fun) J = roifilt2(I,BW,fun,P1,P2,...)

h = fspecial('unsharp'); J = roifilt2(h,I,BW); imshow(J)

filter2, roipoly

BW = roipoly(I,c,r) BW = roipoly(I) BW = roipoly(x,y,I,xi,yi) [BW,xi,yi] = roipoly(...) [x,y,BW,xi,yi] = roipoly(...)

I = imread('eight.tif'); c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75];

BW = roipoly(I,c,r); imshow(I) figure, imshow(BW)

roifilt2, roicolor, roifill

b = std2(A)

corr2, mean2

subimage(X,map) subimage(I) subimage(BW) subimage(RGB) subimage(x,y,...) h = subimage(...)

load trees [X2,map2] = imread('forest.tif'); subplot(1,2,1), subimage(X,map) subplot(1,2,2), subimage(X2,map2)

truesize(fig,[mrows mcols]) truesize(fig)

imshow, iptsetpref, iptgetpref

8
B = uint8(A)

a = [1 3 5]; b = uint8(a); whos Name a Size 1x3 b Bytes Class 24 1x3 doublearray 3 uint8 array

double, im2double, im2uint8

16
I = uint16(X)

a = [1 3 5]; b = uint16(a); whos Name a b Size 1x3 1x3 Bytes 24 6 Class double array uint16 array

double, datatypes, uint8, uint32, int8, int16, int32.

warp(X,map) warp(I,n) warp(BW) warp(RGB) warp(z,...) warp(x,y,z,...) h = warp(...)

[x,y,z] = cylinder; I = imread('testpat1.tif'); warp(x,y,z,I);

imshow

J = wiener2(I,[m n],noise) [J,noise] = wiener2(I,[m n])

I = imread('saturn.tif'); J = imnoise(I,'gaussian',0,0.005); K = wiener2(J,[5 5]); imshow(J) figure, imshow(K)

filter2, medfilt2

YcbCr

RGB

rgbmap = ycbcr2rgb(ycbcrmap) RGB = ycbcr2rgb(YCBCR)

ntsc2rgb, rgb2ntsc, rgb2ycbcr

zoom on zoom off zoom out zoom reset zoom zoom xon zoom yon zoom(factor) zoom(fig,option)

imcrop

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

. . : ,1999 . MATLAB . : ,2003 . MATLAB6.X . : , 2002 . MATLAB . : , 2004 . MATLAB6.5 . : , 2003 Kenneth R Castle,Digital Image Processing,Prentice Hall,1995 Pratt W K.Digital Image Processing,John Wiley&Sons,Inc. RosenfeId A Digital Picture Processing second edition 1982 Gonasales B C and winty P Digital Image Processing 1977 Andrews H C and Hunt B R Digita Image Restoration Prentice Hall 1977 Hall E L Compute Image Praocessing and Recognition Academic Press 1979 GoUB and RaderC M 1980 1990 6 1999 3 1992 1 1995 6 [ ]R.C. ,P. ,1981 4 1995 10 2000 2


相关文章:
实验1 数字图像处理的MATLAB基础
试验一 数字图像处理MATLAB 基础一. 试验目的 通过试验使学生掌握使用 MATLAB 进行数字图像处理基本语句。 二. 试验内容 (一) 复习 MATLAB 基本命令、基本...
Matlab图像处理入门到精通源代码
Matlab图像处理入门到精通源代码_IT/计算机_专业资料。包括全面的matlab图像处理知识Matlab7.x 图像处理 ch2_1_1:查看直方图(§2.1.3) I=imread('LENA256.bmp...
matlab图像处理基础实例
matlab图像处理基础实例 - 边缘检测时先要把其他格式图像转化为灰度图像 >> f=imread('lbxx.bmp'); >> a=rgb2gray(f); >> [g,t]=edge(a...
数字图像处理基础程序及运行结果图像matlab程序
27 1 数字图像处理实验 实验一一、实验目的与要求 MATLAB 数字图像处理初步 1.熟悉及掌握在 MATLAB 中能够处理哪些格式图像。 2.熟练掌握在 MATLAB 中如何读取图像...
基于matlab数字图像处理与识别系统含程序
基于matlab数字图像处理与识别系统含程序 - 目录 第一章 绪论 ......
数字图像处理实验1 MATLAB图像处理编程基础 实验报告
数字图像处理实验1 MATLAB图像处理编程基础 实验报告_理学_高等教育_教育专区。运用matlab工具箱中的函数对图像进行简单的处理 实 验报 告 课程名称 实验项目 指导...
MATLAB数字图像处理基础实验
MATLAB 数字图像处理基础实验(转) 一、实验目的 1、复习 MATLAB 语言的基本用法; 2、掌握 MATLAB 语言中图象数据与信息的读取方法; 3、掌握在 MATLAB 中绘制灰度...
...实验1_数字图像处理中MATLAB使用基础
《数字图像处理(实验部分)》实验1_数字图像处理MATLAB使用基础_计算机软件及应用_IT/计算机_专业资料。《数字图像处理(实验部分) 》教案 实验一:数字图像处理中 ...
matlab图像处理实例练习2
matlab图像处理实例练习2 - Matlab 在图像处理中的应用 本文首先介绍了数字图像处理的发展现状及其应用优势,再阐述了 matlab 在图像处理方面的强大功能及其工具箱, ...
数字图像处理实验一图像的基本操作和基本统计指标计算...
数字图像处理实验一图像的基本操作和基本统计指标计算实验报告 - 实验一图像的基本操作和基本统计指标计算 一、 实验目的 熟悉 MATLAB 图像处理工具箱,在掌握 MATLAB...
更多相关标签: