getting all histograms of tiles in one convert
Posted: 2011-02-11T07:55:46-07:00
Hello,
I need to differentiate between the back- and foreground of images to get the most common colors of the centered foreground
neglecting colors at the outer regions if the image.
For this, I need the histogram of each tile in an image. I'm tiling the image in 5x5 subimages and generating the histograms.
Its easy to do in two convert commands.
convert -map netscape: input_image.jpg +gravity -crop 20%x20% input_image_%d.jpg
convert input_image_?.jpg -format "<file>%f</file>\n<histogram>%c</histogram>" histogram:info:-
This generates me a structures output that like
<file>input_image_1.jpg</file>
<histogram>
561: (102, 0, 51) #660033 rgb(102,0,51)
1: (102, 0,102) #660066 rgb(102,0,102)
...
</histogram>
...
Now I want to do the same in one run to avoid the tile files and because I need to spawn processes, and this is quite costy.
I tried:
convert -map netscape: input_image.jpg -crop 21%x21% -format "<tile>%c</tile>" histogram:info:-
Now I'm loosing the information about, which tile which histogram but just rely, that histograms are in the same order as they use to be with the
2 convert method.
is there a way to number or enumerate the histograms appropriately?
Or is there another way to do so?
thanks
nicslos
I need to differentiate between the back- and foreground of images to get the most common colors of the centered foreground
neglecting colors at the outer regions if the image.
For this, I need the histogram of each tile in an image. I'm tiling the image in 5x5 subimages and generating the histograms.
Its easy to do in two convert commands.
convert -map netscape: input_image.jpg +gravity -crop 20%x20% input_image_%d.jpg
convert input_image_?.jpg -format "<file>%f</file>\n<histogram>%c</histogram>" histogram:info:-
This generates me a structures output that like
<file>input_image_1.jpg</file>
<histogram>
561: (102, 0, 51) #660033 rgb(102,0,51)
1: (102, 0,102) #660066 rgb(102,0,102)
...
</histogram>
...
Now I want to do the same in one run to avoid the tile files and because I need to spawn processes, and this is quite costy.
I tried:
convert -map netscape: input_image.jpg -crop 21%x21% -format "<tile>%c</tile>" histogram:info:-
Now I'm loosing the information about, which tile which histogram but just rely, that histograms are in the same order as they use to be with the
2 convert method.
is there a way to number or enumerate the histograms appropriately?
Or is there another way to do so?
thanks
nicslos