From 35af723cb390616f2e3d6c35c9758a18630cb928 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Mon, 28 Aug 2006 15:34:30 +0200 Subject: [PATCH] - improvements and corrections in image segmentation --- cf/images | 4 ++-- images/sig-cmp.c | 6 +++--- images/sig-seg.c | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cf/images b/cf/images index 09d148d1..b93744fe 100644 --- a/cf/images +++ b/cf/images @@ -12,10 +12,10 @@ ImageSig { MinWidth 16 MinHeight 16 -PreQuantThresholds 9 100 400 1000 2000 2000 2000 4000 4000 4000 4000 8000 8000 8000 8000 +PreQuantThresholds 9 40 40 100 100 200 200 400 400 800 800 1600 1600 1600 1600 PostQuantMinSteps 2 PostQuantMaxSteps 10 -PostQuantThreshold 2 +PostQuantThreshold 1 TexturedThreshold 0.32 diff --git a/images/sig-cmp.c b/images/sig-cmp.c index 47b9d28f..75b8277d 100644 --- a/images/sig-cmp.c +++ b/images/sig-cmp.c @@ -7,7 +7,7 @@ * of the GNU Lesser General Public License. */ -#define LOCAL_DEBUG +#undef LOCAL_DEBUG #include "lib/lib.h" #include "lib/math.h" @@ -175,9 +175,9 @@ image_signatures_dist_2(struct image_signature *sig1, struct image_signature *si /* Get percentages */ for (i = 0, reg1 = sig1->reg; i < sig1->len; i++, reg1++) - p[i] = reg1->wa; + p[i] = reg1->wb; for (i = 0, reg2 = sig2->reg; i < sig2->len; i++, reg2++) - q[i] = reg2->wa; + q[i] = reg2->wb; /* Sort entries in distance matrix */ image_signatures_dist_2_sort(n, dist); diff --git a/images/sig-seg.c b/images/sig-seg.c index 7e6e09f5..dc445bd9 100644 --- a/images/sig-seg.c +++ b/images/sig-seg.c @@ -68,7 +68,9 @@ static void prequant_finish_region(struct image_sig_region *region) { if (region->count < 2) - memcpy(region->c, region->a, sizeof(region->c)); + { + region->e = 0; + } else { u64 a = 0; @@ -120,13 +122,13 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi DBG("Step... regions_count=%u heap_count=%u region->count=%u, region->e=%u", regions_count, heap_count, region->count, (uns)region->e); if (region->count < 2 || - region->e < image_sig_prequant_thresholds[regions_count - 1] * region->count) + region->e < image_sig_prequant_thresholds[regions_count - 1] * blocks_count) { HEAP_DELMIN(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP); continue; } - /* Select axis to split - the one with maximum covariance */ + /* Select axis to split - the one with maximum average quadratic error */ axis = 0; u64 cov = (u64)region->count * region->c[0] - (u64)region->b[0] * region->b[0]; for (uns i = 1; i < 6; i++) @@ -324,7 +326,7 @@ postquant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_reg if (error > last_error) break; u64 dif = last_error - error; - if (dif * image_sig_postquant_threshold < last_error * 100) + if (dif * image_sig_postquant_threshold < (u64)last_error * 100) break; } } -- 2.39.2