Problem with +transparent and +opaque
Posted: 2013-04-02T21:27:18-07:00
I'm sure I've missed something obvious, but I've reread what I believe to be the relevant sections of the documentation several times and can't see what I'm missing.
I want to remove all colors except one from an image. I'm not looking to make use of or retain any geometrical information, I simply want all pixels that are the designated color to stay that color and all other pixels to be go away (ideally become transparent, but I'd settle for setting them all to white or black.)
The end game here is that I want create a sequence of frames that will become a movie of creating the original image one color at a time. The movie will start out with a black screen and pixels of the original image will appear one color per frame. Each frame of the movie will add all the pixels of a single color to the image of the previous frame.
The problem I'm running into is that neither +transparent nor +opaque seem to be working as described in the instructions. I'm running Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
on CentOS 6.4 64 bit.
As you can see I'm ending up with an image with a bunch of colors in it. What I'm expecting in the histogram after using +opaque is an image with exactly two colors, 1) the color I specified with +opaque and 2) the fill color. Why am I getting a bunch of other colors and not getting my designated color?
I want to remove all colors except one from an image. I'm not looking to make use of or retain any geometrical information, I simply want all pixels that are the designated color to stay that color and all other pixels to be go away (ideally become transparent, but I'd settle for setting them all to white or black.)
The end game here is that I want create a sequence of frames that will become a movie of creating the original image one color at a time. The movie will start out with a black screen and pixels of the original image will appear one color per frame. Each frame of the movie will add all the pixels of a single color to the image of the previous frame.
The problem I'm running into is that neither +transparent nor +opaque seem to be working as described in the instructions. I'm running Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
on CentOS 6.4 64 bit.
Code: Select all
$ convert input.jpg -define histogram:unique-colors=true -format %c histogram:info:- |grep "#1A1414"
22: ( 26, 20, 20) #1A1414 rgb(26,20,20)
$ convert input.jpg -fill none +opaque "#1A1414" output.jpg
$ convert output.jpg -define histogram:unique-colors=true -format %c histogram:info:-
704072: ( 0, 0, 0) #000000 black
224: ( 1, 1, 1) #010101 rgb(1,1,1)
85: ( 2, 2, 2) #020202 rgb(2,2,2)
45: ( 3, 3, 3) #030303 grey1
24: ( 4, 4, 4) #040404 rgb(4,4,4)
17: ( 5, 5, 5) #050505 grey2
7: ( 6, 6, 6) #060606 rgb(6,6,6)
9: ( 7, 7, 7) #070707 rgb(7,7,7)
4: ( 8, 8, 8) #080808 grey3
3: ( 9, 9, 9) #090909 rgb(9,9,9)
1: ( 11, 11, 11) #0B0B0B rgb(11,11,11)
1: ( 12, 12, 12) #0C0C0C rgb(12,12,12)
1: ( 13, 13, 13) #0D0D0D grey5
3: ( 14, 14, 14) #0E0E0E rgb(14,14,14)
2: ( 15, 15, 15) #0F0F0F grey6
1: ( 16, 16, 16) #101010 rgb(16,16,16)
4: ( 17, 17, 17) #111111 rgb(17,17,17)
3: ( 18, 18, 18) #121212 grey7
3: ( 20, 20, 20) #141414 grey8
1: ( 22, 22, 22) #161616 rgb(22,22,22)
1: ( 25, 25, 25) #191919 rgb(25,25,25)
1: ( 26, 26, 26) #1A1A1A grey10
$ rm output.jpg
$ convert input.jpg -fill white +opaque "#1A1414" output.jpg
$ convert output.jpg -define histogram:unique-colors=true -format %c histogram:info:-
2: ( 16, 16, 16) #101010 rgb(16,16,16)
1: ( 18, 18, 18) #121212 grey7
4: ( 19, 19, 19) #131313 rgb(19,19,19)
6: ( 20, 20, 20) #141414 grey8
2: ( 21, 21, 21) #151515 rgb(21,21,21)
5: ( 22, 22, 22) #161616 rgb(22,22,22)
1: ( 23, 23, 23) #171717 grey9
1: ( 26, 26, 26) #1A1A1A grey10
3: (247,247,247) #F7F7F7 grey97
5: (248,248,248) #F8F8F8 rgb(248,248,248)
8: (249,249,249) #F9F9F9 rgb(249,249,249)
24: (250,250,250) #FAFAFA grey98
57: (251,251,251) #FBFBFB rgb(251,251,251)
93: (252,252,252) #FCFCFC grey99
167: (253,253,253) #FDFDFD rgb(253,253,253)
194: (254,254,254) #FEFEFE rgb(254,254,254)
703939: (255,255,255) #FFFFFF white