aboutsummaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-10-14 11:23:41 +0200
committerThomas White <taw@bitwiz.org.uk>2009-10-14 11:23:41 +0200
commit58d51685fbaad1cdfce7fcbd15ab70456f9ef328 (patch)
tree92116bab86b3789259613135913783c664a2124d /src/image.c
parentbea1c6e44c2fcce080a1a91c0490f3eb5d01146d (diff)
Tidy up structure definitions
Make ImageList and ImageFeatureList opaque Remove image_feature_second_closest Fix declarations as necessary
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c60
1 files changed, 20 insertions, 40 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;
-
-}