Addendum... one way to make a rough guess as to the original color of a anti-aliased pixel (at least for cartoon characters) is to dilate the image once and only deal with a pixel next to pure black in the original image..
Hmmm a fudged (not exact) solution.
boolean mask of all non-black pixels
Code: Select all
convert anime.png -fill white +opaque black boolean_mask.png
Get the 'edge' pixels which should be almost (but all, the anti-aliased pixels)
For example it will fail for thin wedges from her hair.
Code: Select all
convert boolean_mask.png -morphology edgein square edge_mask.png
This last can be improved with a difference image against ANY other background even if that background is unknown!
now dilate colors (actual colors by intensity not channels) to expand 'lighter' colors,
Code: Select all
convert anime.png -morphology dilateI diamond color_dilate.png
and mask compose those over the original to get what should be roughly the right 'edge' color
Code: Select all
convert anime.png color_dilate.png edge_mask.png -composite edge_colored.png
A compare of the original against this last image will show what edges are failing to get color good result.
At this point I quit the attempt, as there were too many problem areas with this image 'shape'.
Get me the image on other backgrounds (any backgrounds) and I will proceed further.