//Hopefully this is the right section, if not - please move it and I am sorry!:)
Good day everyone!
Since this is my first post, I must say that I am happy to be here and I am deeply thankful to ImageMagick and all they've done!
You guys seem to be a great community so I'll try my luck and see if I can get any of that "goodness":
I've ran into a problem where by replacing a color in an image (Very minimalistic image):
The colors overlap with each other at the edges, since they're not perfect lines, they create "low opacity pixels"(On borders) in order to create smooth lines but when I recolor..there's the problem.
Here is what I mean:
Zoomed In: vs.
You can clearly, clearly see the difference at both zoomed in and zoomed out.
Fuzz Seems to solve the problem, but not quite..I got the Fuzz value to 11, it the colors somehow but left really bad pixels behind. (Now the lines are all edgy, not smooth anymore, as you can see in the picture.)
So, I ask, is there any way I can play with anything in order to achieve that smoothness?
(Please note this problem doesn't appear on pixel perfect icons.)
I very much appreciate your help!
Problems with fuzz and overlapping colors.
-
- Posts: 1
- Joined: 2013-09-07T14:36:13-07:00
- Authentication code: 6789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with fuzz and overlapping colors.
try recoloring hue ranges rather than colors ranges. you can convert to hue via
convert image -colorspace HSL -channel R -separate +channel image_hue_channel.png
Then get the histogram of the hue image and find your ranges of hues
convert image_hue_channel.png -depth 8 -format "%c" histogram:info:
see my script, huemap, for example at the link below. gimp has an interactive version called rotatecolors, as I recall.
also perhaps my isolatecolor script will give you a clue how to select hues
convert image -colorspace HSL -channel R -separate +channel image_hue_channel.png
Then get the histogram of the hue image and find your ranges of hues
convert image_hue_channel.png -depth 8 -format "%c" histogram:info:
see my script, huemap, for example at the link below. gimp has an interactive version called rotatecolors, as I recall.
also perhaps my isolatecolor script will give you a clue how to select hues
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problems with fuzz and overlapping colors.
@basementlover: It would be helpful if you told us the exact commands you used.
I suspect you used something like ...
... with or without fuzz. The problem, as you have discovered, is that the operation is binary, even when using fuzz. A pixel is either changed to the new colour or it isn't. But you don't want this, because you want to retain the antialiasing at the colour boundaries.
A different approach is: The input image has essentially three colours: a reddish background (#do3838), with overlays that are yellowish (#ffcd39) and blackish (#360e13). For each pixel, we can find the distance in RGB space from yellowish and blackish, and use these values as transparency for overlaying the new colours.
Windows script:
This could be combined into a single command, without needing to find the dimensions. The result has no "wrong" colours, and antialiases at the boundaries.
It may be better to do the difference in another colorspace (such as RGB or HLS), and the "-level 0,40%%", which isolates the colour, could be more intelligent.
I suspect you used something like ...
Code: Select all
convert wildland_firefighter_gear_1x.png -fill {newcolour} -opaque {oldcolour} out.png
A different approach is: The input image has essentially three colours: a reddish background (#do3838), with overlays that are yellowish (#ffcd39) and blackish (#360e13). For each pixel, we can find the distance in RGB space from yellowish and blackish, and use these values as transparency for overlaying the new colours.
Windows script:
Code: Select all
%IM%convert wildland_firefighter_gear_1x.png ^
( +clone -fill #ffcd39 -colorize 100 ) ^
-compose Difference -composite ^
-modulate 100,0,100 ^
-level 0,40%% ^
-negate ^
ffYellow.png
%IM%convert wildland_firefighter_gear_1x.png ^
( +clone -fill #360e13 -colorize 100 ) ^
-compose Difference -composite ^
-modulate 100,0,100 ^
-level 0,40%% ^
-negate ^
ffBlack.png
%IM%convert -size 400x300 ^
xc:#606bff ^
( -size 400x300 xc:#62ffa1 ffYellow.png -compose CopyOpacity -composite ) ^
-compose Over -composite ^
( -size 400x300 xc:#330d12 ffBlack.png -compose CopyOpacity -composite ) ^
-compose Over -composite ^
out.png
It may be better to do the difference in another colorspace (such as RGB or HLS), and the "-level 0,40%%", which isolates the colour, could be more intelligent.
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problems with fuzz and overlapping colors.
I should point out that my last command above can be simplified, though the result is not exactly identical:
EDIT: I was forgetting about a bug fix since since 6.8.6-0. In the current version, 6.8.6-9, the result is identical.
Code: Select all
%IM%convert -size 400x300 ^
xc:#606bff ^
xc:#62ffa1 ^
ffYellow.png ^
-composite ^
xc:#330d12 ^
ffBlack.png ^
-composite ^
out2.png
snibgo's IM pages: im.snibgo.com
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Problems with fuzz and overlapping colors.
Can you get the image on two different background colors.
Then you can use a perfect background removal technique.
http://www.imagemagick.org/Usage/maskin ... background
Then you can use a perfect background removal technique.
http://www.imagemagick.org/Usage/maskin ... background
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/