









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Jacobs; Class: Image Processing; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Assignments
1 / 16
This page cannot be seen from the preview
Don't miss anything!










A Ax Zx^ Z e A e^2 dx^2
g (^) 1 ( u ) g 2 ( x u ) du
du u x u ) 2 ( ) exp{ 2 1 ) 2 exp{ 2 1 2 2 2 2 2 1 2 1 ^
du u x u ) 2 ( ) 2 exp{ 2 1 2 2 2 2 1 2 1 2
2 2 2 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 2 1 (^22) 1 2 2 2 1 2 1 (^22) 2 2 1 1 2 2 2 2 1 2 1 (^22) 1 (^22) 2 2 1 1 2 2 2 2 1 (^22) 1 (^22) 2 1 2
( )/ 0 2 2 2 1 2 2 2 A 1 and 2 Z x / 2
g (^) 1 ( u ) g 2 ( x u ) du
2 2 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 (^22) 2 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 2 2 1 2
} 2 ( 2 ) exp{ 2 2 1 ( ) ( ) 2 2 1 2 x g^ ug x u^ du
, sin 2 sin 2 , cos 2 cos 2 , sin sin , cos cos
2 0 2 0 cos(( ) ) cos(( ) ) 2
cos( nx )cos( mx ) dx n m x n m xdx ^ ^ 2 0 2 0 2 0 2 0 21 cos(( )^ ) 21 cos(( ) )^000 21 cos(( )^ ) 21 cos(^0 * )^0122 n mx dx n m x dx n mx dx x dx n m n m
2 0 2 0 cos(( ) ) cos(( ) ) 2
sin( nx )sin( mx ) dx n m x n mxdx ^ ^ (^12) cos(( ) ) 21 cos(( ) ) 0 0 0 (^12) cos( 0 * ) 21 cos(( ) ) (^1220) 2 0 2 0 2 0 2 0 n m x dx n m x dx xdx n m x dx n m n m 2 0 2 0 sin(( ) ) sin(( ) ) 2
cos( nx )sin( mx ) dx n m x n mxdx ( 0 0 ) 0 2
( sin(( ) ) sin(( ) ) ) 2
2 0 2 0 (^) n m xdx n mx dx
(^) 2 0 || cos n || cos^2 n
(^) 2 0 || sin n || sin^2 n
^ ^ 0 ( x )^1 otherwise m x m
1 1 ||sin || sin ||cos || cos ( ) n n n n nx x b nx nx x a
2 0 1 1 2 0 )cos } ||sin || sin ||cos || cos { ( )cos } {( kxdx nx x b nx nx x kxdx a n n n n (^) (^)
1 2 (^10) 2 0 {sin cos } ||sin || {cos cos } || cos || n n n n (^) nx kxdx nx b nx kx dx nx a
1 1
n n n
k k (^) a kx a
||cos ||
^ 0 ( n , k )^1 otherwise n k
2 0 { ( )cos }
ak x kxdx
m m m m m m kxd kx k kxdx kxdx kxdx 0 0 {cos } ( )
cos
cos
cos
km k kx k m x sin
sin |
0
2 0 { ( )sin }
bk x kxdx 0 0
sin
sin
(^)
m m m m kxdx kxdx
1 1 1 ||cos || cos sin( )
||sin || sin ||cos || cos ( ) n n n n n (^) nx nx nm nx n x b nx nx x a
Y2 = Y2(dMargin+1:dMargin+length(X)); Y3 = Convolve1D(Y2,Y); Y3 = Y3(dMargin+1:dMargin+length(X)); plot(X,Y,'k--', X,Y1,'r:', X,Y2,'g-.', X,Y3,'b-'); legend('original Gaussian', 'convolve once', 'convolve twice', 'convolve three times'); Title('convolve Gauassian with itselft, sigma=2');
% EdgeDetect1D.m % 1D edge detector. Take 2 parameters, the amount of smoothing % and a threshold on the strength of the edge % % returns a binary image BW of the same size as I, with 1's where % the function finds edges in I and 0's elsewhere. function imRes = EdgeDetect1D(im1D, sigma, threshold) X = ceil(-3sigma:3sigma); fGau = Gaussian(X, sigma); fGra = [1, 0, -1]; dMargin = 1; fDoG = Convolve1D(fGau,fGra); fDoG = fDoG(dMargin+1:dMargin+length(X)); dMargin = floor(length(fDoG)/2); imRes = Convolve1D(im1D, fDoG); imRes = imRes(dMargin+1:dMargin+length(im1D)); resLen = length(imRes); imRes = abs(imRes); peaks = [0, (imRes(2:resLen-1)> imRes(1:resLen-2) & imRes(2:resLen- 1)>=imRes(3:resLen)) | ... (imRes(2:resLen-1)>=imRes(1:resLen-2) & imRes(2:resLen- 1)> imRes(3:resLen)), 0]; imRes = peaks.*imRes; imRes = imRes > threshold;
% hwk2c.m. Testing the result of running EdgeDetect1D. clear all; I=[zeros(1,50),.9ones(1,10),zeros(1,10),.6ones(1,40),zeros(1,50)]; sigma = 1; threshold = .3; imEdge = EdgeDetect1D(I, sigma, threshold); figure(1); clf, hold on;
plot(1:length(I), I,'r:', 1:length(I),imEdge,'b-'); legend('1D signal', '1 = edge', 1); axis([0,160,-.1,1.1]); Title('Finding edge 1D: threshold=0.3');
% hwk2d.m clear all; I=[zeros(1,50),.9ones(1,10),zeros(1,10),.6ones(1,40),zeros(1,50)]; figure(1); clf, hold on; subplot(2,1,1); plot(1:length(I), I,'r'); axis([0,160,-.1,1.1]); grid on; Title('Finding edge 1D: threshold=0.1'); subplot(2,1,2); hold on; threshold = .1; for sigma=.5:.5: imEdge = EdgeDetect1D(I, sigma, threshold); for x=1:length(imEdge) if imEdge(x)>0.99 % 1 means the edge plot(x,sigma,'.r'); end end end axis([0,160,0,26]); grid on; xlabel('1D position'); ylabel('sigma'); Title('red points: positions of edge, no edges found when sigma is large');
% hwk2e.m clear all; IOld = [zeros(1,50), 9ones(1,10), zeros(1,10), 3ones(1,40), zeros(1,50)]; I = IOld + randn(1,length(IOld)); figure(1); clf, hold on; subplot(2,1,1); plot(1:length(IOld), IOld,'b-', 1:length(I), I,'r-'); legend('Original signal', 'Plus noise'); axis([0,160,-1.5,10.5]); grid on; Title('Finding edge for noised 1D image: threshold=0.1'); subplot(2,1,2); hold on; threshold = .1; for sigma=.5:.5: imEdge = EdgeDetect1D(I, sigma, threshold);
% hwk3.m, homework problem # clear all; I = imread('1.jpg'); E1 = edge(I, 'canny', [.02, .1], 1); E1o = edge(I, 'canny', [.3, .4], 1.5); imwrite(E1,'1E.jpg', 'JPEG'); imwrite(E1o,'1Eo.jpg', 'JPEG'); figure(1); clf; hold on; subplot(2,3,1); imshow(I); title('original image'); subplot(2,3,2); imshow(E1); title('default threshold'); subplot(2,3,3); imshow(E1o); title('threshold=[.3,.4] sig=1.5'); I = imread('2.jpg'); E1 = edge(I, 'canny', [.02, .1], 1); E1o = edge(I, 'canny', [.20, .3], 1.5); imwrite(E1,'2E.jpg', 'JPEG'); imwrite(E1o,'2Eo.jpg', 'JPEG'); subplot(2,3,4); imshow(I); title('original image'); subplot(2,3,5); imshow(E1); title('default threshold'); subplot(2,3,6); imshow(E1o); title('threshold=[.2,.3] sig=1.5');