Is it possible to segment the following image into three parts automatically? Thanks.
Is it possible to do auto segmentation?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Is it possible to do auto segmentation?
WARNING: I will assume the image is pure black and white, which does not appear to be the case! That can make segmentation much much harder as borders of segments could be regarded as having sub-pixel components! I have even seen some sement programs (such as autotrace raster to vector convertor) make each individual edge grey pixel a separate segment. I suggest you threshold the image first!
However I can not see three segments in your image, at least not without further processing! (using morphology)
From the top level I can see at least 10 segments, two odd boxes and 8 individual letters.
If I segment inside borders too I get 30 black segments!
If I was segmenting white areas (the more common proposition for mask segmentation) I see 23 separate and distinct white segments.
If I segment all back and white areas, I get a total of 53 segments for this image!
If that is not wanted you need to describe your segments more fully!
At this time IM is short on built-in segmentation methods. They are planned but there are just not enough programmers willing to get their hands dirty.
I myself have a 'morphology labelling' algorithm planned that would label each white area with a separate grayscale color (segment index) and can join segments that are close to each other (not just a floodfill Z4 neighbourhood segmentation)
A Proof-of-concept segmentation script (using flood fll to mark and remove each segment as it found), is presented in IM
Examples Scripts Area...
http://www.imagemagick.org/Usage/scripts/
Look for "segment_image"
http://www.imagemagick.org/Usage/scripts/segment_image
This was developed as part of another very old IM discussions
http://imagemagick.org/discourse-server ... =1&t=11705
http://imagemagick.org/discourse-server ... =1&t=18283
Examples...
Input...
montage of all output images
The checkerbod is transparency, the red boxes are the 'trimed' image on its vitual canvas (the original image size), and represents the images rectanguar bounding box. If I flattened or mosaic all those images together I would get the original image again. This type of result (perhaps ignoring a specified background color) is the goal of a 'perfect' segmentation.
Other forms of segmentation is 'edge to edge lines' either just horizontally, vertiaclly, both, or any angle. Perhaps recursively, that is segment horizontal, then segment those vertically, then horizontally again.
On horozontal segmentation (dividing an image vertically) is given by the scripts (same directory as before)
divide_vert and divide_vert_bg
the later is faster but limited to a specific background color.
However I can not see three segments in your image, at least not without further processing! (using morphology)
From the top level I can see at least 10 segments, two odd boxes and 8 individual letters.
If I segment inside borders too I get 30 black segments!
If I was segmenting white areas (the more common proposition for mask segmentation) I see 23 separate and distinct white segments.
If I segment all back and white areas, I get a total of 53 segments for this image!
If that is not wanted you need to describe your segments more fully!
At this time IM is short on built-in segmentation methods. They are planned but there are just not enough programmers willing to get their hands dirty.
I myself have a 'morphology labelling' algorithm planned that would label each white area with a separate grayscale color (segment index) and can join segments that are close to each other (not just a floodfill Z4 neighbourhood segmentation)
A Proof-of-concept segmentation script (using flood fll to mark and remove each segment as it found), is presented in IM
Examples Scripts Area...
http://www.imagemagick.org/Usage/scripts/
Look for "segment_image"
http://www.imagemagick.org/Usage/scripts/segment_image
This was developed as part of another very old IM discussions
http://imagemagick.org/discourse-server ... =1&t=11705
http://imagemagick.org/discourse-server ... =1&t=18283
Examples...
Input...
montage of all output images
The checkerbod is transparency, the red boxes are the 'trimed' image on its vitual canvas (the original image size), and represents the images rectanguar bounding box. If I flattened or mosaic all those images together I would get the original image again. This type of result (perhaps ignoring a specified background color) is the goal of a 'perfect' segmentation.
Other forms of segmentation is 'edge to edge lines' either just horizontally, vertiaclly, both, or any angle. Perhaps recursively, that is segment horizontal, then segment those vertically, then horizontally again.
On horozontal segmentation (dividing an image vertically) is given by the scripts (same directory as before)
divide_vert and divide_vert_bg
the later is faster but limited to a specific background color.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Is it possible to do auto segmentation?
Hi Anthony,
Sorry that I did not clarify it. The three segments I want to extract are: Upper box and insides, lower box and insides, the others (which is the label "Page 123" in that image).
So I guess there may exist a method to recognize the sides of the boxes and perform such segmenting.
Sorry that I did not clarify it. The three segments I want to extract are: Upper box and insides, lower box and insides, the others (which is the label "Page 123" in that image).
So I guess there may exist a method to recognize the sides of the boxes and perform such segmenting.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is it possible to do auto segmentation?
I don't believe that IM has any such capability right now. I have some scripts that do some similar things, but will not do what you want. At best they might find every white item (if you negate your image). see script separate at the link below.calvi wrote:Hi Anthony,
Sorry that I did not clarify it. The three segments I want to extract are: Upper box and insides, lower box and insides, the others (which is the label "Page 123" in that image).
So I guess there may exist a method to recognize the sides of the boxes and perform such segmenting.