Page 1 of 1
keep color instead of replace color
Posted: 2011-10-04T15:25:36-07:00
by luckyluca
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
Re: keep color instead of replace color
Posted: 2011-10-04T17:38:49-07:00
by anthony
luckyluca 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.
Use the + form of the option. EG:
-fill black -fuzz 25% +opaque blue
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
Is there a nice way to pixelate ( similarly to mode or median ) by limiting the operation on a given color?
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.
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
Basically anything that removes detail, used over a much larger area than normal, could be used!
Thanks
Luca
your welcome!
Re: keep color instead of replace color
Posted: 2011-10-05T08:36:34-07:00
by luckyluca
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
anthony wrote:luckyluca 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.
Use the + form of the option. EG:
-fill black -fuzz 25% +opaque blue
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
Is there a nice way to pixelate ( similarly to mode or median ) by limiting the operation on a given color?
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.
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
Basically anything that removes detail, used over a much larger area than normal, could be used!
Thanks
Luca
your welcome!
Re: keep color instead of replace color
Posted: 2011-10-05T10:07:16-07:00
by fmw42
6.729 is the most current version
It should support all the features Anthony mentioned.
Re: keep color instead of replace color
Posted: 2011-10-05T16:52:23-07:00
by anthony
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
Fred is right that is the latest, so
+opaque should work direct. The addition was a VERY long time ago.
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.