PHP | Imagick getImageChannelMean() Function

The Imagick::getImageChannelMean() function is an inbuilt function in PHP which is used to get the mean and standard deviation of one or more image channels. It returns an associative array containing the keys as “mean” and value as “standardDeviation”.

Syntax:

array Imagick::getImageChannelMean(int $channel)

Parameters: This function accepts a single parameter $channel which holds the channel constant that is valid for your channel mode. Use bitwise operator to combine more then one channeltype constants.

Exceptions: This function throws ImagickException on error.

Return Value: This function returns TRUE on success.



Below programs illustrate the Imagick::getImageChannelMean() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create new imagick object
$imagick = new Imagick(
  
// Get the mean with CHANNEL constant as 1
// which corresponds to imagick::CHANNEL_RED
$mean = $imagick->getImageChannelMean(1);
  
print_r($mean);
?>

chevron_right


Output:

Array( [mean] => 56510.812968516 [standardDeviation] => 20404.259764873 )

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create new imagick object
$imagick = new Imagick(
  
// Get the mean with CHANNEL constant as 5
// which corresponds to imagick::CHANNEL_MAGENTA
$mean = $imagick->getImageChannelMean(5);
  
print_r($mean);
?>

chevron_right


Output:

Array ( [mean] => 57217.085522456 [standardDeviation] => 18896.296535248 )

Reference: https://www.php.net/manual/en/imagick.getimagechannelmean.php

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.