Hello Wolfgang

I believe that you may be able to do this as follows:

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



2 To get the variance you can use the formula:

x=image pixel value

var = ave(x^2) - (ave(x))^2

That is get the average of the square of the image and subtract the square of the average of the image.

This may or may not work due to how IM clips values after each step. You may want to confer with Anthony Thyssen, but here is what I would try, although I don't guarantee anything. This is a multi-step process, but Anthony may be able to help you do it all in one step, if clipping is not a problem.

convert  image.jpg image.jpg -compose multiply -composite imagesquared.jpg
#the above step is where clipping may screw this up
convert imagesquared.jpg -fliter box -resize 128x96 averageimagesquared.jpg
convert average.jpg average.jpg -compose multiply -composite averagesquared.jpg
#the above step is where clipping may screw this up
convert averageimagesquared averagesquared -compose subtract - composite variance.jpg



Fred Weinhaus
My IM scripts are available at http://www.fmwconcepts.com/imagemagick/index.html




Hello,

I would like to average the bit values in the 8x8 cells of a JPEG-coded
photograph:

If the original is, say, 1024 x 768, then I would like to downsize it to
128 x 96 pixels, each of the pixels representing the average value of
one of the original 8x8 JPEG cells.

Can this be achieved by ImageMagick?

And if so: could I also determine the variance in the 8x8 cells?

Greetings from Germany
Wolfgang Hugemann

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to