Suppose I have a grayscale image with a bunch of disconnected blobs, and all the pixels in a particular blob have the same (non-zero) grayscale value, and each blob has a different grayscale value associated with it. The blobs may have holes in them. Pixels not in a blob have a grayscale value of zero.
I would like an image of the outlines (say 1 pixel wide) of the blobs that preserves the grayscale values, e.g., the pixels for the outline of blob 7 have a grayscale value of 7. Pixels not in an outline should have a grayscale value of zero.
Using convert with "-edge 1" gives me the outlines, but does not preserve the grayscale values. I've searched around for how to do this with masking or compose, but haven't found or figured out a solution. I'm an IM novice.
I'm using IM 6.6.9-7 2012-02-22 Q16 on linux. Thanks for the help.
Image outlines that preserve grayscale values
-
- Posts: 8
- Joined: 2012-07-26T11:24:42-07:00
- Authentication code: 15
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Image outlines that preserve grayscale values
I suggest you use -morphology edgin to get your grayscale edges. -morphology edgein octagon
see
http://www.imagemagick.org/Usage/morphology/#edgein
see
http://www.imagemagick.org/Usage/morphology/#edgein
-
- Posts: 8
- Joined: 2012-07-26T11:24:42-07:00
- Authentication code: 15
Re: Image outlines that preserve grayscale values
That works great, thanks.fmw42 wrote:I suggest you use -morphology edgin to get your grayscale edges. -morphology edgein octagon
see
http://www.imagemagick.org/Usage/morphology/#edgein