function _focal_point_smartcrop_get_best_first_area in Focal Point 7
Calculate the best area to use based on its entropy.
1 call to _focal_point_smartcrop_get_best_first_area()
- focal_point_smartcrop_estimation in ./
focal_point.smartcrop.inc - Given an image, use smartcrop to estimate a good focal point.
File
- ./
focal_point.smartcrop.inc, line 92
Code
function _focal_point_smartcrop_get_best_first_area($area_entropies, $target_areas_counts) {
$slices_count = count($area_entropies);
$best_entropy = -1;
for ($i = 0; $i <= $slices_count - $target_areas_counts[0]; $i++) {
for ($j = 0; $j <= $slices_count - $target_areas_counts[1]; $j++) {
$first_area = array(
$i,
$j,
);
$entropy = _focal_point_smartcrop_sum_entropies($area_entropies, $first_area, $target_areas_counts);
if ($entropy > $best_entropy) {
$best_entropy = $entropy;
$best_first_area = $first_area;
}
}
}
return $best_first_area;
}