Fred, I'm using the Perl interface. I now found a bit of code
(prep4photomosaic.pl) that I borrowed a technique from:

    $Geometry = '200x200';
    $image->Scale (geometry => $Geometry);
    $image->Quantize (colorspace => 'RGB');
    $color = join ('',
        meanColor ($image->GetPixels (map => 'r',
        geometry => $Geometry, normalize => 'true')),
        meanColor ($image->GetPixels (map => 'g',
        geometry => $Geometry, normalize => 'true')),
        meanColor ($image->GetPixels (map => 'b',
        geometry => $Geometry, normalize => 'true'))
    );

But your technique, if I'm getting it right, is actually quite brilliant!
You scale it to 1x1, and thus the 1 remaining pixel is, per definition,
the mean value of the original image! Now why didn't I think of that!? :)

Anyway, thank you very much!!

- Mark



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fred Weinhaus
Sent: woensdag 9 april 2008 19:44
To: magick-users@imagemagick.org
Subject: [magick-users] Average color

If you want just the color values, use:

convert image.jpg -scale 1x1! -format "%[pixel:p{0,0}]" info:


If you want to create a 100x100 patch with that color use:

convert lena2.jpg -scale 1x1! -scale 100x100! tmp.png

_______________________________________________
Magick-users mailing list
Magick-users@imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to