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?".
Hi everyone. I got great help before and I'm in need of a little bit more. This is the current script I call via PHP to remove a white background image and convert the remaining image to a single color.
"-transparent" is a binary operator: each pixel is either changed or it isn't. You could follow this with a blur. Or you could keep the original anti-aliasing, while removing the horrible jpeg noise. Windows BAT syntax:
A anti-aliased shape on a transparent background requires two pieces of knowledge for every pixel.
1/ the true foreground color of the pixel without the backgrounds influence
2/ how transparent the pixel should be.
You can determine 2 if you know the foreground color and the background color, and the two are different.
Well in this image the background is white. that means all the anti-aliasing pixels of the image will be lighter in color than they should be.
Also as the image has no 'border' and a very smooth coloring scheme, you can get an good idea of what the actual forground color is, simply by doing a morphological "Erode" operation, or perhaps a "Intensity_Erode". That is if a pixel is lighter than a neighbour, make it the same color as the neighbour.
Thus you will now have image of the pixels foreground colors, comparing that against the original image to see how much the pixel 'lightened' against a pure white background should let you see how transparent each pixel should be, masked so only pixels next to pure white is made transparent.
That should get you a pretty good transparency mask, which when combined with the foreground colors should get you a good anti-aliased version of the image, on a transparent background.
I am certain it can be worked out (but only for smoothly colored, borderless images on white backgrounds)