]> mj.ucw.cz Git - libucw.git/blob - images/image-sig.h
small bugfixes about transparency
[libucw.git] / images / image-sig.h
1 #ifndef _IMAGES_IMAGE_SIG_H
2 #define _IMAGES_IMAGE_SIG_H
3
4 #include "images/images.h"
5
6 #define IMAGE_VEC_K     6
7 #define IMAGE_REG_K     9
8 #define IMAGE_REG_MAX   4
9
10 typedef byte image_feature_t;   /* 8 or 16 bits precision */
11
12 /* K-dimensional feature vector */
13 struct image_vector {
14   image_feature_t f[IMAGE_VEC_K];
15 };
16
17 /* K-dimensional interval */
18 struct image_bbox {
19   struct image_vector vec[2];
20 };
21
22 /* Fetures for image regions */
23 struct image_region {
24   image_feature_t f[IMAGE_REG_K];
25 };
26
27 /* Image signature */
28 struct image_signature {
29   struct image_vector vec;      /* Combination of all regions... simplier signature */
30   image_feature_t len;          /* Number of regions */
31   struct image_region reg[IMAGE_REG_MAX];/* Feature vector for every region */
32 };
33
34 /* Similarity search tree... will be changed */
35 struct image_tree {
36   uns count;                    /* Number of images in the tree */
37   uns depth;                    /* Tree depth */
38   struct image_bbox bbox;       /* Bounding box containing all the */
39   struct image_node *nodes;     /* Internal nodes */
40   struct image_leaf *leaves;    /* Leaves */
41 };
42
43 /* Internal node in the search tree */
44 #define IMAGE_NODE_LEAF         0x80000000              /* Node contains pointer to leaves array */
45 #define IMAGE_NODE_DIM          0xff                    /* Split dimension */
46 struct image_node {
47   u32 val;
48 };
49
50 /* Leaves in the search tree */
51 #define IMAGE_LEAF_LAST         0x80000000              /* Last entry in the list */
52 #define IMAGE_LEAF_BITS(i)      (31 / IMAGE_VEC_K)      /* Number of bits for relative position in i-th dimension */
53 struct image_leaf {
54   u32 flags;            /* Relative position in bbox and last node flag */ 
55   oid_t oid;
56 };
57
58 #define stk_print_image_vector(v) ({ struct image_vector *_v = v; \
59     byte *_s = (byte *) alloca(IMAGE_VEC_K * 6), *_p = _s + sprintf(_s, "%d", _v->f[0]); \
60     for (uns _i = 1; _i < IMAGE_VEC_K; _i++) _p += sprintf(_p, " %d", _v->f[_i]); _s; })
61
62 int compute_image_signature(struct image *image, struct image_signature *sig);
63
64 #endif
65