X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=images%2Fsignature.h;h=5e3647d1d02e24d965cae6170ee8f1fc75cc2232;hb=94022b1a1e317871b302946b595b2e890f4f1853;hp=3511f914fbb728a2856562c9ab8c09ed8d3240af;hpb=4bc6b76423665d7bfdf27a372b031a0161876a5f;p=libucw.git diff --git a/images/signature.h b/images/signature.h index 3511f914..5e3647d1 100644 --- a/images/signature.h +++ b/images/signature.h @@ -5,10 +5,16 @@ extern uns image_sig_min_width, image_sig_min_height; extern uns *image_sig_prequant_thresholds; extern uns image_sig_postquant_min_steps, image_sig_postquant_max_steps, image_sig_postquant_threshold; +extern double image_sig_border_size; +extern int image_sig_border_bonus; +extern double image_sig_inertia_scale[]; +extern double image_sig_textured_threshold; +extern int image_sig_compare_method; +extern uns image_sig_cmp_features_weights[]; #define IMAGE_VEC_F 6 #define IMAGE_REG_F IMAGE_VEC_F -#define IMAGE_REG_H 3 +#define IMAGE_REG_H 5 #define IMAGE_REG_MAX 16 /* K-dimensional feature vector (6 bytes) */ @@ -18,25 +24,43 @@ struct image_vector { /* Fetures for image regions (16 bytes) */ struct image_region { - byte f[IMAGE_VEC_F]; /* texture features */ - u16 h[IMAGE_REG_H]; /* shape features */ - u16 wa; /* normalized area percentage */ - u16 wb; /* normalized weight */ + byte f[IMAGE_VEC_F]; /* texture features - L, u, v, LH, HL, HH */ + byte h[IMAGE_REG_H]; /* shape/pos features - I1, I2, I3, X, Y */ + byte wa; /* normalized area percentage */ + byte wb; /* normalized weight */ + byte reserved[3]; } PACKED; -/* Image signature (10 + len * 16 bytes) */ +#define IMAGE_SIG_TEXTURED 0x1 + +/* Image signature (16 + len * 16 bytes) */ struct image_signature { byte len; /* Number of regions */ - byte df; /* average f dist */ - u16 dh; /* average h dist */ - struct image_vector vec; /* Combination of all regions... simple signature */ + byte flags; /* IMAGE_SIG_xxx */ + u16 cols; /* Image width */ + u16 rows; /* Image height */ + u16 df; /* Average weighted f dist */ + u16 dh; /* Average weighted h dist */ + struct image_vector vec; /* Average features of all regions... simple signature */ struct image_region reg[IMAGE_REG_MAX];/* Feature vector for every region */ } PACKED; +struct image_cluster { + union { + struct { + s32 dot; /* Dot product of the splitting plane */ + s8 vec[IMAGE_VEC_F]; /* Normal vector of the splitting plane */ + } PACKED; + struct { + u64 pos; /* Cluster size in bytes */ + } PACKED; + } PACKED; +} PACKED; + static inline uns image_signature_size(uns len) { - return 4 + sizeof(struct image_vector) + len * sizeof(struct image_region); + return OFFSETOF(struct image_signature, reg) + len * sizeof(struct image_region); } /* sig-dump.c */ @@ -48,10 +72,11 @@ byte *image_vector_dump(byte *buf, struct image_vector *vec); byte *image_region_dump(byte *buf, struct image_region *reg); struct image_sig_block { - struct image_sig_block *next; - u32 area; /* block area in pixels (usually 16) */ - u32 v[IMAGE_VEC_F]; - u32 x, y; /* block position */ + struct image_sig_block *next; /* linked list */ + u32 x, y; /* block position */ + byte area; /* block area in pixels (usually 16) */ + byte region; /* region index */ + byte v[IMAGE_VEC_F]; /* feature vector */ }; struct image_sig_region { @@ -72,6 +97,7 @@ struct image_sig_data { u32 rows; u32 full_cols; u32 full_rows; + u32 flags; u32 area; u32 valid; u32 blocks_count; @@ -92,46 +118,14 @@ void image_sig_cleanup(struct image_sig_data *data); void image_sig_segmentation(struct image_sig_data *data); -/* sig-cmp.c */ +/* sig-txt.c */ -#define IMAGE_SIG_DIST_SCALE (3 + 3 + 8 + 16) - -uns image_signatures_dist(struct image_signature *sig1, struct image_signature *sig2); - -#if 0 -/* K-dimensional interval */ -struct image_bbox { - struct image_vector vec[2]; -}; +void image_sig_detect_textured(struct image_sig_data *data); -/* Similarity search tree... will be changed */ -struct image_tree { - uns count; /* Number of images in the tree */ - uns depth; /* Tree depth */ - struct image_bbox bbox; /* Bounding box containing all the */ - struct image_node *nodes; /* Internal nodes */ - struct image_leaf *leaves; /* Leaves */ -}; - -/* Internal node in the search tree */ -#define IMAGE_NODE_LEAF 0x80000000 /* Node contains pointer to leaves array */ -#define IMAGE_NODE_DIM 0xff /* Split dimension */ -struct image_node { - u32 val; -}; - -/* Leaves in the search tree */ -#define IMAGE_LEAF_LAST 0x80000000 /* Last entry in the list */ -#define IMAGE_LEAF_BITS(i) (31 / IMAGE_VEC_K) /* Number of bits for relative position in i-th dimension */ -struct image_leaf { - u32 flags; /* Relative position in bbox and last node flag */ - oid_t oid; -}; +/* sig-cmp.c */ -#define stk_print_image_vector(v) ({ struct image_vector *_v = v; \ - byte *_s = (byte *) alloca(IMAGE_VEC_K * 6), *_p = _s + sprintf(_s, "%d", _v->f[0]); \ - for (uns _i = 1; _i < IMAGE_VEC_K; _i++) _p += sprintf(_p, " %d", _v->f[_i]); _s; }) -#endif +uns image_signatures_dist(struct image_signature *sig1, struct image_signature *sig2); +uns image_signatures_dist_explain(struct image_signature *sig1, struct image_signature *sig2, void (*msg)(byte *text, void *param), void *param); #endif