summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-03 22:21:30 +0100
committerAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-03 22:21:30 +0100
commitddbe05a3b4bd4ec8b195f7526f886896ac0f9610 (patch)
treec6ab66ded1c59235c995184fefedc4e80f2484ba
parent4c496f527292468264900c5800a38c8dce07f918 (diff)
Improve algorithm for max value
-rw-r--r--modules/image/src/img_alx.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/image/src/img_alx.cpp b/modules/image/src/img_alx.cpp
index cb88d5c..093ff69 100644
--- a/modules/image/src/img_alx.cpp
+++ b/modules/image/src/img_alx.cpp
@@ -89,7 +89,6 @@ static void img_alx_local_max (class cv::Mat *imgptr)
int j;
int k;
int l;
- bool local_max;
/* Minimum distance between local maxima */
const int dist_min = 16;
/* Minimum value of local maxima */
@@ -110,30 +109,30 @@ static void img_alx_local_max (class cv::Mat *imgptr)
for (j = 0; j < imgptr->cols; j++) {
img_pix = imgptr->data + i * imgptr->step + j;
tmp_pix = imgtmp.data + i * imgptr->step + j;
- local_max = true;
+ *tmp_pix = 0;
if (*img_pix < val_min) {
- local_max = false;
+ goto next_pixel;
}
- for (k = i - dist_min; (k < i + dist_min+1) && local_max; k++) {
- for (l = j - dist_min; (l < j + dist_min+1) && local_max; l++) {
+ for (k = (i - dist_min); k < (i + dist_min + 1); k++) {
+ for (l = (j - dist_min); l < (j + dist_min + 1); l++) {
near_pix = imgptr->data + k * imgptr->step + l;
if ((k >= 0) && (k < imgptr->rows)) {
if ((l >= 0) && (l < imgptr->cols)) {
if (*img_pix < *near_pix) {
- local_max = false;
+ goto next_pixel;
}
}
}
}
}
- if (local_max) {
- *tmp_pix = *img_pix;
- } else {
- *tmp_pix = 0;
- }
+ *tmp_pix = *img_pix;
+ continue;
+
+next_pixel:
+ *tmp_pix = 0;
}
}
@@ -144,7 +143,7 @@ static void img_alx_local_max (class cv::Mat *imgptr)
static void img_alx_skeleton (class cv::Mat *imgptr)
{
- /* Width of the skeleton */
+ /* (Half of the) width of the skeleton */
const int width = 5;
int dist_x;
int dist_y;