Page 1 of 1

From blobs to lines

Posted: 2010-08-23T02:59:48-07:00
by LeyreM
Hi, I would like to simplify an image transforming some areas to just simple lines, I mean, obtaining just one line from a one-color blob. I've tried using morphological operations so the blob was reduced several times, but the result is not too clear, it's like some little blobs that makes the sense of making the shape of a line, but it's not a real line.
Does anybody know how I could get this? Thanks!

Re: From blobs to lines

Posted: 2010-08-23T10:20:29-07:00
by fmw42
By "line", do you mean a row of the image or do you mean some linear feature in the image?

Re: From blobs to lines

Posted: 2010-08-23T14:52:35-07:00
by LeyreM
The objective would be to erase everything but the most important pixels of the blobs (the ones that stablish the shape or curvature of the blob), so I could use their coordinates to create a line or an arc, depending on the caracteristics of each blob.

Re: From blobs to lines

Posted: 2010-08-23T15:00:23-07:00
by fmw42
I think you will need to post a link to an example image and describe what you want to extract.

Re: From blobs to lines

Posted: 2010-08-24T02:51:12-07:00
by LeyreM
This is a example of what I would like to extract...

http://s875.photobucket.com/albums/ab31 ... g&newest=1

Then, I would like to obtain only a line from the the several white blobs on the black part of the image (the isolated white blob shouldn't exist).

Re: From blobs to lines

Posted: 2010-08-24T10:16:34-07:00
by fmw42
floodfill the outer white area with black, then threshold to black/white. see http://www.imagemagick.org/Usage/draw/#color

convert line.png -fuzz 70% -fill black -draw "color 0,0 floodfill" -alpha off -threshold 50% line_flood.png

Re: From blobs to lines

Posted: 2010-08-25T02:21:43-07:00
by LeyreM
Thanks, it worked... but it wasn't was I was really looking for.

Even if the line seems quite clear in the image it's not a real line but an amount of blobs. I would like to have just a line (one pixel in each row, connected with the upper and lower-row pixels). I want to make something like an erode but the results are not the best, in fact I would like something like "Thinning down to a Skeleton", but in my version the morphology doesn't exist. Any idea of how solving this?

Re: From blobs to lines

Posted: 2010-08-25T08:39:41-07:00
by fmw42
upgrade your IM so that you can use thinning in -morphology. That is all I can suggest. There are no other thinning type functions in IM. The best you can do is print out all the white pixels and do your own processing external to IM and fit a (straight?) line to the points. Perhaps Anthony who wrote the morphology function may have other ideas.


convert line_flood.png txt:- | grep "white" | sed -n 's/^\(.*,.*\):.*$/\1/p'

Re: From blobs to lines

Posted: 2010-08-25T18:29:39-07:00
by fmw42
FYI: If I use -morphology to close up some gaps and then thin on the processed image from above, this is what I get:

Your input:
http://www.fmwconcepts.com/misc_tests/line.png


convert line.png -fuzz 70% -fill black -draw "color 0,0 floodfill" -alpha off -threshold 50% line_flood.png

http://www.fmwconcepts.com/misc_tests/line_flood.png


convert line_flood.png -morphology close square -morphology Thinning:-1 Skeleton line_flood_close_thin.png

http://www.fmwconcepts.com/misc_tests/l ... e_thin.png

Re: From blobs to lines

Posted: 2010-08-26T05:39:30-07:00
by LeyreM
Thanks for the help, I downloaded the last ImageMagick version so I could use morphology, and I got exactly what I wanted with the comands written by fmw42