Download presentation
Presentation is loading. Please wait.
1
Vectorization in MATLAB Vectorization: an operation carried out over an entire matrix or vector. Ex.1: compare the below instructions 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 a=[1:10].^2 a>10
2
Line detection Ex1:Produce the results as the right figure Use ic2.jpg
3
Edge detection (1) ic=imread( ‘ house.jpg'); px=[-1 0 1; -1 0 1; -1 0 1]; icx=filter2(px, ic); figure, imshow(icx,[]) py=px ’ ; icy=filter2(py, ic); figure, imshow(icy,[]); edge_p=sqrt(icx.^2+icy.^2); figure, imshow(edge_p, []); Ex2: Try 3x3, 5x5 smoothing before edge detection. Then thresholding your edge detection result.
4
Edge detection (2) edgep=edge(ic, ‘ sobel ’ ); Ex3: Use ‘help edge’, enter the threshold parameter yourself. Try to find a best threshold.
5
Edge detection (3) heart.jpg Generate Gaussian g=fspecial( ‘ gaussian'); Use Laplacian Ex4: show results as right -1 -1 -1 -1 8 -1 -1 -1 -1 Gaussian smoothing Laplacian of Gaussian original ?
6
Thresholding Example: b=imread( ‘ bacteria.tif ’ ); imshow(b), figure, imshow(b>100) Ex5: Determine a threshold that can properly separate the rice grains in rice.tif MATLAB function graythresh Otsu’s method for find optimal threshold graythresh(b)
7
Adaptive thresholding Create the illuminated image c=imread('circles.tif'); x=ones(256,1)*[1:256]; c2=double(c).*(x/2+50)+(1-double(c)).*x/2; c3=uint8(255*mat2gray(c2)); Ex6: Divide the image into four parts Thresholding each parts, then combine them
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.