diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-10-14 11:23:41 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-10-14 11:23:41 +0200 |
commit | 58d51685fbaad1cdfce7fcbd15ab70456f9ef328 (patch) | |
tree | 92116bab86b3789259613135913783c664a2124d /src | |
parent | bea1c6e44c2fcce080a1a91c0490f3eb5d01146d (diff) |
Tidy up structure definitions
Make ImageList and ImageFeatureList opaque
Remove image_feature_second_closest
Fix declarations as necessary
Diffstat (limited to 'src')
-rw-r--r-- | src/image.c | 60 | ||||
-rw-r--r-- | src/image.h | 35 |
2 files changed, 30 insertions, 65 deletions
diff --git a/src/image.c b/src/image.c index b3825b38..8780c0dd 100644 --- a/src/image.c +++ b/src/image.c @@ -19,6 +19,20 @@ #include "utils.h" +struct _imagelist +{ + int n_images; + struct image *images; +}; + + +struct _imagefeaturelist +{ + struct imagefeature *features; + int n_features; +}; + + int image_add(ImageList *list, struct image *image) { if ( list->images ) { @@ -60,10 +74,11 @@ void image_add_feature_reflection(ImageFeatureList *flist, double x, double y, { if ( flist->features ) { flist->features = realloc(flist->features, - (flist->n_features+1)*sizeof(ImageFeature)); + (flist->n_features+1) + *sizeof(struct imagefeature)); } else { assert(flist->n_features == 0); - flist->features = malloc(sizeof(ImageFeature)); + flist->features = malloc(sizeof(struct imagefeature)); } flist->features[flist->n_features].x = x; @@ -107,8 +122,9 @@ void image_feature_list_free(ImageFeatureList *flist) } -ImageFeature *image_feature_closest(ImageFeatureList *flist, double x, double y, - double *d, int *idx) +struct imagefeature *image_feature_closest(ImageFeatureList *flist, + double x, double y, + double *d, int *idx) { int i; double dmin = +HUGE_VAL; @@ -136,39 +152,3 @@ ImageFeature *image_feature_closest(ImageFeatureList *flist, double x, double y, *d = +INFINITY; return NULL; } - - -ImageFeature *image_feature_second_closest(ImageFeatureList *flist, - double x, double y, double *d, - int *idx) -{ - int i; - double dmin = +HUGE_VAL; - int closest = 0; - double dfirst; - int idxfirst; - - image_feature_closest(flist, x, y, &dfirst, &idxfirst); - - for ( i=0; i<flist->n_features; i++ ) { - - double d; - - d = distance(flist->features[i].x, flist->features[i].y, x, y); - - if ( (d < dmin) && (i != idxfirst) ) { - dmin = d; - closest = i; - } - - } - - if ( dmin < +HUGE_VAL ) { - *d = dmin; - *idx = closest; - return &flist->features[closest]; - } - - return NULL; - -} diff --git a/src/image.h b/src/image.h index f53f7d92..69b8cc79 100644 --- a/src/image.h +++ b/src/image.h @@ -20,13 +20,15 @@ #include <stdint.h> +/* How is the scaling of the image described? */ typedef enum { FORMULATION_CLEN, FORMULATION_PIXELSIZE } FormulationMode; -typedef struct imagefeature_struct { +/* Structure describing a feature in an image */ +struct imagefeature { struct image *parent; double x; @@ -39,20 +41,12 @@ typedef struct imagefeature_struct { /* Distance between this feature and its partner, if any. */ double partner_d; - /* The reflection this was projected from, if any */ - struct reflection_struct *reflection; - -} ImageFeature; - - -typedef struct { - - ImageFeature *features; - int n_features; - -} ImageFeatureList; +}; +/* An opaque type representing a list of image features */ +typedef struct _imagefeaturelist ImageFeatureList; +/* Structure describing an image */ struct image { uint16_t *data; @@ -84,13 +78,8 @@ struct image { }; - -typedef struct imagelist_struct { - - int n_images; - struct image *images; - -} ImageList; +/* An opaque type representing a list of images */ +typedef struct _imagelist ImageList; extern ImageList *image_list_new(void); @@ -109,11 +98,7 @@ extern void image_add_feature_reflection(ImageFeatureList *flist, struct image *parent, double intensity); -extern ImageFeature *image_feature_closest(ImageFeatureList *flist, - double x, double y, double *d, - int *idx); - -extern ImageFeature *image_feature_second_closest(ImageFeatureList *flist, +extern struct imagefeature *image_feature_closest(ImageFeatureList *flist, double x, double y, double *d, int *idx); |