Reputation: 29
I want to convert to white any light shades of grey. I am using '-fuzz 10% -fill white -opaque #efeaee'. The problem is that the fuzz converts other colours other than grey, not just shades of grey (ie light yellow and light green get converted). I have tried to reduce the fuzz and repeat for various versions of grey but it really doesn't work and I'm sure there's a better way?
Upvotes: 0
Views: 273
Reputation: 53174
You can do that in ImageMagick, by converting to HSV colorspace. Then threshold the S and V channels. You want low saturation and high value combined as a mask. Then blend the input and a white image using the mask.
sthresh=10
vthresh=10
convert zelda1.jpg \
\( -clone 0 -fill white -colorize 100 \) \
\( -clone 0 -colorspace HSV -channel 1 -separate +channel -threshold $sthresh% -negate \) \
\( -clone 0 -colorspace HSV -channel 2 -separate +channel -negate -threshold $vthresh% -negate \) \
\( -clone 2,3 -compose multiply -composite -blur 0x1 \) \
-delete 2,3 \
-compose over -composite \
result.png
sthresh is the fuzz value for how close in color it is to white
vthresh is the fuzz value for how close it is in brightness to white
Values of zero mean exactly pure white.
Upvotes: 1