I'm looking for a efficient and fast method to convert this to 12 different PNGs where each resulting image keeps all pixels of one of the respective unique colors, while converting all the others to transparent pixels.
So far I've come up only with a very slow one (which I could script easily too):
- Determine the exact color values of the 12 unique colors. I could use convert my.png text:- | sort | uniq -c .
- Determine one pixel in the PNG which uses this exact color. I could use convert my.png text:- | grep ${color1} | head -n 1.
- Color-convert all pixels which match 11 other colors to transparent. I could use 12 variants of convert my.png -alpha on -fill none -draw 'color X2,Y2 replace' -draw 'color X3,Y3 replace' -draw [....] -draw 'color X12,Y12 replace' my-output-color1.png
There must be a better, faster method -- one that can do the whole operation in a single command line, preferably.
Here is the list of unique color values in my PNG:
Code: Select all
#10110C
#374344
#463A2B
#544A35
#605E57
#6F7D7C
#857A6B
#947113
#98926D
#A69E95
#BBC0A7
#F3EEE6
Code: Select all
0,0
264,0
457,0
575,4
279,0
283,0
394,5
594,24
577,1
390,0
391,0
395,4