I have an image on a white background. Is it possible to fill the object with a solid color so that Canny Edge would only detect the boundary and not the unnecessary lines? Or is there an easier algorithm for detecting just the outline of the object? I've seen a few libraries for image processing such as JavaCV. But I haven't tried them yet. Do you have any suggestions? Thanks in advance.
Asked
Active
Viewed 2,043 times
1
-
See [Image/Graphic into a Shape](http://stackoverflow.com/questions/7052422/image-graphic-into-a-shape) & [Smoothing a jagged path](http://stackoverflow.com/questions/7218309/smoothing-a-jagged-path) for some tips on one (primitive) way to obtain a `Shape` of the non-white area of an image. Actually I suspect I misread your question. Could you link to an example small (in bytes) image? – Andrew Thompson Dec 29 '12 at 05:15
-
sample input: [link](http://4photos.net/en/image:118-215226-Maple_Leaf_images), sample output: [link](http://0.tqn.com/d/gonewengland/1/0/5/C/leaf5.gif) – user974227 Dec 29 '12 at 05:22
-
OK - 1.1 Meg is hardly 'small', but it appears the technique outlined in the first linked thread should do it. I doubt any of those lightly colored area along the veins of the maple leaf are close enough to white to confuse the algorithm. Try it. – Andrew Thompson Dec 29 '12 at 05:26
-
I've tried Canny Edge. But it includes the venation in the output. Someone has suggested connected-component labeling but I'm afraid the line detected might not be connected at all. Ok thanks. I will look into that! :D – user974227 Dec 29 '12 at 05:28
-
You could probably use a variation of the Floodfill algorithm to do the task. – Extreme Coders Dec 29 '12 at 06:33
-
thanks. i'll look into tat one too. – user974227 Dec 29 '12 at 06:36
-
You could floodfill on the white background to obtain an outline of the image. What you do is to keep a note of pixels that are not of white color while maintaining continuity with the outer white background. – Extreme Coders Dec 29 '12 at 07:57
-
the code in Smoothing a jagged path worked well. Took me time to read and understand it though. Thanks anyway. :D – user974227 Dec 29 '12 at 12:24
-
Please add a sample image. – Abid Rahman K Dec 29 '12 at 18:35
-
see my comment above for sample input and output. thanks! – user974227 Dec 30 '12 at 05:16
2 Answers
0
Just do a threshold on the image, cutting out the white part. Then you end up with a binary image. You can then apply Canny if you like.

Rob Audenaerde
- 19,195
- 10
- 76
- 121
-
Yes, that's how it worked. The algo in the link given above worked more accurately than Canny. – user974227 Dec 30 '12 at 05:19
0
Edge detection in various graphic libraries does the same as edge detection tool in Photoshop
or Photopaint
does. If you wan't true outline detection, you need to implement sophisticated AI logic above it.

Dims
- 47,675
- 117
- 331
- 600