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: 12159
- 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: 25562
- 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: 25562
- 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
Re: Fill image with other colors
This function working fine but is there possibility to keep a few colors ?
I use this function like this. I want to keep also colors:
I use this function like this. I want to keep also colors:
Code: Select all
0xBFBF00 rgba(191, 191, 0, 1) ITS YELLOW NOW
0xBF2F2F rgba(191, 47, 47, 1) RED NOW
Code: Select all
$CMD = 'magick ' & $capture_filename & _
' -channel rgba -fuzz 20%' & _ ; close to the target color in RGB space
' -fill none -opaque "rgba(0,164,0,1)"' & _ ; color to keep
' -fill "rgba(255,255,255,1)" +opaque none' & _ ; fill with black what exist
' -trim ' & _ ; trim all borders where is white
' -alpha off ' & $capture_filename
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fill image with other colors
What image? Your original image has no yellow.
Re: Fill image with other colors
its no matter. this red color on ballon could have red yellow or green value. It depends on situation on screen
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fill image with other colors
Create a mask by cloning the image and making the colors you want to preserve transparent. Then extract the alpha channel and negate it. Then put that into the alpha channel of the original
Code: Select all
convert balloons.jpg \
\( +clone \
-fuzz 25% -transparent "rgb(220,0,105)" \
-fuzz 25% -transparent "rgb(0,0,180)" \
-alpha extract -negate \
\) \
-alpha off -compose copy_opacity -composite \
balloons_result.png