示例#1
0
 /**
  * @since 2.0
  * @param SLIRImage $image
  * @return integer
  */
 public function getCropX(SLIRImage $image)
 {
     return round(($image->getWidth() - $image->getCropWidth()) / 2);
 }
示例#2
0
 /**
  * Calculates and stores requested pixel's Delta E in relation to comparison pixel
  *
  * @since 2.0
  * @param SLIRImage $image
  * @param integer $xA x-axis position of pixel to calculate
  * @param integer $yA y-axis position of pixel to calculate
  * @param integer $xMove number of pixels to move on the x-axis to find comparison pixel
  * @param integer $yMove number of pixels to move on the y-axis to find comparison pixel
  * @return boolean
  */
 private function calculateDelta(SLIRImage $image, $xA, $yA, $xMove, $yMove)
 {
     $xB = $xA + $xMove;
     $yB = $yA + $yMove;
     // Pixel is outside of the image, so we cant't calculate the Delta E
     if ($xB < 0 || $xB >= $image->getWidth() || $yB < 0 || $yB >= $image->getHeight()) {
         return null;
     }
     if (!isset($this->colors[$xA][$yA][self::PIXEL_LAB])) {
         $this->loadPixelInfo($image, $xA, $yA);
     }
     if (!isset($this->colors[$xB][$yB][self::PIXEL_LAB])) {
         $this->loadPixelInfo($image, $xB, $yB);
     }
     $delta = $this->deltaE($this->colors[$xA][$yA][self::PIXEL_LAB], $this->colors[$xB][$yB][self::PIXEL_LAB]);
     $this->colors[$xA][$yA][self::PIXEL_DELTA_E]["d{$xMove}{$yMove}"] = $delta;
     $xBMove = $xMove * -1;
     $yBMove = $yMove * -1;
     $this->colors[$xB][$yB][self::PIXEL_DELTA_E]["d{$xBMove}{$yBMove}"] =& $this->colors[$xA][$yA][self::PIXEL_DELTA_E]["d{$xMove}{$yMove}"];
     return true;
 }