Page 1 of 1

problem to get transparency for picture background

Posted: 2014-04-18T04:45:06-07:00
by derilzemer
Hi,

i use multicrop to cut picture from a former plate (thanks to Fred Weinhaus for support)
multicrop -g 5 -f 20 -b "gray(15%)" -m save -p 4 tmp_000.jpg tmp_new.png
After using multicrop i have pictures like this http://derilzemer.de/producer/Testseiten/single_pic.htm
Now i want to remove the background but nothing works for me (probably i do it wrong :( ). Can anyone tell me what i have to do??
for example i use

convert tmp_new.png -alpha set -virtual-pixel transparent -channel A -blur 0x8 -threshold 50% +channel tmp-test.png or
convert tmp-new.png -bordercolor black -border 1 -fuzz 20% -fill none -draw \"matte 0,0 floodfill\" -trim +repage tmp-test.png

but nothing happend. Thanks for your hints

regards
Andreas

Re: problem to get transparency for picture background

Posted: 2014-04-18T09:33:52-07:00
by fmw42
You may need to increase the fuzz value. Note I have removed the escapes on your quotes and it works fine for me on IM 6.8.9.0 Q16 MAC OSX in the command line. What version of IM are your using and what platform? Are you using it in PHP exec()? Does it work in the command line?

Code: Select all

convert tmp-new.png -bordercolor black -border 1 -fuzz 20% -fill none -draw "matte 0,0 floodfill" -trim +repage tmp-test.png

Re: problem to get transparency for picture background

Posted: 2014-04-18T10:06:07-07:00
by derilzemer
Hi Fred,
i use the command line because later i would like to use it with a script. I tested the command and look at the result with with backgound
http://derilzemer.de/producer/Testseiten/single_pic.htm

I would like to use it with a black background then the result look like that

http://derilzemer.de/producer/Testseite ... pic_bb.htm

FYI. If i use the former plate for the scan i use little metal plates to weight the pictures down. This is what you can see in the corners after making transparency.

Regards
Andreas

Re: problem to get transparency for picture background

Posted: 2014-04-18T10:18:56-07:00
by fmw42
try the following using morphology open to remove the thin white lines.

convert tmp-new.png -morphology open diamond:2 \
-bordercolor black -border 1 -fuzz 20% -fill none -draw "matte 0,0 floodfill" -trim +repage tmp-test.png

Re: problem to get transparency for picture background

Posted: 2014-04-18T11:20:08-07:00
by derilzemer
Hi,

okay using this parameter get a strange result :? Corners looking very good but the lettering is crazy
http://derilzemer.de/producer/Testseiten/single_pic.htm

regards
Andreas

Re: problem to get transparency for picture background

Posted: 2014-04-18T11:52:25-07:00
by derilzemer
Hi,
if i use diamond:1 the result is a little bit smoother but also not okay inside the lettering section.
Here is the result http://derilzemer.de/producer/Testseiten/single_pic.htm

regards
Andreas

Re: problem to get transparency for picture background

Posted: 2014-04-18T12:54:40-07:00
by fmw42
Yes, the morphology open will affect the whole image. The only way to treat that is to process only the corners to apply the morphology, then composite the new corners onto the image, then use the floodfill to make it all surrounded by transparency. You can use -region to process each corner or -mask to do all the corners at once without having to crop them out and composite them back. See

http://www.imagemagick.org/script/comma ... php#region
http://www.imagemagick.org/script/comma ... s.php#mask
http://www.imagemagick.org/Usage/masking/#regions
http://www.imagemagick.org/Usage/masking/#write_mask