]> mj.ucw.cz Git - libucw.git/commitdiff
configurable border bonuses for signature computation
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Sat, 16 Sep 2006 07:33:02 +0000 (09:33 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Sat, 16 Sep 2006 07:33:02 +0000 (09:33 +0200)
cf/images
images/config.c
images/sig-init.c
images/signature.h

index cd7f61ed199a61afbd7830e0cb24db410529eb6a..e27df7049c81b96380da0f68690fb7a315e53ec3 100644 (file)
--- 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
index a992dbb32c101b9583c217e889eddf37cd31c169..3bda5ed6c988b165f6b152c1dba7abf49995d9ce 100644 (file)
@@ -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),
index d829930eeb139498133b878410200cf7f98b30fb..3422c7457c3ddaa66f4c49d264f8b4f1dba7c343 100644 (file)
@@ -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;
index 2b93e32ad2fd80bc59347c0731108b63a4baa767..57867848e3bba1e28e8936748fa62b27c280e662 100644 (file)
@@ -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[];