Remove black (add transparency)
Remove black (add transparency)
Hi everybody,
Does anybody know if it is possible with imagemagick to remove the black part and that the white stripes also become semi transparent?
I searched, but could not find a 'ready to use' convert command...
Regards,
Marcel
Does anybody know if it is possible with imagemagick to remove the black part and that the white stripes also become semi transparent?
I searched, but could not find a 'ready to use' convert command...
Regards,
Marcel
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Remove black (add transparency)
I can't see your image or otherwise connect to that domain.
Re: Remove black (add transparency)
That is strange. I see the image an i can connect to glitterbase.com
But okay, i uploaded the image to imgur
But okay, i uploaded the image to imgur
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Remove black (add transparency)
Do you want?
- black becomes fully transparent
- white stays white and fully opaque
- grays stay gray and become partially transparent
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Remove black (add transparency)
is this what you want?
convert 6SyqTgj.png \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test1.png
or
This will make the white more opaque by a factor of 2. You can change that value for more opaque if you want.
convert \( 6SyqTgj.png -evaluate multiply 2 \) \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test2.png
I am taking your grayscale image, multiplying it by some factor, then cloning it and filling it completely with white, then putting modified grayscale image into the alpha channel of the white image.
convert 6SyqTgj.png \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test1.png
or
This will make the white more opaque by a factor of 2. You can change that value for more opaque if you want.
convert \( 6SyqTgj.png -evaluate multiply 2 \) \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test2.png
I am taking your grayscale image, multiplying it by some factor, then cloning it and filling it completely with white, then putting modified grayscale image into the alpha channel of the white image.
Re: Remove black (add transparency)
I would like that the black turns transparent and the white becomes semi transparent. (so there is nothing black anymore, just white semi transparent stripes).
*Will try fmw's solution. Did not see that before posting this
*Will try fmw's solution. Did not see that before posting this
Re: Remove black (add transparency)
This left me with an empty canvas
This looks indeed what i want, i will need to play with the multiply (like set it to 3 or higher) to get the correct result.
Thanks a lot fer helping out.
Regards,
Marcel
Code: Select all
convert 6SyqTgj.png \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test1.png
Code: Select all
convert \( 6SyqTgj.png -evaluate multiply 2 \) \( +clone -fill white -colorize 100 \) +swap -alpha off -compose copy_opacity -composite test2.png
Regards,
Marcel
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Remove black (add transparency)
Marcel71,
An alternative to -evaluate multiply is -auto-level, which would apply a multiply of 3.5 in this case.
Fred,
I had a different solution in mind but I only ran into problems. Any insight?
These create proper output as viewed by IM, but GIMP doesn't show a histogram for them, which couldn't be weirder.
Here -colorize removes the alpha, which seems incorrect.
An alternative to -evaluate multiply is -auto-level, which would apply a multiply of 3.5 in this case.
Fred,
I had a different solution in mind but I only ran into problems. Any insight?
These create proper output as viewed by IM, but GIMP doesn't show a histogram for them, which couldn't be weirder.
Code: Select all
convert 6SyqTgj.png -alpha Copy out1.png
convert 6SyqTgj.png -alpha Copy PNG32:out2.png
Code: Select all
convert 6SyqTgj.png -alpha Copy -fill white -colorize 100 out3.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Remove black (add transparency)
That should work, but the alpha channel will only have partial transparency and background will have very dark areas under the transparency. So it will all appear dark.convert 6SyqTgj.png -alpha Copy out1.png
The histogram will have very small bins especially when weighted with the alpha channel. In GIMP histogram change the selector to Alpha and you will see very small bins even in just the alpha channel. Because there is such a large bin at black all the other bins are scaled very small.
But try
convert 6SyqTgj.png -alpha Copy -alpha off -fill white -colorize 100 -alpha on out1.png
That should be the same as my first result which puts a full white image under the alpha channel.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Remove black (add transparency)
You are all making it more complicated than it really is...
Just use it as a transparency mask for a white image... (or black if that is what you want).
you can also level adjust before hand if you like to make the rain streaks stronger.
Just use it as a transparency mask for a white image... (or black if that is what you want).
Code: Select all
convert 6SyqTgj.png -background white -alpha shape rain_overlay.png
Code: Select all
convert 6SyqTgj.png -auto-level -background white -alpha shape rain_overlay.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/