Page 1 of 1
Removing background
Posted: 2008-10-06T15:44:54-07:00
by Jim
I'm sorry if this is more of an image processing question than Imagemagick, per se, but, I have a series of microscope images that have blue spots with a random off-white background. I like the blue spots and want to remove the background so that it's transparent.
The difficulty is that the blue spots are irregular and have a number of different hues. They are diffuse blue at the edges and dark blue in the middle. I haven't found any solutions online for any package. Is there some keyword I should look under?
I'm currently trying convert -fx to see if I can isolate a range of blues, but, so far, I'm not good enough with -fx or maybe I'm trying the wrong tool. Any suggestions?
Re: Removing background
Posted: 2008-10-06T16:16:41-07:00
by fmw42
Jim wrote:I'm sorry if this is more of an image processing question than Imagemagick, per se, but, I have a series of microscope images that have blue spots with a random off-white background. I like the blue spots and want to remove the background so that it's transparent.
The difficulty is that the blue spots are irregular and have a number of different hues. They are diffuse blue at the edges and dark blue in the middle. I haven't found any solutions online for any package. Is there some keyword I should look under?
I'm currently trying convert -fx to see if I can isolate a range of blues, but, so far, I'm not good enough with -fx or maybe I'm trying the wrong tool. Any suggestions?
convert image.png -fuzz XX% -transparent white result.png
Change XX to some percent tolerance for determining a range of values near white to make transparent. XX=0 will make pure white transparent. XX=100 will make the whole image transparent. If you have a better estimate of the background color, substitute that value as "rgb(rr,gg,bb)" with the quotes. You can use rr,gg,bb in range 0-255 or 0-100%. If percent, then include the % symbol with each value for rr,gg,bb. Be sure your result image is png or gif or some other format that supports transparency. Input image can be any type.
see
http://www.imagemagick.org/script/comma ... s.php#fuzz
http://www.imagemagick.org/script/comma ... ransparent
http://imagemagick.org/script/color.php
P.S. You might also want to check out the ImageJ application (
http://rsb.info.nih.gov/ij/), which has many plug-ins especially designed for medical applications (such as microscopy)
Re: Removing background
Posted: 2008-10-06T21:42:52-07:00
by anthony
As you describe images containing only blue and white colors (variable) I would say the easiest is to extract the blue channel, then normalize. After that you can threshold at say 50% (or some other value) to divide the image into a map of blue and white areas.
Experiment.
If you submit a small sample image we could also do some experiments for you too.
This whole process by the way is known as 'segmentation' but is an area IM lacks some direct and specific operators. That doesn't mean it can't do it, just not simply.