From a9a75f5d39bb6ef183f2cfaa1e9dac7fa360f722 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Sat, 16 Sep 2006 09:33:02 +0200 Subject: [PATCH] configurable border bonuses for signature computation --- cf/images | 3 +++ images/config.c | 4 ++++ images/sig-init.c | 6 +++--- images/signature.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cf/images b/cf/images index cd7f61ed..e27df704 100644 --- a/cf/images +++ b/cf/images @@ -17,6 +17,9 @@ PostQuantMinSteps 2 PostQuantMaxSteps 10 PostQuantThreshold 1 +BorderSize 0.2 +BorderBonus 50 + TexturedThreshold 0.32 CompareMethod 2 diff --git a/images/config.c b/images/config.c index a992dbb3..3bda5ed6 100644 --- a/images/config.c +++ b/images/config.c @@ -19,6 +19,8 @@ uns *image_sig_prequant_thresholds; uns image_sig_postquant_min_steps; uns image_sig_postquant_max_steps; uns image_sig_postquant_threshold; +double image_sig_border_size; +int image_sig_border_bonus; double image_sig_textured_threshold; uns image_sig_compare_method; uns image_sig_cmp_features_weights[IMAGE_VEC_F + IMAGE_REG_H]; @@ -31,6 +33,8 @@ static struct cf_section sig_config = { CF_UNS("PostQuantMinSteps", &image_sig_postquant_min_steps), CF_UNS("PostQuantMaxSteps", &image_sig_postquant_max_steps), CF_UNS("PostQuantThreshold", &image_sig_postquant_threshold), + CF_DOUBLE("BorderSize", &image_sig_border_size), + CF_INT("BorderBonus", &image_sig_border_bonus), CF_DOUBLE("TexturedThreshold", &image_sig_textured_threshold), CF_UNS("CompareMethod", &image_sig_compare_method), CF_UNS_ARY("CompareFeaturesWeights", image_sig_cmp_features_weights, IMAGE_VEC_F + IMAGE_REG_H), diff --git a/images/sig-init.c b/images/sig-init.c index d829930e..3422c745 100644 --- a/images/sig-init.c +++ b/images/sig-init.c @@ -192,8 +192,8 @@ image_sig_finish(struct image_sig_data *data, struct image_signature *sig) /* For each region */ u64 w_total = 0; - uns w_border = (MIN(data->cols, data->rows) + 3) / 4; - uns w_mul = 127 * 256 / w_border; + uns w_border = MIN(data->cols, data->rows) * image_sig_border_size; + int w_mul = image_sig_border_bonus * 256 / w_border; for (uns i = 0; i < sig->len; i++) { struct image_sig_region *r = data->regions + i; @@ -221,7 +221,7 @@ image_sig_finish(struct image_sig_data *data, struct image_signature *sig) if (d >= w_border) w_sum += 128; else - w_sum += 128 + (d - w_border) * w_mul / 256; + w_sum += 128 + (int)(w_border - d) * w_mul / 256; } w_total += w_sum; r->w_sum = w_sum; diff --git a/images/signature.h b/images/signature.h index 2b93e32a..57867848 100644 --- a/images/signature.h +++ b/images/signature.h @@ -5,6 +5,8 @@ extern uns image_sig_min_width, image_sig_min_height; extern uns *image_sig_prequant_thresholds; extern uns image_sig_postquant_min_steps, image_sig_postquant_max_steps, image_sig_postquant_threshold; +extern double image_sig_border_size; +extern int image_sig_border_bonus; extern double image_sig_textured_threshold; extern uns image_sig_compare_method, image_sig_cmp_features_weights[]; -- 2.39.2