hello Im wondering if it is possible to process image in autoit like this
1. firstly there is colorfull wallpaper
2. Fill all colors (exception rose color) - with white
3. Fill rose color with black color
https://imgur.com/a/lFdY26g
Fill image with other colors
-
- Posts: 11216
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Fill image with other colors
Is this a question about ImageMagick? If it is, what version of IM, on what platform? Please link to an image that is relevant to your question.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 24470
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fill image with other colors
try
Since your image is JPG and JPG is lossy compressed, we need to use a fuzz value to allow for variations in your image colors. Also since you have both black and white in your image, we need to use an intermediate color that is not in your image. So here I use none, which means fully transparent (black), reba(0,0,0,0).
So I first change your red color to "none" (transparent black), then change all colors other than "none" to white. Then I turn off the alpha channel leaving black where you had red.
I enabled all the channels including the alpha channel at the beginning since I was going to use "none" as a color. Thus all colors thereafter need to include the alpha channel even if it is opaque (represented by 1).
See
https://imagemagick.org/Usage/color_basics/#replace
https://imagemagick.org/script/color.php
Code: Select all
convert balloon.jpg -channel rgba -fuzz 20% -fill none -opaque "rgba(225,0,66,1)" -fill "rgba(255,255,255,1)" +opaque none -alpha off result result.png
So I first change your red color to "none" (transparent black), then change all colors other than "none" to white. Then I turn off the alpha channel leaving black where you had red.
I enabled all the channels including the alpha channel at the beginning since I was going to use "none" as a color. Thus all colors thereafter need to include the alpha channel even if it is opaque (represented by 1).
See
https://imagemagick.org/Usage/color_basics/#replace
https://imagemagick.org/script/color.php
- fmw42
- Posts: 24470
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fill image with other colors
If using IM 6, use convert. If using IM 7, use magick. Do not use magick convert for IM 7.
My command has a typo. I put an extra "result" in it. Take that out so that
convert balloon.jpg -channel rgba -fuzz 20% -fill none -opaque "rgba(225,0,66,1)" -fill "rgba(255,255,255,1)" +opaque none -alpha off result result.png
becomes
convert balloon.jpg -channel rgba -fuzz 20% -fill none -opaque "rgba(225,0,66,1)" -fill "rgba(255,255,255,1)" +opaque none -alpha off result.png
My command has a typo. I put an extra "result" in it. Take that out so that
convert balloon.jpg -channel rgba -fuzz 20% -fill none -opaque "rgba(225,0,66,1)" -fill "rgba(255,255,255,1)" +opaque none -alpha off result result.png
becomes
convert balloon.jpg -channel rgba -fuzz 20% -fill none -opaque "rgba(225,0,66,1)" -fill "rgba(255,255,255,1)" +opaque none -alpha off result.png