Imagick::getImageChannelStatistics

(PECL imagick 2, PECL imagick 3)

Imagick::getImageChannelStatistics β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ статистику для ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΊΠ°Π½Π°Π»Π° изобраТСния

ОписаниС

public function Imagick::getImageChannelStatistics(): array

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ статистику для ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΊΠ°Π½Π°Π»Π° изобраТСния. Бтатистика Π²ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ Π³Π»ΡƒΠ±ΠΈΠ½Ρƒ ΠΊΠ°Π½Π°Π»Π°, Π΅Π³ΠΎ ΠΌΠΈΠ½ΠΈΠΌΡƒΠΌΡ‹ ΠΈ максимумы, срСднСС ΠΈ стандартноС ΠΎΡ‚ΠΊΠ»ΠΎΠ½Π΅Π½ΠΈΠ΅.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

Π‘ΠΈΠ³Π½Π°Ρ‚ΡƒΡ€Π° Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ Π½Π΅ содСрТит ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ².

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Ѐункция Π² случаС ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎΠΉ Ρ€Π°Π±ΠΎΡ‚Ρ‹ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ true.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
0
holdoffhunger at gmail dot com ΒΆ
14 years ago
The ImageMagick function 'getImageChannelStatistics' returns an array of arrays.  The first array has keys with values set to 0, 1, 2, 4, 8, and 32.  Each of these arrays, in turn, has five values, mean, minima, maxima, standard deviation, and depth.  A sample print_r of the array produces...

Array
(
    [0] => Array
        (
            [mean] => 0
            [minima] => 1.0E+37
            [maxima] => -1.0E-37
            [standardDeviation] => 0
            [depth] => 1
        )

    [1] => Array
        (
            [mean] => 13215.2836185
            [minima] => 0
            [maxima] => 65535
            [standardDeviation] => 19099.2202751
            [depth] => 8
        )

[etc., etc..]
}

What does each 0, 1, 2, etc., value mean for the keys?  Those are shared, evaluated values of the ImageMagick Channel Constants.  You have the channel constant values that look like imagick::CHANNEL_UNDEFINED, with "_VALUE" values of: undefined, red, gray, cyan, green, magenta, blue, yellow, alpha, opacity, matte, black, index, all, and default.  If you actually print out these constants, you get '0' for undefined, '1' for red, gray, and cyan, '2' for green and magenta, '4' for blue and yellow, and '8' for alpha, opacity, and matte, or '32' for black and index.  Why do multiple channels share the same evaluated integer values?  That's because they're colors from different color spaces, with Red/Green/Blue being the RGB spectrum, Cyan/Magenta/Yellow/blacK being the CMYK spectrum, etc., etc..  If you want to get the statistical result values for Cyan or Red, you'll be accessing the same channel keys.

There are five values produced for each color channel.  The element values for the keys 'mean' and 'standardDeviation' are the results from the getImageChannelMean function.  The element values for the keys 'minima' and 'maxima' are the results from the getChannelRange function.  And the element values for the key 'depth' is the result from the getImageChannelDepth function.  All of these values can be useful in terms of measuring the Channel values of a particular image.

And now, some sample code :

<?php

            // Author: holdoffhunger@gmail.com

        // Create Imagick Object
        // ---------------------------------------------
    
    $imagick_type = new Imagick();
    
        // Filename to Open
        // ---------------------------------------------

    $file_to_grab_with_location = "image_workshop_directory/test.bmp";
    
        // Open File
        // ---------------------------------------------
            
    $file_handle_for_viewing_image_file = fopen($file_to_grab_with_location, 'a+');

        // Read File
        // ---------------------------------------------

    $imagick_type->readImageFile($file_handle_for_viewing_image_file);

        // Get Statistics
        // ---------------------------------------------
                
    $imagick_type_channel_statistics = $imagick_type->getImageChannelStatistics();

        // Print Statistics
        // ---------------------------------------------

    print_r($imagick_type_channel_statistics);

?>