90 likes | 175 Views
Announcements. No office hours on Wednesday. Make up office hours Tuesday Friday class will be taught by Ravish Mehra . Final exam Mon Dec 10 12pm-3pm in SN014. Image manipulation (filtering). Discrete Convolution.
E N D
Announcements • No office hours on Wednesday. Make up office hours Tuesday • Friday class will be taught by Ravish Mehra. • Final exam Mon Dec 10 12pm-3pm in SN014
Discrete Convolution • Let f be a 1xn matrix and g be a 1x m matrix. If h is the convolution of f with g. Then, • It actually is
Smoothing • A is a preassigned row vector • imfilter(A, [1 1 1 1 1]/5) does uniform averaging • imfilter(A, [1 2 4 2 1]/10) is an example of weighted averaging, where the central element has a higher weight
Finding cliffs/edges • A is a preassigned row vector • imfilter(A, [-1 1]) identifies cliffs. Equivalent to differentiating. • But differentiating increase noise • imfilter(A, [-1 -1 11]) identifies cliffs also suppresses noise • imfilter(A, [-1 -2 2 1]) weighted differentiating
2D smoothing • A is a matrix • imfilter(A,[1 1 1 1]/4) smooths along the rows (in the y-direction) • imfilter(A,[1 1 1 1]’/4) smooths along the columns (x-direction) • imfilter(A,ones(4,4)/16) smooths in all directions. • Remember: you are not restricted to uniform averaging. Try non-uniform kernels.
Blurring Images • Download che_gray.jpg from the course page • Read it into Matlab using imread and convert into a matrix of doubles >> sub_im=im(1:4:end,1:4:end) >> imagesc(sub_im) >> surf(sub_im) >> surf(imfilter(sub_im,ones(5,5)/25)) • Smoothing is equivalent to blurring
Motion blur • kernel=eye(10) • im_motion=imfilter(im,kernel); • imagesc(im_motion)
Finding cliffs/edges • Find Cliffs facing North/South >>clfs_ns=imfilter(sub_im,[-1 -1 -1 1 1 1]) • Find Cliffs facing East/West >>clfs_ew=imfilter(sub_im,[-1 -1 -1 1 1 1]’) • All Cliffs >>clfs_all=sqrt(clfs_ns.^2+clfs_ew.^2)