public function analyse()
    {
        $result = [];
        $w = $this->w = imagesx($this->oImg);
        $h = $this->h = imagesy($this->oImg);

        $this->od = new \SplFixedArray ($h * $w * 3);
        $this->aSample = new \SplFixedArray ($h * $w);
        for ($y = 0; $y < $h; $y++)
        {
            for ($x = 0; $x < $w; $x++)
            {
                $p = ($y) * $this->w * 3 + ($x) * 3;
                $aRgb = $this->getRgbColorAt($x, $y);
                $this->od [$p + 1] = $this->edgeDetect($x, $y, $w, $h);
                $this->od [$p] = $this->skinDetect($aRgb [0], $aRgb [1], $aRgb [2], $this->sample($x, $y));
                $this->od [$p + 2] = $this->saturationDetect($aRgb [0], $aRgb [1], $aRgb [2], $this->sample($x, $y));
            }
        }

        $scoreOutput = $this->downSample($this->options ['scoreDownSample']);
        $topScore = -INF;
        $topCrop = null;
        $crops = $this->generateCrops();

        foreach ($crops as &$crop)
        {
            $crop ['score'] = $this->score($scoreOutput, $crop);
            if ($crop ['score'] ['total'] > $topScore)
            {
                $topCrop = $crop;
                $topScore = $crop ['score'] ['total'];
            }
        }

        $result ['topCrop'] = $topCrop;

        if ($this->options ['debug'] && $topCrop)
        {
            $result ['crops'] = $crops;
            $result ['debugOutput'] = $scoreOutput;
            $result ['debugOptions'] = $this->options;
            $result ['debugTopCrop'] = array_merge([], $result ['topCrop']);
        }

        return $result;
    }
public function analyse()
    {
        $result = [];
        $w = $this->w = imagesx($this->oImg);
        $h = $this->h = imagesy($this->oImg);

        $this->od = new \SplFixedArray ($h * $w * 3);
        $this->aSample = new \SplFixedArray ($h * $w);
        for ($y = 0; $y < $h; $y++)
        {
            for ($x = 0; $x < $w; $x++)
            {
                $p = ($y) * $this->w * 3 + ($x) * 3;
                $aRgb = $this->getRgbColorAt($x, $y);
                $this->od [$p + 1] = $this->edgeDetect($x, $y, $w, $h);
                $this->od [$p] = $this->skinDetect($aRgb [0], $aRgb [1], $aRgb [2], $this->sample($x, $y));
                $this->od [$p + 2] = $this->saturationDetect($aRgb [0], $aRgb [1], $aRgb [2], $this->sample($x, $y));
            }
        }

        $scoreOutput = $this->downSample($this->options ['scoreDownSample']);
        $topScore = -INF;
        $topCrop = null;
        $crops = $this->generateCrops();

        foreach ($crops as &$crop)
        {
            $crop ['score'] = $this->score($scoreOutput, $crop);
            if ($crop ['score'] ['total'] > $topScore)
            {
                $topCrop = $crop;
                $topScore = $crop ['score'] ['total'];
            }
        }

        $result ['topCrop'] = $topCrop;

        if ($this->options ['debug'] && $topCrop)
        {
            $result ['crops'] = $crops;
            $result ['debugOutput'] = $scoreOutput;
            $result ['debugOptions'] = $this->options;
            $result ['debugTopCrop'] = array_merge([], $result ['topCrop']);
        }

        return $result;
    }
public function analyse ( ) { $ result = [ ] ; $ w = $ this -> w = imagesx ( $ this -> oImg ) ; $ h = $ this -> h = imagesy ( $ this -> oImg ) ; $ this -> od = new \ SplFixedArray ( $ h * $ w * 3 ) ; $ this -> aSample = new \ SplFixedArray ( $ h * $ w ) ; for ( $ y = 0 ; $ y < $ h ; $ y ++ ) { for ( $ x = 0 ; $ x < $ w ; $ x ++ ) { $ p = ( $ y ) * $ this -> w * 3 + ( $ x ) * 3 ; $ aRgb = $ this -> getRgbColorAt ( $ x , $ y ) ; $ this -> od [ $ p + 1 ] = $ this -> edgeDetect ( $ x , $ y , $ w , $ h ) ; $ this -> od [ $ p ] = $ this -> skinDetect ( $ aRgb [ 0 ] , $ aRgb [ 1 ] , $ aRgb [ 2 ] , $ this -> sample ( $ x , $ y ) ) ; $ this -> od [ $ p + 2 ] = $ this -> saturationDetect ( $ aRgb [ 0 ] , $ aRgb [ 1 ] , $ aRgb [ 2 ] , $ this -> sample ( $ x , $ y ) ) ; } } $ scoreOutput = $ this -> downSample ( $ this -> options [ 'scoreDownSample' ] ) ; $ topScore = - INF ; $ topCrop = null ; $ crops = $ this -> generateCrops ( ) ; foreach ( $ crops as & $ crop ) { $ crop [ 'score' ] = $ this -> score ( $ scoreOutput , $ crop ) ; if ( $ crop [ 'score' ] [ 'total' ] > $ topScore ) { $ topCrop = $ crop ; $ topScore = $ crop [ 'score' ] [ 'total' ] ; } } $ result [ 'topCrop' ] = $ topCrop ; if ( $ this -> options [ 'debug' ] && $ topCrop ) { $ result [ 'crops' ] = $ crops ; $ result [ 'debugOutput' ] = $ scoreOutput ; $ result [ 'debugOptions' ] = $ this -> options ; $ result [ 'debugTopCrop' ] = array_merge ( [ ] , $ result [ 'topCrop' ] ) ; } return $ result ; }
Analyse the image, find out the optimal crop scheme

@return array
Analyse the image find out the optimal crop scheme