private function _entropy($hist){
        $entropy = 0;
        $hist_size = array_sum($hist['r']) + array_sum($hist['g']) + array_sum($hist['b']);
        foreach($hist['r'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        foreach($hist['g'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        foreach($hist['b'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        return $entropy * -1;
    }
private function _entropy($hist){
        $entropy = 0;
        $hist_size = array_sum($hist['r']) + array_sum($hist['g']) + array_sum($hist['b']);
        foreach($hist['r'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        foreach($hist['g'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        foreach($hist['b'] as $p){
            $p = $p / $hist_size;
            $entropy += $p * log($p, 2);
        }
        return $entropy * -1;
    }
private function _entropy ( $ hist ) { $ entropy = 0 ; $ hist_size = array_sum ( $ hist [ 'r' ] ) + array_sum ( $ hist [ 'g' ] ) + array_sum ( $ hist [ 'b' ] ) ; foreach ( $ hist [ 'r' ] as $ p ) { $ p = $ p / $ hist_size ; $ entropy += $ p * log ( $ p , 2 ) ; } foreach ( $ hist [ 'g' ] as $ p ) { $ p = $ p / $ hist_size ; $ entropy += $ p * log ( $ p , 2 ) ; } foreach ( $ hist [ 'b' ] as $ p ) { $ p = $ p / $ hist_size ; $ entropy += $ p * log ( $ p , 2 ) ; } return $ entropy * - 1 ; }
Calculate entropy based on histogram.

@param array $hist Histogram returned by Image->histogram

@return float|int
Calculate entropy based on histogram .