X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fsignature.h;h=204174768a83c3e0ed22a276691afe5e9d22ccb2;hb=eec6d2c37cbcbf9c350aa4ca80e5a316e5144087;hp=868f4d1c8b0aece82eb2b30ad56d953774cb3582;hpb=c08e5b6cf16ac7fdf810a142bf2f1f48951ba3fc;p=libucw.git diff --git a/images/signature.h b/images/signature.h index 868f4d1c..20417476 100644 --- a/images/signature.h +++ b/images/signature.h @@ -1,18 +1,20 @@ #ifndef _IMAGES_SIGNATURE_H #define _IMAGES_SIGNATURE_H -#include "lib/fastbuf.h" - /* Configuration */ 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 uns image_sig_compare_method; +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) */ @@ -20,34 +22,36 @@ struct image_vector { byte f[IMAGE_VEC_F]; /* texture features */ } PACKED; -/* Fetures for image regions (16 bytes) */ +/* Features 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 */ -} PACKED; + 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 */ +}; #define IMAGE_SIG_TEXTURED 0x1 -/* Image signature (11 + len * 16 bytes) */ +/* Image signature (usually 16 + len * 16 bytes) */ struct image_signature { - byte len; /* Number of regions */ + byte len; /* number of regions */ byte flags; /* IMAGE_SIG_xxx */ - byte df; /* Average f dist */ - u16 dh; /* Average h dist */ - struct image_vector vec; /* Combination of all regions... simple signature */ - struct image_region reg[IMAGE_REG_MAX];/* Feature vector for every region */ -} PACKED; + 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 */ +}; struct image_cluster { union { struct { - s32 dot; /* Dot product of the splitting plane */ - byte vec[IMAGE_VEC_F]; /* Normal vector of the splitting plane */ + s32 dot; /* dot product of the splitting plane */ + s8 vec[IMAGE_VEC_F]; /* normal vector of the splitting plane */ }; struct { - u64 pos; /* Cluster size in bytes */ + u64 pos; /* cluster size in bytes */ }; }; }; @@ -55,7 +59,7 @@ struct image_cluster { static inline uns image_signature_size(uns len) { - return 5 + sizeof(struct image_vector) + len * sizeof(struct image_region); + return OFFSETOF(struct image_signature, reg) + len * sizeof(struct image_region); } /* sig-dump.c */ @@ -100,39 +104,11 @@ struct image_sig_data { u32 f[IMAGE_VEC_F]; }; -#define IMAGE_VECTOR_SIZE (sizeof(struct image_vector)) - -static inline uns -bget_image_vector(struct fastbuf *fb, struct image_vector *vec) -{ - breadb(fb, vec, sizeof(*vec)); - return IMAGE_VECTOR_SIZE; -} - -static inline uns -bput_image_vector(struct fastbuf *fb, struct image_vector *vec) -{ - bwrite(fb, vec, sizeof(*vec)); - return IMAGE_VECTOR_SIZE; -} - -static inline uns -bpeek_image_signature(struct fastbuf *fb) -{ - return image_signature_size(bpeekc(fb)); -} - -uns get_image_signature(byte *buf, struct image_signature *sig); -uns put_image_signature(byte *buf, struct image_signature *sig); - -uns bget_image_signature(struct fastbuf *fb, struct image_signature *sig); -uns bput_image_signature(struct fastbuf *fb, struct image_signature *sig); - /* sig-init.c */ -int compute_image_signature(struct image_thread *thread, struct image_signature *sig, struct image *image); +int compute_image_signature(struct image_context *ctx, struct image_signature *sig, struct image *image); -int image_sig_init(struct image_thread *thread, struct image_sig_data *data, struct image *image); +int image_sig_init(struct image_context *ctx, struct image_sig_data *data, struct image *image); void image_sig_preprocess(struct image_sig_data *data); void image_sig_finish(struct image_sig_data *data, struct image_signature *sig); void image_sig_cleanup(struct image_sig_data *data);