aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw27@cam.ac.uk>2009-04-09 17:31:30 +0100
committerThomas White <taw27@cam.ac.uk>2009-04-09 17:31:30 +0100
commite472b068cab44e109fdd47f3962ab3a3a76674dd (patch)
treef152e0184a816d5eeca80f4f88fe229b68704e83
parent167eb24cae0c452ec64a182bee27c217722dfdeb (diff)
Add Zaeferrer distance cutoff, whitespace
-rw-r--r--src/itrans-zaefferer.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/itrans-zaefferer.c b/src/itrans-zaefferer.c
index 69d2566..e1b63e9 100644
--- a/src/itrans-zaefferer.c
+++ b/src/itrans-zaefferer.c
@@ -27,89 +27,99 @@ ImageFeatureList *itrans_peaksearch_zaefferer(ImageRecord *imagerecord) {
int width, height;
uint16_t *image;
ImageFeatureList *flist;
-
+
flist = image_feature_list_new();
-
+
image = imagerecord->image;
width = imagerecord->width;
height = imagerecord->height;
-
+
for ( x=1; x<width-1; x++ ) {
for ( y=1; y<height-1; y++ ) {
double dx1, dx2, dy1, dy2;
double dxs, dys;
double grad;
-
+
/* Get gradients */
dx1 = image[x+width*y] - image[(x+1)+width*y];
dx2 = image[(x-1)+width*y] - image[x+width*y];
dy1 = image[x+width*y] - image[(x+1)+width*(y+1)];
dy2 = image[x+width*(y-1)] - image[x+width*y];
-
+
/* Average gradient measurements from both sides */
dxs = ((dx1*dx1) + (dx2*dx2)) / 2;
dys = ((dy1*dy1) + (dy2*dy2)) / 2;
-
+
/* Calculate overall gradient */
grad = dxs + dys;
if ( grad > 400 ) {
-
+
int mask_x, mask_y;
int sx, sy;
double max;
unsigned int did_something = 1;
-
+
mask_x = x;
mask_y = y;
-
+
while ( (did_something) && (distance(mask_x, mask_y, x, y)<50) ) {
-
+
max = image[mask_x+width*mask_y];
did_something = 0;
-
+
for ( sy=biggest(mask_y-PEAK_WINDOW_SIZE/2, 0);
sy<smallest(mask_y+PEAK_WINDOW_SIZE/2, height);
sy++ ) {
-
+
for ( sx=biggest(mask_x-PEAK_WINDOW_SIZE/2, 0);
sx<smallest(mask_x+PEAK_WINDOW_SIZE/2, width);
sx++ ) {
-
+
if ( image[sx+width*sy] > max ) {
max = image[sx+width*sy];
mask_x = sx;
mask_y = sy;
did_something = 1;
}
-
+
}
-
+
}
-
+
}
-
+
if ( !did_something ) {
-
+
double d;
int idx;
-
+
assert(mask_x<width);
assert(mask_y<height);
assert(mask_x>=0);
assert(mask_y>=0);
-
- /* Check for a feature at exactly the same coordinates */
- image_feature_closest(flist, mask_x, mask_y, &d, &idx);
-
+
+ if ( distance(mask_x, mask_y, x, y)
+ > 50.0 ) {
+ printf("Too far\n");
+ continue;
+ }
+
+ /* Check for a feature at exactly the
+ * same coordinates */
+ image_feature_closest(flist, mask_x,
+ mask_y, &d,
+ &idx);
+
if ( d > 1.0 ) {
- image_add_feature(flist, mask_x, mask_y, imagerecord,
- image[mask_x + width*mask_y]);
+ image_add_feature(flist, mask_x,
+ mask_y, imagerecord,
+ image[mask_x + width*mask_y]);
}
-
+
}
-
+
}
}
}
@@ -117,4 +127,3 @@ ImageFeatureList *itrans_peaksearch_zaefferer(ImageRecord *imagerecord) {
return flist;
}
-