Exemplo n.º 1
0
function pHashWithDCT($file)
{
    $hash = array();
    $image = imagecreatefromstring(file_get_contents($file));
    $image = resizetosquare($image, 8);
    $image = grayscale($image);
    $dct = optimizedImgDTC($image);
    foreach ($dct as $key => $val) {
        $avg = array_average($val);
        foreach ($dct[$key] as $bit => $bit_val) {
            if ($bit_val < $avg) {
                array_push($hash, 0);
            } else {
                array_push($hash, 1);
            }
        }
    }
    return $hash;
}
Exemplo n.º 2
0
<!--
    Author: Juan Diego Pérez @pekechis
    E-mail: contact@jdperez.es
    Description: Creating a Function that calculates the average value of an indexed array
    of integer. The function is defined in library.php
    Date: November 2015
    Reference: http://php.net/manual/functions.user-defined.php
               http://php.net/manual/function.include.php
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CALCULATE THE AVERAGE OF AN ARRAY OF INTEGERS</title>
    </head>
  <body>
      <?php 
//Including the file where array_average is defined
include_once "library.php";
//Declaring the array with the data
$data = array(23, 23, 45, 56, 78, 99, 100, 200);
//Printing the average in the screen
echo "The average is:" . array_average($data);
?>
  </body>
</html>
Exemplo n.º 3
0
/**
 * 计算方差
 *
 * @param array $a 数字的数组
 * @return double
 */
function variation_and_standard_deviation(array $a)
{
    if (empty($a)) {
        return FALSE;
    }
    $average = array_average($a);
    //计算平均值
    $i = 0.0;
    foreach ($a as $key => $value) {
        $i += pow($value + 0 - $average, 2);
    }
    return $i / count($a);
}