-
- /* Convergation cycle */
- for (uns conv_i = 8; ; conv_i--)
- {
- for (r = regions; r != regions_end; r++)
- {
- r->sum_l = r->sum_u = r->sum_v = r->sum_lh = r->sum_hl = r->sum_hh = r->count = 0;
- r->blocks = NULL;
- }
-
- /* Find nearest regions and accumulate averages */
- for (b = blocks; b != blocks_end; b++)
- {
- uns best_d = ~0U;
- struct region *best_r = NULL;
- for (r = regions; r != regions_end; r++)
- {
- uns d =
- dist(r->l, b->l) +
- dist(r->u, b->u) +
- dist(r->v, b->v) +
- dist(r->lh, b->lh) +
- dist(r->hl, b->hl) +
- dist(r->hh, b->hh);
- if (d < best_d)
- {
- best_d = d;
- best_r = r;
- }
- }
- best_r->sum_l += b->l;
- best_r->sum_u += b->u;
- best_r->sum_v += b->v;
- best_r->sum_lh += b->lh;
- best_r->sum_hl += b->hl;
- best_r->sum_hh += b->hh;
- best_r->count++;
- b->next = best_r->blocks;
- best_r->blocks = b;
- }
-
- /* Compute new averages */
- for (r = regions; r != regions_end; r++)
- if (r->count)
- {
- r->l = r->sum_l / r->count;
- r->u = r->sum_u / r->count;
- r->v = r->sum_v / r->count;
- r->lh = r->sum_lh / r->count;
- r->hl = r->sum_hl / r->count;
- r->hh = r->sum_hh / r->count;
- }
-
- if (!conv_i)
- break; // FIXME: convergation criteria
- }
-
- /* Remove empty regions */
- struct region *r2 = regions;
- for (r = regions; r != regions_end; r++)
- if (r->count)
- *r2++ = *r;
- return r2 - regions;
+ data->blocks = xmalloc(data->blocks_count * sizeof(struct image_sig_block));
+ data->area = image->cols * image->rows;
+ DBG("Computing signature for image of %ux%u pixels (%ux%u blocks)",
+ image->cols, image->rows, data->cols, data->rows);
+ return 1;