1 #ifndef _IMAGES_SIGNATURE_H
2 #define _IMAGES_SIGNATURE_H
5 extern uns image_sig_min_width, image_sig_min_height;
6 extern uns *image_sig_prequant_thresholds;
7 extern uns image_sig_postquant_min_steps, image_sig_postquant_max_steps, image_sig_postquant_threshold;
8 extern double image_sig_border_size;
9 extern int image_sig_border_bonus;
10 extern double image_sig_textured_threshold;
11 extern uns image_sig_compare_method, image_sig_cmp_features_weights[];
14 #define IMAGE_REG_F IMAGE_VEC_F
16 #define IMAGE_REG_MAX 16
18 /* K-dimensional feature vector (6 bytes) */
20 byte f[IMAGE_VEC_F]; /* texture features */
23 /* Fetures for image regions (16 bytes) */
25 byte f[IMAGE_VEC_F]; /* texture features */
26 u16 h[IMAGE_REG_H]; /* shape features */
27 u16 wa; /* normalized area percentage */
28 u16 wb; /* normalized weight */
31 #define IMAGE_SIG_TEXTURED 0x1
33 /* Image signature (11 + len * 16 bytes) */
34 struct image_signature {
35 byte len; /* Number of regions */
36 byte flags; /* IMAGE_SIG_xxx */
37 byte df; /* Average f dist */
38 u16 dh; /* Average h dist */
39 struct image_vector vec; /* Combination of all regions... simple signature */
40 struct image_region reg[IMAGE_REG_MAX];/* Feature vector for every region */
43 struct image_cluster {
46 s32 dot; /* Dot product of the splitting plane */
47 s8 vec[IMAGE_VEC_F]; /* Normal vector of the splitting plane */
50 u64 pos; /* Cluster size in bytes */
56 image_signature_size(uns len)
58 return 5 + sizeof(struct image_vector) + len * sizeof(struct image_region);
63 #define IMAGE_VECTOR_DUMP_MAX (IMAGE_VEC_F * 16 + 1)
64 #define IMAGE_REGION_DUMP_MAX ((IMAGE_REG_F + IMAGE_REG_H) * 16 + 100)
66 byte *image_vector_dump(byte *buf, struct image_vector *vec);
67 byte *image_region_dump(byte *buf, struct image_region *reg);
69 struct image_sig_block {
70 struct image_sig_block *next; /* linked list */
71 u32 x, y; /* block position */
72 byte area; /* block area in pixels (usually 16) */
73 byte region; /* region index */
74 byte v[IMAGE_VEC_F]; /* feature vector */
77 struct image_sig_region {
78 struct image_sig_block *blocks;
87 struct image_sig_data {
89 struct image_sig_block *blocks;
90 struct image_sig_region regions[IMAGE_REG_MAX];
105 int compute_image_signature(struct image_thread *thread, struct image_signature *sig, struct image *image);
107 int image_sig_init(struct image_thread *thread, struct image_sig_data *data, struct image *image);
108 void image_sig_preprocess(struct image_sig_data *data);
109 void image_sig_finish(struct image_sig_data *data, struct image_signature *sig);
110 void image_sig_cleanup(struct image_sig_data *data);
114 void image_sig_segmentation(struct image_sig_data *data);
118 void image_sig_detect_textured(struct image_sig_data *data);
122 uns image_signatures_dist(struct image_signature *sig1, struct image_signature *sig2);
123 uns image_signatures_dist_explain(struct image_signature *sig1, struct image_signature *sig2, void (*msg)(byte *text, void *param), void *param);