Assignment 3 ΔΙΔΑΣΚΩΝ: ΑΛΕΞΑΝΔΡΟΣ ΜΑΚΡΗΣ

Assignment 3 ΔΙΔΑΣΚΩΝ: ΑΛΕΞΑΝΔΡΟΣ ΜΑΚΡΗΣ

Advances in Digital Imaging and Computer Vision 16/12/2018 Assignment 3 ΔΙΔΑΣΚΩΝ: ΑΛΕΞΑΝΔΡΟΣ ΜΑΚΡΗΣ ΠΑΠΑΔΑΚΗ ΜΑΡΙΑ Α.Μ. ΜΗ92 Σ΢ΑΡΟΤΧΙΔΟΤ ΧΑΡΙΚΛΕΙΑ Α.Μ. ΜΗ93 ΣΕΧΝΟΛΟΓΙΚΟ ΕΚΠΑΙΔΕΤΣΙΚΟ ΙΔΡΤΜΑ ΚΡΗΣΗ΢ ΠΡΟΗΓΜΕΝΑ ΢Τ΢ΣΗΜΑΣΑ ΠΑΡΑΓΩΓΗ΢ ΑΤΣΟΜΑΣΙ΢ΜΟΤ ΚΑΙ ΡΟΜΠΟΣΙΚΗ΢ PAGE 1 Assignment 3 Blob-Hough Exercise 1 – Blob Detection (30%) 01 Blob Detection a) Develop a simple 'blob' detector. The detector takes as arguments an image and the blob radius and return the detected blob positions. The detector should use Hough – Circle the LoG filter so the possible detections are the local minima and maxima of the 02 Detection filter response. b) Add an extra parameter to the detector to select either: i) dark blobs, ii) light blobs, or iii) both. c) Extend the detector so instead of a single radius it accepts a range (min, max). Test the detector firstly in the images 'black_dots.jpg', 'white_dots.jpg' and then also in 'coins.tiff' and 'circles_%%.jpg' . Present the results by showing the detected blobs in the initial images. Exercise 2 – Hough – Circle Detection (70%) a) Develop a system that detects circular objects of known radius r in an image. For their detection you should implement the Hough transform. Visualize the detected objects on the initial image. Test your system using the images 'coins.tiff' and 'circles_%%.jpg' . b) Extend your system to detect circular objects within a given radius interval rmin-rmax. c) Use the gradient orientation to render your system more robust to noise. d) Evaluate the final detector on the image 'circles_05.jpg'. To that end evaluate the precision and recall metrics for various detection thresholds and plot the precision-recall curve. A detection should be considered as correct if the ratio of overlap between the detection bounding box and the groundtruth bounding box divided by the area of the detection bounding box is above 0.8. The groundtruth bounding boxes are provided ('circles_05_gt.mat'). PAGE 2 01 a) Develop a simple 'blob' detector. The detector takes as arguments an image and the blob radius and return the detected blob positions. The detector should use the LoG filter so the possible detections are the local minima and maxima of the filter response. Before we apply the ‘blob’ detector first in 'black_dots.jpg' image with radius equals 50, we need to create the Blob detector function. (We named it blob_det(I,radius)). Inside the function we first convert our image (I) to greyscale and unit8. Then we create the LoG filter and filter the image. We defined that σ is equal with the cycle’s radius divided by the square root of 2. As well as the filter size to be 10 to 10. Then we show the image with the threshold and we find the centroid of the same image. Next we draw the red cycles around the centers and finally we show the result. Below is shown the matlab code for the blod detector function and the results we got for the image ‘black_dots.jpg'. (Image Frame 3.01) MATLAB CODE: function [A]=blob_det(I,radius) I1 = rgb2gray(I); %in case our image rgb converting it to grayscale I1=im2uint8(I1); %converting our image in unit8 s=radius/sqrt(2); %defining our s filter_size=[10, 10]; I2=double(I1); figure(1); imshow(I); LoG=s^2*fspecial('log',filter_size,s); %creating LoG filter I3 = imfilter(I2,LoG); %filtering the image thr=I3>0.22; %threashold figure(3) imshow(I3); figure(4); imshow(thr); Centers=regionprops(thr,'centroid'); centroids=cat(1,Centers.Centroid); imshow(thr); hold on A=[centroids(:,1),centroids(:,2)]; % hold on, figure(3) plot(centroids(:,1),centroids(:,2),'g*') ; R(1:size(centroids,1),1) = radius; K = int16([A R]); red = uint8([255 0 0]); J = vision.ShapeInserter('Shape', 'Circles','BorderColor','Custom','CustomBorderColor', red); Y = step(J, I, K); imshow(Y); end PAGE 3 Our Image Drawing the cicles Finding the centers Image Frame 3.01 Now we will apply the function for the image ‘white_dots.jpg’ image with radius equals 25 and the results that we got are shown in the Image Frames 3.02. Image Cycles Drawn Image Frames 3.02 PAGE 4 Next, we apply the function for the image ‘coins.tiff’ and take the results for the Image Frame 3.03. Image Cycles Drawn Image Frames 3.03 Next, we apply the function for the image ‘circles_01.jpg’ with radius equals 45, the filter size equals with 2*radius, threshold around 30 and take the results for the Image Frame 3.04. Image Draw Cycle Image Frames 3.04 Last for a, we apply the function for the image ‘circles_02.jpg’ with radius equals 15, the filter size equals with 2*radius, threshold around 30 and take the results for the Image Frame 3.05. PAGE 5 Image Draw Cycle Image Frames 3.05 b) Add an extra parameter to the detector to select either: i) dark blobs, ii) light blobs, or iii) both. Here we will add an extra parameter to our script we will choose whether we want dark circles to be assumed, let us assume option = 1, dark-circles option = 2 or all circles option 3. The code will change to the following and we will get the results below. We will just add a third variable ‘option’ to our function and simply use the if..else statement to our code. MATLAB CODE: function [A]=blob_det1(I,radius,option) … if option==1 thr=I3>25; if option==2 thr=I3<-25; else thr=(I3<-0.22 & I3>0.22); end end … PAGE 6 c) Extend the detector so instead of a single radius it accepts a range (min, max) MATLAB CODE I=imread(black_dots.jpg); I2=im2uint8(I); Is=size(I2); if (length(Is)==3) I2=rgb2gray(I2); end r_min=25; r_max=30; I_double=double(I2); figure(1); imshow(I); count=1; for i=r_min:r_max r=i; s=r/sqrt(2); filter_size=2*r; Fsx=s^2*fspecial('log',filter_size,s); th= imfilter(I_double,Fsx); I_fil_thr=th<-20; E(:,:,count)=I_fil_thr; count=count+1; end S = regionprops(E, 'centroid'); centroids=cat(1,S.Centroid); figure(3) imshow(I); hold on C=[centroids(:,1),centroids(:,2)] plot(centroids(:,1),centroids(:,2),'g*') ; R(1:size(centroids,1),1) = r; PTS = int16([C R]); red = uint8([255 0 0]); J = vision.ShapeInserter('Shape', 'Circles','BorderColor','Custom','CustomBorderColor', red); RGB = repmat(I,[1,1,3]); Y = step(J, I, PTS); figure(4) imshow(Y); PAGE 7 Image Frames 3.06 02 a) Develop a system that detects circular objects of known radius r in an image. For their detection you should implement the Hough transform. Visualize the detected objects on the initial image. Test your system using the images 'coins.tiff' and 'circles_%%.jpg'. Here we'll describe how to detect circles (which are quite important in computer vision application) using a technique Hough transform. So, the flow of events is something like this: I. Load an image 'circles_01.jpg'. II. Detect edges and generate a binary image. III. For every 'edge' pixel, generate a circle in the space. IV. For every point on the circle in the space, cast 'votes' in the accumulator cells. V. The cells with greater number of votes are the centers. (Step 4 and 5 are created by using the AddCircle that has already being given to us. “Lucky us!” VI. We used a sobel operator to get the images. And finally, for every white pixel in the image, it creates a circle in the space. VII. The horizontal axis is the 'a' axis, the vertical axis is the 'b' axis. The brighter a spot, more the number of votes case at the point. And more votes imply a greater probability of a point being a center. Note: When the radius is unknown, the simplest solution is to just guess. Assume R = 1, and then run the same algorithm. Then assume R = 2, and run it again. Assume R = 3.... and so on. PAGE 8 MATLAB CODE: I=imread('circles_01.jpg'); radius=50; s=size(I); if (length(s)==3) I=rgb2gray(I); End I2=double(I); a=min(min(I2)); b=max(max(I2)); In=(I2 - a) * 255 / (b - a); Gaus_filer=fspecial('gaussian',[3,3],0.5); Sobel_filter= fspecial('sobel'); Ix=imfilter(Gaus_filer,Sobel_filter); Iy=imfilter(Gaus_filer,Sobel_filter') ; I5=imfilter(In,Ix); I6=imfilter(In,Iy); I7=sqrt(I5.^2+I6.^2); I7=I7>235; figure(1) imshow(I7) hough=I7.*0; [K2,K1]=find(I7); x=length(K1); for i=1:x hough=AddCircle(hough,radius,K1(i),K2(i),0.011); %votes end figure(2) imshow(hough) hough=hough>0.50; %threshold S = regionprops(hough, 'centroid'); centroids=cat(1,S.Centroid); figure(3) imshow(I); hold on C=[centroids(:,1),centroids(:,2)]; plot(centroids(:,1),centroids(:,2),'g*') ; R(1:size(centroids,1),1) = radius; PTS = int16([C R]); red = uint8([255 0 0]); J = vision.ShapeInserter('Shape', 'Circles','BorderColor',Custom', …'CustomBorderColor', red); RGB = repmat(I,[1,1,3]); Y = step(J, RGB, PTS); figure(4) imshow(Y); PAGE 9 Image: 'circles_01.jpg' Radius: 50 Threshold: 0.50 Image Frames 3.07 PAGE 10 Image: 'circles_02.jpg' Radius: 18 Threshold: 0.35 (We note that this time it detected another cycle not the one we were supposed to find.) Image Frames 3.08 PAGE 11 Image: 'circles_03.jpg' Radius: 75 Threshold: 0.70 Image Frames 3.09 PAGE 12 Image: 'circles_04.jpg' Radius: 30 Threshold: 0.30 Image Frames 3.10 PAGE 13 Image: 'circles_05.jpg' Radius: 18 Threshold: 0.30 Image Frames 3.11 PAGE 14 b) Extend your system to detect circular objects within a given radius interval rmin-rmax.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    24 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us