
39f4563a64547450937a33f008a448c6.ppt
- Количество слайдов: 7
Vectorization in MATLAB n n Vectorization: an operation carried out over an entire matrix or vector. Ex. 1: compare the below instructions n n tic, for i=1: 10^6, sin(i); end, toc tic, i=1: 10^6; sin(i); toc Vectorization is faster than loops Example of vectorization n n a=[1: 10]. ^2 a>10
Line detection n n Ex 1: Produce the results as the right figure Use ic 2. jpg
Edge detection (1) ic=imread(‘house. jpg'); px=[-1 0 1; -1 0 1]; icx=filter 2(px, ic); figure, imshow(icx, []) py=px’; icy=filter 2(py, ic); figure, imshow(icy, []); edge_p=sqrt(icx. ^2+icy. ^2); figure, imshow(edge_p, []); Ex 2: Try 3 x 3, 5 x 5 smoothing before edge detection. Then thresholding your edge detection result.
Edge detection (2) n n edgep=edge(ic, ‘sobel’); Ex 3: Use ‘help edge’, enter the threshold parameter yourself. Try to find a best threshold.
Edge detection (3) original n n heart. jpg Generate Gaussian n n ? g=fspecial(‘gaussian'); Use Laplacian -1 -1 8 -1 -1 n Gaussian smoothing Ex 4: show results as right Laplacian of Gaussian
Thresholding n Example: n n n Ex 5: n n b=imread(‘bacteria. tif’); imshow(b), figure, imshow(b>100) Determine a threshold that can properly separate the rice grains in rice. tif MATLAB function graythresh n n Otsu’s method for find optimal threshold graythresh(b)
Adaptive thresholding n Create the illuminated image n n n c=imread('circles. tif'); x=ones(256, 1)*[1: 256]; c 2=double(c). *(x/2+50)+(1 -double(c)). *x/2; c 3=uint 8(255*mat 2 gray(c 2)); Ex 6: Divide the image into four parts n Thresholding each parts, then combine them n
39f4563a64547450937a33f008a448c6.ppt