From c27ba2060606c7f7677754572042d06f1f81a9fa Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Tue, 8 Aug 2006 20:30:15 +0200 Subject: [PATCH] new config file... almost empty yet --- cf/images | 21 +++++++++++++++++++++ images/Makefile | 2 +- images/config.c | 31 +++++++++++++++++++++++++++++++ images/sig-init.c | 4 ++++ images/signature.h | 3 +++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 cf/images create mode 100644 images/config.c diff --git a/cf/images b/cf/images new file mode 100644 index 00000000..3c1f39b7 --- /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 { +} + diff --git a/images/Makefile b/images/Makefile index 97abc79b..e2ab4197 100644 --- a/images/Makefile +++ b/images/Makefile @@ -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 index 00000000..6d3c927a --- /dev/null +++ b/images/config.c @@ -0,0 +1,31 @@ +/* + * Image Library -- Configuration + * + * (c) 2006 Pavel Charvat + */ + +#undef LOCAL_DEBUG + +#include "lib/lib.h" +#include "lib/conf.h" +#include "images/images.h" +#include "images/signature.h" + +#include + +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); +} diff --git a/images/sig-init.c b/images/sig-init.c index 9c9db6c3..9ebd5351 100644 --- a/images/sig-init.c +++ b/images/sig-init.c @@ -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)); diff --git a/images/signature.h b/images/signature.h index 695ca722..981e0af1 100644 --- a/images/signature.h +++ b/images/signature.h @@ -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 -- 2.39.2