1 / 11

Image Segmentation I

Image Segmentation I. Comp344 Tutorial Kai Zhang. Outline. Line & Edge detection Hough transform. Line Detection. Apply a mask and compute the image response Design of Mask determines what kind of line is detected -1 -1 -1 -1 -1 2 -1 2 -1 2 -1 -1

theola
Download Presentation

Image Segmentation I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Image Segmentation I Comp344 Tutorial Kai Zhang

  2. Outline • Line & Edge detection • Hough transform

  3. Line Detection • Apply a mask and compute the image response • Design of Mask determines what kind of line is detected • -1 -1 -1 -1 -1 2 -1 2 -1 2 -1 -1 • 2 2 2 -1 2 -1 -1 2 -1 -1 2 -1 • -1 -1 -1 2 -1 -1 -1 2 -1 -1 -1 2 • Horizontal +45o vertical -45o

  4. Codes • f = imread('wirebond.tif'); • w = [2 -1 -1; -1 2 -1; -1 -1 2]; • g = imfilter(double(f),w); • imshow(g,[]); • gtop = g(1:120,1:120); • gtop = pixeldup(gtop, 4); • figure,imshow(gtop, []); • gbot = g(end - 119:end, end-119:end); • gbot = pixeldup(gbot, 4); • figure,imshow(gbot, []); • g = abs(g); • figure,imshow(g,[]); • T = max(g(:)); • g = g >= T; • figure,imshow(g,[]);

  5. Hough Transform • A method for line detection on binary images • Transform points in the x-y plane into the parameter space (\rho, \theta) • Detect local maximum on the parameter space (kind of voting), which corresponds to strong line signals • Complexity much lower than naïve method

  6. Sparse matrices in matlab • Sparse matrix: Matrices that contain only a small number of non-zero elements • Sparse matrix can reduce both the storage and the computational complexity • Example • A = [ 0 0 0 5; 0 2 0 0; 1 3 0 0; 0 0 4 0]; • S = sparse(A); • S = • (3,1) 1 • (2,2) 2 • (3,2) 3 • (4,3) 4 • (1,4) 5

  7. Example 1

  8. Codes • f = zeros(101,101); • f(1,1) = 1; f(101,1) = 1; f(1,101) = 1; • f(101,101) = 1; f(51,51) = 1; • figure,imshow(f,[]); • H = hough(f); • figure, imshow(histeq(H),[]); • [H, theta, rho] = hough(f); • figure, imshow(theta, rho, histeq(H), [], 'notruesize'); • axis on; axis normal; • xlabel('theta'),ylabel('\rho');

  9. Example 2

  10. codes • f = double(imread('building.tif')); • [canny,tc] = edge(f,'canny',[0.04 0.1], 1.5); • figure,imshow(canny,[]); • f = g_canny_default; • [H, theta, rho] = hough(f,0.5); • figure, imshow(theta, rho, H/30, 'notruesize'),axis on; axis normal; • [r,c] = houghpeaks(H, 5); • hold on; plot(theta(c),rho(r),'linestyle','none','marker','s','color','w'); • lines = houghlines(f, theta, rho, r,c); • figure,imshow(f,[]);hold on; • for k = 1:length(lines); • xy =[lines(k).point1; lines(k).point2]; • plot(xy(:,2),xy(:,1),'LineWidth',4,'Color',[.9 .0 .0]); • end;

More Related