Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Hello, I need to remove a black background while making the edge, which is black/red mixed, semi-red transparent. I don't have other images to work with for masks, etc.. Can this be done with command line ImageMagick?
Use combinations of the red and blue channels for the mask. The red channel is thicker than the blue channel. Get the blue channel. Then get the difference between the red and blue channels, which corresponds to the red outline region. This will be ramped as the red fades to black. Add the two results and put that into the alpha channel of your image.
Try this (unix syntax). if on windows remove all the \ and put ^ at the end of each line
What you provided is about as close as I could get from the examples. Unfortunately, the edge has been removed a little, has some black still in it, and is not faded in a transparency way. There should be some way to remove all black, ie the solid background and the influence of it on the edges.
If you know that the background is black, any result should get you back to the original by placing it on a black background. The math for transparency is simple, but it doesn't yield a single solution. For example, your source image composed over a black background will yield the same image since it has no transparency. Here I assume the opposite, that you want the maximum transparency. Anything along this continuum may be chosen, and none may be "correct" because this may be chosen separately for each pixel. Should a 50% red pixel be 100% red and 50% transparent, or 50% red and 0% transparent? Without a mask, or the image also composed over a white background, there is no "correct". I hope this helps.
Since the red fades to black some part of it will be nearly black in the fade and your eyes cannot distinguish it from black. The fade is done via the difference between red and blue, which covers the same area as the red to black fade. You can modify the command to force the fade to be faster in the mask, but then your outline will be thinner.
Try this with some anti-aliasing of the edge at the end
Veerry sweeet, thanks much -all- for your replies and examples. GreenKoopa - it is very close to the original minus the black. It's hard to tell switching between transparent and black background if the Red luminosity/brightness has changed - maybe my eyes aren't that good. Now, a little bash script to convert a multitude.
Thanks again, all the replies and examples help in the learning process.
As my test showed, it is exactly the original minus black. While I preserve hue (this process will work for any color), of course brightness has increased. That is what removing black does. The question was how much black you wanted removed. I removed it all, which I thought was too much but this is the subjective part. It also depends on what you plan on doing with the image next. If you compose the result over black, your original brightness level is restored. If you compose it over white, brightness will be increased further. This is usually the goal of having transparency.
Thanks GreenKoopa, just what I was looking for - "exactly the original minus black". Good to here you confirm. Ya, brightness, hue, or any other potential alterations, I was concerned with for the core extracted image.
Can't give you much, but will definitely give UPs to the ImageMagick and your support when possible. Now, I'm ghosted...