Title: Chapter 2: Digital Image Fundamentals
1Chapter 2 Digital Image Fundamentals
2Chapter 2 Digital Image Fundamentals
3Chapter 2 Digital Image Fundamentals
4Chapter 2 Digital Image Fundamentals
5Chapter 2 Digital Image Fundamentals
6Chapter 2 Digital Image Fundamentals
7Chapter 2 Digital Image Fundamentals
8Chapter 2 Digital Image Fundamentals
9Chapter 2 Digital Image Fundamentals
10Chapter 2 Digital Image Fundamentals
11Chapter 2 Digital Image Fundamentals
12Chapter 2 Digital Image Fundamentals
13Chapter 2 Digital Image Fundamentals
14Chapter 2 Digital Image Fundamentals
15Chapter 2 Digital Image Fundamentals
16Chapter 2 Digital Image Fundamentals
17Chapter 2 Digital Image Fundamentals
18Chapter 2 Digital Image Fundamentals
19Chapter 2 Digital Image Fundamentals
20Chapter 2 Digital Image Fundamentals
21Chapter 2 Digital Image Fundamentals
22Chapter 2 Digital Image Fundamentals
23Chapter 2 Digital Image Fundamentals
24Chapter 2 Digital Image Fundamentals
25Chapter 2 Digital Image Fundamentals
26Chapter 2 Digital Image Fundamentals
27Chapter 2 Digital Image Fundamentals
28Chapter 2 Digital Image Fundamentals
29MATLAB/Image Processing Toolbox
function rt, f, g twodsin(A,u0, v0, M, N)
TWODSIN Compares for loops vs. vectorization.
The comparison is based on implementing the
function f(x,y)Asin(u0xv0y) for x0,1,2,,M-1
and y0,1,2,,N-1. The inputs to the function
are M and N and the constants in the
function. First implement using for loops tic
start timing for r1M u0xu0(r-1) for
c1N v0yv0(c-1) f(r,c)Asin(u0xv0y
) end end t1toc End timing Now
implement using vectorization tic start
timing r0M-1 c0N-1 C,Rmeshgrid(c,r) spe
cial MATLAB function for fast 2F function
evaluations creates all the (x,y) pairs for
function evaluation gAsin(u0Rv0C) t2toc
End timing compute the ratio of the two
times rtt1/(t2eps) use eps in case t2 is
close to zero.
30MATLAB/Image Processing Toolbox
gtgt rt,f,gtwodsin(1, 1/(2pi), 1/(4pi), 512,
512) gtgt rt rt 34.2520 according to
GWE. I only got 19. gtgtgmat2gray(g) gtgt
imshow(g) show in separate window.
31MATLAB/Image Processing Toolbox
imshow (f,G) F is an image array G is the
number of intensity levels. Default is
256. imwrite(f, filename) filename MUST
contain a recognized file format extension .tif
or .tiff identify TIFF .jpg identifies jpeg
additional parameters for tiff and jpeg identify
compression, etc. imfiinfo filename returns all
kind of cool file information such as
size Imread(filename) filename MUST contain
an appropriate extension
32MATLAB/Image Processing Toolbox
indexed
bw2ind
rgb2ind
ind2rgb
im2bw
ind2gray
gray2ind
RGB
binary
im2bw
rgb2gray
im2bw
intensity
mat2gray
General matrix
33MATLAB/Image Processing Toolbox
1
2
3
N
c
1
2
3
M
r
One pixel
34MATLAB/Image Processing Toolbox
gtgt himhist(f) any
previously loaded image gtgt h1h(110256)
create bins for horiz axis gtgt
horz(110256 gtgt
bar(horiz, h1) gtgt
axis(0 255 0 15000) expand lower
range of y-axis gtgt set(gca, xtick, 050255)
gca means get current axis gtgt set(gca,
ytick, 0200015000) lab h v ticks