Hello,
This is my first post, I hope to be as concise as I can
I've got a few small points that I got stuck with and will need your help. I took a look at examples unsuccessfully.
1)
I need to select a color from an image and replace everything else with black.
It's pretty much similar to
convert FILE -fuzz 60% -fill black -opaque green FILEOUT
except that instead of replacing the color, I want to keep it and replace everything else.
2)
Is there a nice way to pixelate ( similarly to mode or median ) by limiting the operation on a given color?
Thanks
Luca
keep color instead of replace color
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: keep color instead of replace color
Use the + form of the option. EG: -fill black -fuzz 25% +opaque blueluckyluca wrote:1)
I need to select a color from an image and replace everything else with black.
It's pretty much similar to
convert FILE -fuzz 60% -fill black -opaque green FILEOUT
except that instead of replacing the color, I want to keep it and replace everything else.
If you IM is not modern enough for +opaque (added IM v6.3.7-10) there is a masking method that will also let you do this.
For this and more see
color Basics, Replace a Specific Color (invert color selection example)
http://www.imagemagick.org/Usage/color_basics/#opaque
Color Basics, Fuzz Factor Distance
http://www.imagemagick.org/Usage/color_ ... z_distance
Not directly. For that you will need to generate a mask, and then either use that mask as a 'write mask' or a compose mask for the pixelated form of the image.Is there a nice way to pixelate ( similarly to mode or median ) by limiting the operation on a given color?
For example... Protect Someone's Anonymity -- fuzzing out some part of a photo
http://www.imagemagick.org/Usage/photos/#anonymity
Pixelation can be performed in a number of ways, such as
- scale down and up as in the above
http://www.imagemagick.org/Usage/resize/#scale - Blurring (as shown above
http://www.imagemagick.org/Usage/blur/#blur - morphology Intensity Variant (circular or shaped - non-array pixels
http://www.imagemagick.org/Usage/morphology/#intensity - using -paint
http://www.imagemagick.org/Usage/transform/#paint - Using -statistical mean or -statistic median
your welcome!Thanks
Luca
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: keep color instead of replace color
Thanks Anthony, I'm on windows and can't seem able to find any binary newer than 6.729 though.
In the case of planB (use of older versions of imagemagick) how would the following look like with the old masking method?
convert FILEIN -fill black -fuzz 95% +opaque 'rgb(255, 255,255)' FILEOUT
I now am quite close but I'm not sure where to place -fuzz and whether I need -matte and -transparent in:
convert FILEIN ( +clone -matte -transparent white -fill black -colorize 100% ) -composite FILEOUT
Sorry I'll have to sit down with the example html properly. Thanks for the pixelate headsup I'll look into it.
Thanks
Luca
In the case of planB (use of older versions of imagemagick) how would the following look like with the old masking method?
convert FILEIN -fill black -fuzz 95% +opaque 'rgb(255, 255,255)' FILEOUT
I now am quite close but I'm not sure where to place -fuzz and whether I need -matte and -transparent in:
convert FILEIN ( +clone -matte -transparent white -fill black -colorize 100% ) -composite FILEOUT
Sorry I'll have to sit down with the example html properly. Thanks for the pixelate headsup I'll look into it.
Thanks
Luca
anthony wrote:Use the + form of the option. EG: -fill black -fuzz 25% +opaque blueluckyluca wrote:1)
I need to select a color from an image and replace everything else with black.
It's pretty much similar to
convert FILE -fuzz 60% -fill black -opaque green FILEOUT
except that instead of replacing the color, I want to keep it and replace everything else.
If you IM is not modern enough for +opaque (added IM v6.3.7-10) there is a masking method that will also let you do this.
For this and more see
color Basics, Replace a Specific Color (invert color selection example)
http://www.imagemagick.org/Usage/color_basics/#opaque
Color Basics, Fuzz Factor Distance
http://www.imagemagick.org/Usage/color_ ... z_distance
Not directly. For that you will need to generate a mask, and then either use that mask as a 'write mask' or a compose mask for the pixelated form of the image.Is there a nice way to pixelate ( similarly to mode or median ) by limiting the operation on a given color?
For example... Protect Someone's Anonymity -- fuzzing out some part of a photo
http://www.imagemagick.org/Usage/photos/#anonymity
Pixelation can be performed in a number of ways, such asBasically anything that removes detail, used over a much larger area than normal, could be used!
- scale down and up as in the above
http://www.imagemagick.org/Usage/resize/#scale- Blurring (as shown above
http://www.imagemagick.org/Usage/blur/#blur- morphology Intensity Variant (circular or shaped - non-array pixels
http://www.imagemagick.org/Usage/morphology/#intensity- using -paint
http://www.imagemagick.org/Usage/transform/#paint- Using -statistical mean or -statistic median
your welcome!Thanks
Luca
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: keep color instead of replace color
6.729 is the most current version
It should support all the features Anthony mentioned.
It should support all the features Anthony mentioned.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: keep color instead of replace color
Fred is right that is the latest, so +opaque should work direct. The addition was a VERY long time ago.luckyluca wrote:Thanks Anthony, I'm on windows and can't seem able to find any binary newer than 6.729 though.
In the case of planB (use of older versions of imagemagick) how would the following look like with the old masking method?
convert FILEIN -fill black -fuzz 95% +opaque 'rgb(255, 255,255)' FILEOUT
I now am quite close but I'm not sure where to place -fuzz and whether I need -matte and -transparent in:
convert FILEIN ( +clone -matte -transparent white -fill black -colorize 100% ) -composite FILEOUT
Explanation of alternative method (as a FYI)...
The operator -transparent is similar to opaque. In this case make the matching color transparent. As this is what uses -fuzz the -fuzz should be just before it. The -matte is built in to -transparent so is not needed.
The non-transparent colors are then set to 'black' (the -fill for no-match) and the result composed onto the original image to make non-match black and restore the match colors to there original values.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/