[magick-users] RE: Averaging 8x8 blocks (Wolfgang Hugemann)

Wolfgang Hugemann Auto at Hugemann.de
Mon Sep 24 04:11:24 PDT 2007


Sorry for responding so slowly. I have been out of office for some days.

> 1. To get the 8x8 downsized block average of the pixel values in an 
> image do the following:
> 
> convert image.jpg -filter box -resize 128x96 average.jpg

This works fine and on JPEGs with arbitrary size when using 12.5% as 
Anthony proposed.

> 2 To get the variance you can use the formula:
> x=image pixel value
> var = ave(x^2) - (ave(x))^2

As you have indicated, this approach does not work, due to clipping. 
This may get solved if I could somehow tell IM to use 16bit color depth 
when performing this operation.

I presume that MIFF is capable of storing 16bit color depth, as well as 
TIFF. So it is probably recommendable to store the intermediate results 
either as MIFF or TIFF.

But I couldn't convince IM to use 16 bit color depth. I tried to apply 
the option "-storage-type long" but it wasn't recognized.

Any ideas on the solution? BTW: How do I find out about the maximum 
color depth that can be handelt by my IM version?

Greetings from Germany
Wolfgang Hugemann


More information about the Magick-users mailing list