Crop one color with anti-aliasing pixels

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?".
Post Reply
Posts: 4
Joined: 2016-01-26T09:23:49-07:00
Authentication code: 1151

Crop one color with anti-aliasing pixels

Post by peej »

Hi there, I'm having trouble finding a solution for isolating one color in an image, filling the rest with white, but keeping the anti-aliasing transparent pixels for the selected color.

I've done all kinds of research and tried a bunch of different things, but can't quite get it to work. I'm using version 6.9.3 on linux. Below you'll see the original image, and then the desired result (which I altered in Photoshop): ... eColor.png

The closest solution looks like this:

Code: Select all

convert test-1.png -fill '#ffffff' +opaque '#a6bc15' test_oneColor.png
This certainly isolates the color, but of course it creates an alias edge. I've tried scaling it down a bit to create the anti-aliasing, but it's different from the original anti-aliasing border. I also tried blurring, but again, different from the original anti-aliasing.

I've used -fuzz and got some pretty good results, but I need a solution that doesn't quite know what the best fuzz factor would be.

Is there a new solution in IM7 that can help me determine the correct fuzz factor, or better yet, is there another solution in general for isolating a color with its anti-aliasing intact?

Thanks so much!
Post Reply