]> mj.ucw.cz Git - libucw.git/commitdiff
configurable weighted features distance
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Sat, 16 Sep 2006 07:09:18 +0000 (09:09 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Sat, 16 Sep 2006 07:09:18 +0000 (09:09 +0200)
cf/images
images/config.c
images/sig-cmp-gen.h
images/signature.h

index 83b05840424f785b6206aee3066eb1c912fffd72..cd7f61ed199a61afbd7830e0cb24db410529eb6a 100644 (file)
--- a/cf/images
+++ b/cf/images
@@ -21,6 +21,10 @@ TexturedThreshold    0.32
 
 CompareMethod          2
 
+# Array of multiplicative constants in feature vectors distance computation 
+# (L, u, v, LH, HL, HH, H0, H1, H2). Each one must be in range 0..15.
+CompareFeaturesWeights 1 2 2 1 1 1 1 1 1
+
 }
 
 ######## Duplicates finder ######################################################
index 931cc1992f42c844b44a31f9f8e7e0fd35f6812d..a992dbb32c101b9583c217e889eddf37cd31c169 100644 (file)
@@ -21,6 +21,7 @@ uns image_sig_postquant_max_steps;
 uns image_sig_postquant_threshold;
 double image_sig_textured_threshold;
 uns image_sig_compare_method;
+uns image_sig_cmp_features_weights[IMAGE_VEC_F + IMAGE_REG_H];
 
 static struct cf_section sig_config = {
   CF_ITEMS{
@@ -32,6 +33,7 @@ static struct cf_section sig_config = {
     CF_UNS("PostQuantThreshold", &image_sig_postquant_threshold),
     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),
     CF_END
   }
 };
index c6b80195bd1ae959c5f40a6d1309caa65d085791..e6164d536f9ce76caddaa14ae825e408d2312828 100644 (file)
@@ -68,16 +68,16 @@ image_signatures_dist_2_explain(struct image_signature *sig1, struct image_signa
       for (i = 0, reg1 = sig1->reg; i < sig1->len; i++, reg1++)
         {
          uns ds =
-           isqr((int)reg1->h[0] - (int)reg2->h[0]) +
-           isqr((int)reg1->h[1] - (int)reg2->h[1]) +
-           isqr((int)reg1->h[2] - (int)reg2->h[2]);
+           image_sig_cmp_features_weights[6] * isqr((int)reg1->h[0] - (int)reg2->h[0]) +
+           image_sig_cmp_features_weights[7] * isqr((int)reg1->h[1] - (int)reg2->h[1]) +
+           image_sig_cmp_features_weights[8] * isqr((int)reg1->h[2] - (int)reg2->h[2]);
          uns dt =
-           isqr((int)reg1->f[0] - (int)reg2->f[0]) +
-           isqr((int)reg1->f[1] - (int)reg2->f[1]) +
-           isqr((int)reg1->f[2] - (int)reg2->f[2]) +
-           isqr((int)reg1->f[3] - (int)reg2->f[3]) +
-           isqr((int)reg1->f[4] - (int)reg2->f[4]) +
-           isqr((int)reg1->f[5] - (int)reg2->f[5]);
+           image_sig_cmp_features_weights[0] * isqr((int)reg1->f[0] - (int)reg2->f[0]) +
+           image_sig_cmp_features_weights[1] * isqr((int)reg1->f[1] - (int)reg2->f[1]) +
+           image_sig_cmp_features_weights[2] * isqr((int)reg1->f[2] - (int)reg2->f[2]) +
+           image_sig_cmp_features_weights[3] * isqr((int)reg1->f[3] - (int)reg2->f[3]) +
+           image_sig_cmp_features_weights[4] * isqr((int)reg1->f[4] - (int)reg2->f[4]) +
+           image_sig_cmp_features_weights[5] * isqr((int)reg1->f[5] - (int)reg2->f[5]);
          if (ds < 1000)
            dt *= 8;
          else if (ds < 10000)
@@ -95,12 +95,12 @@ image_signatures_dist_2_explain(struct image_signature *sig1, struct image_signa
       for (i = 0, reg1 = sig1->reg; i < sig1->len; i++, reg1++)
         {
          uns dt =
-           isqr((int)reg1->f[0] - (int)reg2->f[0]) +
-           isqr((int)reg1->f[1] - (int)reg2->f[1]) +
-           isqr((int)reg1->f[2] - (int)reg2->f[2]) +
-           isqr((int)reg1->f[3] - (int)reg2->f[3]) +
-           isqr((int)reg1->f[4] - (int)reg2->f[4]) +
-           isqr((int)reg1->f[5] - (int)reg2->f[5]);
+           image_sig_cmp_features_weights[0] * isqr((int)reg1->f[0] - (int)reg2->f[0]) +
+           image_sig_cmp_features_weights[1] * isqr((int)reg1->f[1] - (int)reg2->f[1]) +
+           image_sig_cmp_features_weights[2] * isqr((int)reg1->f[2] - (int)reg2->f[2]) +
+           image_sig_cmp_features_weights[3] * isqr((int)reg1->f[3] - (int)reg2->f[3]) +
+           image_sig_cmp_features_weights[4] * isqr((int)reg1->f[4] - (int)reg2->f[4]) +
+           image_sig_cmp_features_weights[5] * isqr((int)reg1->f[5] - (int)reg2->f[5]);
          dist[n++] = (dt << 12) + i + (j << 4);
          DBG("[%u, %u] dt=%u", i, j, dt);
          MSG("[%u, %u] dt=%u", i, j, dt);
index e84c7f3164fbb01784fb9c527af634756f39b2d7..2b93e32ad2fd80bc59347c0731108b63a4baa767 100644 (file)
@@ -6,7 +6,7 @@ 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_textured_threshold;
-extern uns image_sig_compare_method;
+extern uns image_sig_compare_method, image_sig_cmp_features_weights[];
 
 #define IMAGE_VEC_F    6
 #define IMAGE_REG_F    IMAGE_VEC_F