Page 1 of 1

Convert white to trans. only effect background white

Posted: 2011-07-22T15:24:14-07:00
by jburkhart68
Linux RH 5
IM 6.6.9

I am trying to convert some jpegs and tiffs to .png files. All are on white backgrounds that I need to convert to transparent. I can do it but I need to get tighter in on the image because some have shadows around them. I can adjust the -fuzz but the white part of the image are effected when I increase to over 3% and I need to keep the white within the image boundaries . so far: convert -background transparent -fuzz 3% -transparent white Are there any other commands to use that would keep the image white areas in-tacked?

Thanks a bunch,
Jeff

Re: Convert white to trans. only effect background white

Posted: 2011-07-22T15:42:02-07:00
by fmw42
Post a link to one of your images so others can test. But shadows are hard to deal with. The only other technique is to flood fill with transparency. see http://www.imagemagick.org/Usage/draw/#matte

Also -background transparent won't do anything in your command.

Re: Convert white to trans. only effect background white

Posted: 2011-07-22T15:52:58-07:00
by jburkhart68
Opps I meant to take that out.
Links:
http://dl.dropbox.com/u/13952031/CHL00031558_Output.png
Notice the white areas of the sign.

http://dl.dropbox.com/u/13952031/CHL000 ... iginal.jpg

Will giver your other command a try.

Thanks Fred!

Re: Convert white to trans. only effect background white

Posted: 2011-07-22T16:16:03-07:00
by fmw42
Looking at your image, floodfill will be tedious as you have to find each white region in between the black bars on the stand.

It is not clear from your discussion above what parts you want to keep white as opposed to increasing the fuzz value.

If you need to preserver the two signs, then create a mask for them. Then process the whole image with an appropriate fuzz value to remove all of what you need ignoring that you change your sign. Then composite the original with the modified image using the mask to protect/preserve your signs in the composite. You may have to draw the mask manually.

Re: Convert white to trans. only effect background white

Posted: 2011-07-22T16:31:37-07:00
by jburkhart68
Geez I didn't think about in between the bars, which means I am between a rock and a hard place. Have too many to make a mask for each. Need to see how many are effected.

Thanks again,
Jeff

Re: Convert white to trans. only effect background white

Posted: 2011-07-22T16:33:59-07:00
by fmw42
jburkhart68 wrote:Geez I didn't think about in between the bars, which means I am between a rock and a hard place. Have too many to make a mask for each. Need to see how many are effected.

Thanks again,
Jeff

That is the case for floodfill. But see my additional notes about making a binary mask for your signs (white) and everything else black. Then process the image with a larger fuzz value (as appropriate) ignoring the effect on the signs. Then composite the two images together using the mask to keep the signs from the original and rest from the image made transparent from using -fuzz XX% -transparent white