]> mj.ucw.cz Git - libucw.git/commitdiff
new config file... almost empty yet
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 8 Aug 2006 18:30:15 +0000 (20:30 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 8 Aug 2006 18:30:15 +0000 (20:30 +0200)
cf/images [new file with mode: 0644]
images/Makefile
images/config.c [new file with mode: 0644]
images/sig-init.c
images/signature.h

diff --git a/cf/images b/cf/images
new file mode 100644 (file)
index 0000000..3c1f39b
--- /dev/null
+++ b/cf/images
@@ -0,0 +1,21 @@
+# Configuration of the image library (included by cf/sherlock)
+
+######## General parameters #####################################################
+
+Images {
+}
+
+######## Image signatures #######################################################
+
+ImageSig {
+
+MinWidth       16
+MinHeight      16
+
+}
+
+######## Duplicates finder ######################################################
+
+ImageDup {
+}
+
index 97abc79bd2a4198e1aa4f5d40095367b9d987b9d..e2ab4197a5c26bdc8a0010b3b73ed46356ce90af 100644 (file)
@@ -4,7 +4,7 @@ DIRS+=images
 
 PROGS+=$(addprefix $(o)/images/,image-tool image-dup-test image-sim-test)
 
-LIBIMAGES_MODS=image scale color alpha io-main dup-init dup-cmp sig-dump sig-init sig-cmp object
+LIBIMAGES_MODS=config image scale color alpha io-main dup-init dup-cmp sig-dump sig-init sig-cmp object
 
 LIBIMAGES_LIBS=-lm
 
diff --git a/images/config.c b/images/config.c
new file mode 100644 (file)
index 0000000..6d3c927
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *     Image Library -- Configuration
+ *
+ *     (c) 2006 Pavel Charvat <pchar@ucw.cz>
+ */
+
+#undef LOCAL_DEBUG
+
+#include "lib/lib.h"
+#include "lib/conf.h"
+#include "images/images.h"
+#include "images/signature.h"
+
+#include <string.h>
+
+uns image_sig_min_width;
+uns image_sig_min_height;
+
+static struct cf_section sig_config = {
+  CF_ITEMS{
+    CF_UNS("MinWidth", &image_sig_min_width),
+    CF_UNS("MinHeight", &image_sig_min_height),
+    CF_END
+  }
+};
+
+static void CONSTRUCTOR
+images_init_config(void)
+{
+  cf_declare_section("ImageSig", &sig_config, 0);
+}
index 9c9db6c377d5847873b8cffebc5c9d5826d9286f..9ebd5351bb00b794a46809c3003785397ee01718 100644 (file)
@@ -150,6 +150,7 @@ compute_k_means(struct block *blocks, uns blocks_count, struct region *regions,
 int
 compute_image_signature(struct image_thread *thread, struct image_signature *sig, struct image *image)
 {
+  bzero(sig, sizeof(*sig));
   uns cols = image->cols;
   uns rows = image->rows;
 
@@ -263,6 +264,9 @@ compute_image_signature(struct image_thread *thread, struct image_signature *sig
   sig->vec.f[4] = hl_sum / blocks_count;
   sig->vec.f[5] = hh_sum / blocks_count;
 
+  if (cols < image_sig_min_width || rows < image_sig_min_height)
+    return 1;
+
   /* Quantize blocks to image regions */
   struct region regions[IMAGE_REG_MAX];
   sig->len = compute_k_means(blocks, blocks_count, regions, MIN(blocks_count, IMAGE_REG_MAX));
index 695ca722a257597bfcb4a509fae593d3d0e9fbdd..981e0af1b33ec515d9f50f3c209ff2bdf7578c11 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef _IMAGES_SIGNATURE_H
 #define _IMAGES_SIGNATURE_H
 
+/* Configuration */
+extern uns image_sig_min_width, image_sig_min_height;
+
 #define IMAGE_VEC_F    6
 #define IMAGE_REG_F    IMAGE_VEC_F
 #define IMAGE_REG_H    3