]> mj.ucw.cz Git - libucw.git/blobdiff - images/sig-txt.c
experiment - store relative centroid position for each image region
[libucw.git] / images / sig-txt.c
index 3673c118703a6223107e4f41622880afbbd4df31..0202e601d2ff294bdb51e48b9884a265abd917f2 100644 (file)
@@ -7,7 +7,7 @@
  *     of the GNU Lesser General Public License.
  */
 
  *     of the GNU Lesser General Public License.
  */
 
-#define LOCAL_DEBUG
+#undef LOCAL_DEBUG
 
 #include "sherlock/sherlock.h"
 #include "images/images.h"
 
 #include "sherlock/sherlock.h"
 #include "images/images.h"
@@ -24,13 +24,19 @@ image_sig_detect_textured(struct image_sig_data *data)
 {
   uns cols = data->cols;
   uns rows = data->rows;
 {
   uns cols = data->cols;
   uns rows = data->rows;
-  uns cell_cols = MIN(cols, MAX_CELLS_COLS);
-  uns cell_rows = MIN(rows, MAX_CELLS_ROWS);
+  uns cell_cols = MIN((cols + 1) / 2, MAX_CELLS_COLS);
+  uns cell_rows = MIN((rows + 1) / 2, MAX_CELLS_ROWS);
   uns cell_x[MAX_CELLS_COLS + 1];
   uns cell_y[MAX_CELLS_ROWS + 1];
   uns i, j;
   u32 cnt[IMAGE_REG_MAX];
 
   uns cell_x[MAX_CELLS_COLS + 1];
   uns cell_y[MAX_CELLS_ROWS + 1];
   uns i, j;
   u32 cnt[IMAGE_REG_MAX];
 
+  if (cell_cols * cell_rows < 4)
+    {
+      DBG("Image is not textured.");
+      return;
+    }
+
   DBG("Detecting textured image... cols=%u rows=%u cell_cols=%u cell_rows=%u", cols, rows, cell_cols, cell_rows);
   
   /* Compute cells boundaries */
   DBG("Detecting textured image... cols=%u rows=%u cell_cols=%u cell_rows=%u", cols, rows, cell_cols, cell_rows);
   
   /* Compute cells boundaries */
@@ -55,7 +61,7 @@ image_sig_detect_textured(struct image_sig_data *data)
       {
        uns cell_area = 0;
         bzero(cnt, data->regions_count * sizeof(u32));
       {
        uns cell_area = 0;
         bzero(cnt, data->regions_count * sizeof(u32));
-       struct image_sig_block *b1 = data->blocks + cell_x[i] + cell_y[i] * cols, *b2;
+       struct image_sig_block *b1 = data->blocks + cell_x[i] + cell_y[j] * cols, *b2;
         for (uns y = cell_y[j]; y < cell_y[j + 1]; y++, b1 += cols)
          {
            b2 = b1;
         for (uns y = cell_y[j]; y < cell_y[j + 1]; y++, b1 += cols)
          {
            b2 = b1;