Removing all but one color
Posted: 2007-08-29T06:05:24-07:00
Hello all,
I am fairly new to using the ImageMagick software. I am looking to perform a rather simple task, but after digging through the forum for a couple of hours and trying out several options I have not succeeded in reaching my goal.
My goal:
- I have an image with several colors
- I want to select all pixels of a specific color in the original image (result may be black and white)
- Must be possible to perform this in batch mode
This thread has given me some pointers, but my brain does not cooperate with me understanding it
viewtopic.php?f=10&t=8711
I think the approach should be to create a mask which highlights only the pixels of the specific color (lets say 'red').
I have tried to indicate that 'red' should be the transparency color and then create a mask from that using the matte channel:
From the samples:
convert drawn.png -channel matte -separate +matte matte.png
But my attempts were far from successful.
Hmm, update...! Found this post:
viewtopic.php?p=21394#p21394
convert colorwheel.jpg -matte \
\( +clone -fuzz 30% -transparent blue \) \
-compose DstOut -composite all_blue_colors.png
Which suggests to make all pixels not near the same color of 'red' (in my example) transparent. Although this works, it uses the -fuzz attribute, but I only want to select ONE color. (changing the -fuzz to 1 does not seem to work, 2% does seem to work, but I think too many colors will fall within the range).
My question is:
- Am i on the right track?
- Is there an easier way to do this?
- Or... How do I do this!!!
I am a bit lost at this point... Any help greatly appreciated!
I am fairly new to using the ImageMagick software. I am looking to perform a rather simple task, but after digging through the forum for a couple of hours and trying out several options I have not succeeded in reaching my goal.
My goal:
- I have an image with several colors
- I want to select all pixels of a specific color in the original image (result may be black and white)
- Must be possible to perform this in batch mode
This thread has given me some pointers, but my brain does not cooperate with me understanding it
viewtopic.php?f=10&t=8711
I think the approach should be to create a mask which highlights only the pixels of the specific color (lets say 'red').
I have tried to indicate that 'red' should be the transparency color and then create a mask from that using the matte channel:
From the samples:
convert drawn.png -channel matte -separate +matte matte.png
But my attempts were far from successful.
Hmm, update...! Found this post:
viewtopic.php?p=21394#p21394
convert colorwheel.jpg -matte \
\( +clone -fuzz 30% -transparent blue \) \
-compose DstOut -composite all_blue_colors.png
Which suggests to make all pixels not near the same color of 'red' (in my example) transparent. Although this works, it uses the -fuzz attribute, but I only want to select ONE color. (changing the -fuzz to 1 does not seem to work, 2% does seem to work, but I think too many colors will fall within the range).
My question is:
- Am i on the right track?
- Is there an easier way to do this?
- Or... How do I do this!!!
I am a bit lost at this point... Any help greatly appreciated!