Extracting certain unformatted data from each frame of a GIF
Posted: 2012-03-14T14:30:29-07:00
Hello! I'm trying to make a process for generating some simple ambient algorithmic music from (and for) videos I've shot. For the music I'm using something completely different, of course, but I was hoping to use IM to extract the data I plan to use for generating the music. I've been poring over the manuals, but I'm having great trouble wrapping my head around the intricacies of IM.
I'm using the Windows command line. I suppose if I had to I could fetch a linux distro, but I'd rather not.
Here's what I'm trying to do:
I have the video as tiny .gif animations of 32 x 18 pixels and 1 x 1 pixels. From the single pixel file I'd like to generate a text file whose each line contained the following data of one frame. The values should be clean integers (preferably) without any other text. I think I'm actually (almost) successful in this with the following command:
The bigger 32x18 file is a bit more complicated.
1. First decrease the amount of colors to 4.
2. Then, for each frame, the following line in a text file:
Preferably this would be ordered so that the first color had the largest amount of pixels and the last had least pixels. I probably won't need saturation for this one. For the life of me I can't figure this out, but I know IM should be able to handle it quite easily.
I'd very much appreciate help with this!
I'm using the Windows command line. I suppose if I had to I could fetch a linux distro, but I'd rather not.
Here's what I'm trying to do:
I have the video as tiny .gif animations of 32 x 18 pixels and 1 x 1 pixels. From the single pixel file I'd like to generate a text file whose each line contained the following data of one frame.
Code: Select all
HUE SAT LUM
Code: Select all
convert anim.gif -format "%[fx:hue*360] %[fx:saturation*100] %[fx:luminance*100]" info:huesatlum.txt
1. First decrease the amount of colors to 4.
2. Then, for each frame, the following line in a text file:
Code: Select all
COLOR1_AMOUNT COLOR1_HUE COLOR1_LUM COLOR2_AMOUNT COLOR2_HUE COLOR2_LUM COLOR3_AMOUNT COLOR3_HUE COLOR3_LUM COLOR4_AMOUNT COLOR4_HUE COLOR4_LUM
I'd very much appreciate help with this!