Borrar filtros
Borrar filtros

Detect outer contour and find contour's co-ordinates, at sub-pixel level, ignoring noise.

9 visualizaciones (últimos 30 días)

Hi,

I want to find the co-ordinates of an object's contour (similar to a circular rim) which will be rotated in 3D. This need not appear like a circle when rotated in 3D. (Only the outermost contour is sufficient)

Also, if the contour has little noise, then I want this algorithm to ignore noise, and detect the correct contour of rim.

This should be done at a subpixel level (detecting contours).

It should be fast.

These points I have mentioned above are the requirements I have.

In order to do this, I have tried the following:

  1. Simple Sobel / Canny edge detectors. These do not give sub-pixel accuracy. Moreover, it does not tolerate any noise.
  2. Chan Vese Active Contours without edges. This algorithm detects at subpixel level, but is extremely slow (I am working with images of resolution around 10MP).
  3. Detect circles with various radii in grayscale image via Hough Transform. This has given me the best results so far. Here are a couple of points about this algorithm:
  • It has subpixel accuracy, as shown below:
  • This is fast enough.
  • It takes input as grayscale image and extracts contour information from this (instead of converting it to binary as many other algorithms I have come across do, therefore losing information).
  • If it encounters any noise on the contours, it ignores it and finds the contour (As displayed in the image below (I have introduces a little noise on the left side of rim's contour, and the algorith still works very well!)).
  • The problem with this is that when I rotate my object (circular rim) in 3D a little more, it cannot detect contour. (I have attached an image (Hough_grd_doesnt_work_for_this.bmp))
  • Since I am interested in detecting the contours, I also want the co-ordinates of the detected contour for my further processing. Using this algorithm, I am not able to access the co-ordinates.

This is the problem I am facing.

I want to know if there's any other algorithm which I can use for my work. Or if I can make some changes to CircularHough_Grd to make it more flexible.

Any inputs will be appreciated.

Thank you.

Respuestas (2)

Star Strider
Star Strider el 23 de Dic. de 2014
You e-mailed me to ask that I re-post my answer and code for finding a specific contour level plotted by the contour function, so I am doing so here:
q = matfile('Sanya_NX2_cordinates.mat');
c = q.c; % Get Data From ‘.mat’ File
lenix = find(c(2,:) >= 1000); % Find Indices Of Length Parameters
clen = c(2,lenix); % Contour Lengths
X = c(1,2:clen(1)); % First Column Is Info So Skip ...
Y = c(2,2:clen(1)); % ... Other Columns Are X,Y Data
figure(1)
plot(X, Y)
grid
axis equal
When I run this code, I do not get the extra lines such as in the plot you posted. I do not have access to the data (produced by contour) that you used in that plot, so I cannot help you discover what that particular problem is. If you want to post it here, I will do my best to help.
  1 comentario
Meghana Dinesh
Meghana Dinesh el 24 de Dic. de 2014
Editada: Meghana Dinesh el 24 de Dic. de 2014
Thanks.
Well, just so that others reading this know, it is an answer to this question of mine.
Currently, I am using a much simpler method Image Analyst suggested, instead of active contours. But later, I will get back to this, to improve my accuracy. (Or maybe it'll be useful in another project I am doing.)
I give my image as input to Active contour without edge by Su Dongcai. In demo_acwe.m, contour is obtained from the line:
[c,h] = contour(u,[0 0],'r');
This is where I use your code:
lenix = find(c(2,:) >= 1000); % Find Indices Of Length Parameters
clen = c(2,lenix); % Contour Lengths
X = c(1,2:clen(1)); % First Column Is Info So Skip ...
Y = c(2,2:clen(1)); % ... Other Columns Are X,Y Data
figure(1)
plot(X, Y)
grid
axis equal
I have attached my input image, a plot of all contours (output from Active contour without edge by Su Dongcai after 30 iterations) and after plotting only the outermost contour from your code.
The attachments are here.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 24 de Dic. de 2014
Like you said, the method I suggested is much simpler and will accurately follow the contours or edges of the region. That also means it will accurately track around all the little noisy areas and all the desired areas also. Unless you somehow identify which pixels are noise and which are not , you can't have it both ways. If it accurately follows edges, then it will trace the noise. If you smooth out the little fine nooks and crannies (noise) in the edge and follow a smoother path, then it might also go slightly off the edge at places where you didn't want it to.
If you want to assume that you're locating perfect circles, you can use imfindcircles(). If you want an accurate boundary, just threshold, like I suggested. If you want a smooth boundary then pass the thresholded image into activecontour() to smooth it out. It will be smoother, which means it will smoothly go through noisy areas which in turn means that it doesn't follow actual true edges as accurately.
  1 comentario
Meghana Dinesh
Meghana Dinesh el 24 de Dic. de 2014
Editada: Meghana Dinesh el 24 de Dic. de 2014
Again, I am comparing this to Detect circles with various radii in grayscale image via Hough Transform by Tao Peng. In the second example I have posted in my question above (where I have introduced a little noise on the contour), Tao Peng's code works perfectly! The algorithm traces the wheel's contour and forces the contour to be the same nearly circular shape, which makes it disregard any noise it finds on it's way (obviously, if it finds a little noise). This is a magnified view of how the contour is detected in the noisy part:
Perfect circles is not what I want to find since it wont be a perfect circle in 3D.
I have attached the output for your reference.
@ Image Analyst: Nevertheless, thanks for your suggestion. It works well for now =)

Iniciar sesión para comentar.

Categorías

Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by