Results 1 to 4 of 4

Math Help - (Matlab) Image processing - Detect multiple circle

  1. #1
    Newbie
    Joined
    Apr 2009
    Posts
    2

    (Matlab) Image processing - Detect multiple circle

    Dear All..

    I need your help about hough transform..
    I have problem with detecting multiple circle
    I have program to detect a circle and show the radius of it..
    but the problem is I want to detect another circle in a picture and shown the radius as well..

    here is the program

    ---------------------------------------------------------------------
    %circle equation = (x-a)^2 + (y-b)^2 = R^2
    I = imread('pic23.bmp');
    % function [radian]= hough (I)
    I =im2bw(I);
    [y,x]=find(I);
    [sy,sx]=size(I);

    totalpix = length(x); %totalpix is the numbers of '1' in the image (white)
    HM = zeros(sy,sx,50); %Preallocate memory
    R = 1:50; %R is known in the range from 1 to 50
    R2 = R.^2;
    sz = sy*sx; %column x row

    % Hough Transform
    for cnt = 1:totalpix
    for cntR = 1:50
    b = 1:sy;
    a = (round(x(cnt) - sqrt(R2(cntR) - (y(cnt) - [1:sy]).^2))); %(x-a)^2 + (y-b)^2 = R^2
    b = b(imag(a)==0 & a>0);
    a = a(imag(a)==0 & a>0);
    ind = sub2ind([sy,sx],b,a);
    HM(sz*(cntR-1)+ind) = HM(sz*(cntR-1)+ind) + 1;
    end
    end


    % Find for the maximum value for each layer, or in other words, the layer
    % with maximum value will indicate the correspond R for the circle
    for cnt = 1:50
    H(cnt) = max(max(HM(:,:,cnt)));

    end

    [maxval, maxind] = max(H);
    [B,A] = find(HM(:,:,maxind)==maxval);
    imshow(I); hold on;
    plot(mean(A),mean(B),'xr')
    text(mean(A),mean(B),num2str(maxind),'color','gree n')
    radian = maxind


    ------------------------------------------------------------

    and the result of the image i put on attachment .
    It shows only the radius of the biggest circle.
    I want to know the small one also, or if there is another circle.
    Thank you very much for any help..
    Attached Thumbnails Attached Thumbnails (Matlab) Image processing - Detect multiple circle-pic-23-mat.jpg  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Zoegabh View Post
    Dear All..

    I need your help about hough transform..
    I have problem with detecting multiple circle
    I have program to detect a circle and show the radius of it..
    but the problem is I want to detect another circle in a picture and shown the radius as well..

    here is the program

    ---------------------------------------------------------------------
    %circle equation = (x-a)^2 + (y-b)^2 = R^2
    I = imread('pic23.bmp');
    % function [radian]= hough (I)
    I =im2bw(I);
    [y,x]=find(I);
    [sy,sx]=size(I);

    totalpix = length(x); %totalpix is the numbers of '1' in the image (white)
    HM = zeros(sy,sx,50); %Preallocate memory
    R = 1:50; %R is known in the range from 1 to 50
    R2 = R.^2;
    sz = sy*sx; %column x row

    % Hough Transform
    for cnt = 1:totalpix
    for cntR = 1:50
    b = 1:sy;
    a = (round(x(cnt) - sqrt(R2(cntR) - (y(cnt) - [1:sy]).^2))); %(x-a)^2 + (y-b)^2 = R^2
    b = b(imag(a)==0 & a>0);
    a = a(imag(a)==0 & a>0);
    ind = sub2ind([sy,sx],b,a);
    HM(sz*(cntR-1)+ind) = HM(sz*(cntR-1)+ind) + 1;
    end
    end


    % Find for the maximum value for each layer, or in other words, the layer
    % with maximum value will indicate the correspond R for the circle
    for cnt = 1:50
    H(cnt) = max(max(HM(:,:,cnt)));

    end

    [maxval, maxind] = max(H);
    [B,A] = find(HM(:,:,maxind)==maxval);
    imshow(I); hold on;
    plot(mean(A),mean(B),'xr')
    text(mean(A),mean(B),num2str(maxind),'color','gree n')
    radian = maxind


    ------------------------------------------------------------

    and the result of the image i put on attachment .
    It shows only the radius of the biggest circle.
    I want to know the small one also, or if there is another circle.
    Thank you very much for any help..
    Assuming what I think this is doing is correct:

    Delete the layer with the already found max, and find the max of the remaining layers.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2009
    Posts
    2
    Quote Originally Posted by CaptainBlack View Post
    Assuming what I think this is doing is correct:

    Delete the layer with the already found max, and find the max of the remaining layers.

    CB
    Thank you for your response.
    but i'm still confused about it,
    can you explain little bit.
    thank you
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Zoegabh View Post
    Thank you for your response.
    but i'm still confused about it,
    can you explain little bit.
    thank you
    Not without a detailed explanation of how you are implementing the transfrom.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Image-processing Algorithm
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: June 11th 2011, 09:08 PM
  2. Pulse response and Phase function (image processing-Wavelets)?
    Posted in the Advanced Math Topics Forum
    Replies: 3
    Last Post: December 6th 2010, 02:14 AM
  3. Stability of an impulse response (image processing -Wavelets)?
    Posted in the Advanced Math Topics Forum
    Replies: 0
    Last Post: December 3rd 2010, 05:26 PM
  4. A problem with matlab image analysis
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 13th 2010, 07:55 AM
  5. Matlab doesn't gives an error when processing
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 4th 2009, 02:05 PM

Search Tags


/mathhelpforum @mathhelpforum