1 | <?php |
||
16 | class CropEntropy |
||
17 | { |
||
18 | /** |
||
19 | * @var Imagick |
||
20 | */ |
||
21 | protected $image = null; |
||
22 | |||
23 | /** |
||
24 | * CropEntropy constructor |
||
25 | * |
||
26 | * @param Imagick|null $image |
||
27 | */ |
||
28 | public function __construct(Imagick $image = null) |
||
36 | |||
37 | /** |
||
38 | * @return Imagick |
||
39 | */ |
||
40 | public function getImage() |
||
44 | |||
45 | /** |
||
46 | * @param int $width - The width of the region to be extracted |
||
47 | * @param int $height - The height of the region to be extracted |
||
48 | * @param int $x - X-coordinate of the top-left corner of the region to be extracted |
||
49 | * @param int $y -Y-coordinate of the top-left corner of the region to be extracted |
||
50 | * @return CropEntropy |
||
51 | */ |
||
52 | public function getRegion($width, $height, $x, $y) |
||
56 | |||
57 | /** |
||
58 | * Get the area in pixels for this image |
||
59 | * |
||
60 | * @return int |
||
61 | */ |
||
62 | public function area() |
||
67 | |||
68 | /** |
||
69 | * @param CropEntropy $b |
||
70 | * @return int |
||
71 | */ |
||
72 | public function compare(CropEntropy $b) |
||
83 | |||
84 | /** |
||
85 | * Calculate the entropy for this image. |
||
86 | * |
||
87 | * A higher value of entropy means more noise / liveliness / color / business |
||
88 | * |
||
89 | * @return float |
||
90 | * |
||
91 | * @see http://brainacle.com/calculating-image-entropy-with-python-how-and-why.html |
||
92 | * @see http://www.mathworks.com/help/toolbox/images/ref/entropy.html |
||
93 | */ |
||
94 | public function getGrayScaleEntropy() |
||
99 | |||
100 | /** |
||
101 | * |
||
102 | * @param string $axis - must be either 'x' or 'y' |
||
103 | * @param int $sliceSize |
||
104 | * @return int |
||
105 | */ |
||
106 | public function getMidPoint($axis, $sliceSize = 20) |
||
164 | |||
165 | /** |
||
166 | * |
||
167 | * @param ImagickPixel[] $histogram |
||
168 | * @param int $area |
||
169 | * @return float |
||
170 | */ |
||
171 | protected function getEntropy($histogram, $area) |
||
183 | |||
184 | public function getVerticalSlice($x, $sliceSize) |
||
189 | |||
190 | public function getHorizontalSlice($y, $sliceSize) |
||
195 | } |
||
196 |