Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

Hi CV/Pattern Recognition Community,

because my last thread was concerning the segmentation as BLOB and started to getting too big, with no clear results. I would like to reconcider the last step of that process regarding the sequential gaining of object contour points.

I need to extract the contour of an image from a defined starting point (left) to the right (endpoint). As you can see in the next image, there are two yellow windows (left and right). These are the mentioned start- and endpoints. And what I want to do: Starting from the left yellow window and moving to the right, saving (x,y) coords of the regarding points. This is what the red line (contour) does. The sequence of the contour pixels does matter. What I want to do

I am at the step where I've only got a binary image, So far, so good. In the worst case still with holes and possible noise in the rest of the image.

So, here are some images, which I want to extract.

For this example, I'd like to get the outer contour line of the object on the table/underground. As you can see in the right upper corner and in the left upper corner are fragments of the edge detection process, which should not be traversed. example1 example2

Thank you in advance. Matlab and/or OpenCV Hints are welcome!

share|improve this question
I made a little progress on that one. Took the ´bwlabel` function and sorted out the labels i wouldn't need. Nevertheless I need a complete contour which isn't guaranteed by this approach. So I will check the start and endpoints for the label identity and select those labels and merge them together, if they aren't of the same kind. –  mchlfchr Oct 22 '12 at 16:33

2 Answers 2

You can do the following in order to get a connected contour. Get a few points on the contour say like 100 points or so. And then fit a cubic-spline on it.

I had done something which might be helpful to you. Below is what I had done. The project was clustering of cars by shapes. So I had images of cars and I a user had marked the boundaries of the car. Red dots are the manually marked points. Then I had fit a closed cubic splines on these few points. The blue contour is the cubic spline. I then used this contour for my purpose enter image description here

I am sure you can do something similar to get the contours. Please be aware that it is possible to get an open curve with cubic splines. Let me also tell you constructing splines from these set of co-ordinate points is simple. What you basically want to do is fit a cubic curve between each set of points.

Please ask if you need further clarification on what I think.

share|improve this answer

What I can suggest is the following

1- Chop of the image at certain sections. You know where the base is, that is where the blue line reside. Chop of the image from there. If you can safely remove the bottom which is not required

2- Using Hough Transform, detect the horizontal and vertical lines of the image. Sort of the largest lines. And then remove them from the image. You should be now left with some clean image.

3- Either now find the contours of the image and see which contour now resides closest to the bottom of the image. This will ensure that your object of interest was close to the base. Or Find all the contours and remove the small ones of some predefined size and then look for the contours which lies near the base. Contours are always directional and in clock wise direction.

4- Or another way now is to start from the left yellow box and keep on tra

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.