diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/control.h | 6 | ||||
-rw-r--r-- | src/imagedisplay.c | 30 | ||||
-rw-r--r-- | src/imagedisplay.h | 1 | ||||
-rw-r--r-- | src/ipr.c | 16 | ||||
-rw-r--r-- | src/mapping.c | 2 | ||||
-rw-r--r-- | src/reflections.c | 6 | ||||
-rw-r--r-- | src/reflections.h | 4 | ||||
-rw-r--r-- | src/reproject.c | 21 | ||||
-rw-r--r-- | src/reproject.h | 4 |
9 files changed, 83 insertions, 7 deletions
diff --git a/src/control.h b/src/control.h index 4566315..1952dab 100644 --- a/src/control.h +++ b/src/control.h @@ -59,6 +59,12 @@ typedef struct imagerecord_struct { } ImageRecord; +typedef struct { + int x; + int y; + double intensity; +} ImageReflection; + typedef struct cctx_struct { /* Modes */ diff --git a/src/imagedisplay.c b/src/imagedisplay.c index 6ca646c..9c7aee5 100644 --- a/src/imagedisplay.c +++ b/src/imagedisplay.c @@ -244,3 +244,33 @@ void imagedisplay_mark_point(ImageDisplay *imagedisplay, unsigned int x, unsigne } +void imagedisplay_mark_circle(ImageDisplay *imagedisplay, unsigned int x, unsigned int y) { + + guchar *image_eightbit; + int xd, yd; + int w, h; + + if ( !imagedisplay->pixbuf ) return; + + w = imagedisplay->width; + h = imagedisplay->height; + + g_object_get(G_OBJECT(imagedisplay->pixbuf), "pixels", &image_eightbit, NULL); + + if ( (y >= 0) && (y < h) ) { + for ( xd=biggest(x-3, 0); xd<=smallest(x+3, w-1); xd++ ) { + imagedisplay->data[3*( xd+w*(h-1-y) )] = 0; + imagedisplay->data[3*( xd+w*(h-1-y) )+1] = 255; + imagedisplay->data[3*( xd+w*(h-1-y) )+2] = 0; + } + } + if ( (x >= 0) && (x < w) ) { + for ( yd=biggest(y-3, 0); yd<=smallest(y+3, h-1); yd++ ) { + imagedisplay->data[3*( x+w*(h-1-yd) )] = 0; + imagedisplay->data[3*( x+w*(h-1-yd) )+1] = 255; + imagedisplay->data[3*( x+w*(h-1-yd) )+2] = 0; + } + } + +} + diff --git a/src/imagedisplay.h b/src/imagedisplay.h index 9d75ded..84ffb03 100644 --- a/src/imagedisplay.h +++ b/src/imagedisplay.h @@ -39,6 +39,7 @@ typedef struct struct_imagedisplay { extern ImageDisplay *imagedisplay_open(int16_t *image, unsigned int width, unsigned int height, const char *title); extern void imagedisplay_mark_point(ImageDisplay *imagedisplay, unsigned int x, unsigned int y); +extern void imagedisplay_mark_circle(ImageDisplay *imagedisplay, unsigned int x, unsigned int y); #include "control.h" extern void imagedisplay_add_tilt_axis(ImageDisplay *imagedisplay, ControlContext *ctx, double omega); @@ -232,30 +232,36 @@ static int ipr_random_image(ControlContext *ctx) { int ipr_refine(ControlContext *ctx) { Basis *basis; + ReflectionContext *lat; int finished; basis = ipr_choose_initial_basis(ctx); ctx->reflectionctx->basis = basis; if ( !basis ) return -1; - /* Get rid of the original list and replace it with the prediction list */ - //reflection_clear(ctx->reflectionctx); - //free(ctx->reflectionctx); - //ctx->reflectionctx = ipr_generate(ctx, basis); + lat = ipr_generate(ctx, basis); ctx->reflectionctx->basis = basis; - /* Select an image */ finished = 0; do { int i; + size_t n, j; ImageDisplay *cur; + ImageReflection *refl; + /* Select an image */ i = ipr_random_image(ctx); cur = imagedisplay_open(ctx->images[i].image, ctx->images[i].width, ctx->images[i].height, "Current Image"); + refl = reproject_get_reflections(ctx->images[i], &n, lat); + for ( j=0; j<n; j++ ) { + imagedisplay_mark_circle(cur, refl[j].x, refl[j].y); + } + finished = 1; } while ( !finished ); + reflection_free(lat); return 0; diff --git a/src/mapping.c b/src/mapping.c index adf3205..0a0dcdf 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -65,7 +65,7 @@ ReflectionContext *mapping_create(ControlContext *ctx) { } ctx->x_centre = max_x; ctx->y_centre = max_y; - + /* Display */ sum_id = imagedisplay_open(image_total, twidth, theight, "Sum of All Images"); imagedisplay_mark_point(sum_id, ctx->x_centre, ctx->y_centre); diff --git a/src/reflections.c b/src/reflections.c index c1b557e..03d901b 100644 --- a/src/reflections.c +++ b/src/reflections.c @@ -53,6 +53,12 @@ void reflection_clear(ReflectionContext *reflectionctx) { } +void reflection_free(ReflectionContext *reflectionctx) { + reflection_clear(reflectionctx); + free(reflectionctx->reflections); + free(reflectionctx); +} + void reflection_add(ReflectionContext *reflectionctx, double x, double y, double z, double intensity, ReflectionType type) { Reflection *new_reflection; diff --git a/src/reflections.h b/src/reflections.h index 624c1ce..66b30f8 100644 --- a/src/reflections.h +++ b/src/reflections.h @@ -65,7 +65,8 @@ typedef struct rctx_struct { } ReflectionContext; extern ReflectionContext *reflection_init(void); -void reflection_clear(ReflectionContext *reflectionctx); +extern void reflection_clear(ReflectionContext *reflectionctx); +extern void reflection_free(ReflectionContext *reflectionctx); extern void reflection_add(ReflectionContext *reflectionctx, double x, double y, double z, double intensity, ReflectionType type); extern void reflection_add_index(ReflectionContext *reflectionctx, signed int h, signed int k, signed int l, double intensity, ReflectionType type); @@ -77,3 +78,4 @@ extern void reflection_add_from_reciprocal(ControlContext *ctx, double x, double extern void reflection_add_from_reflection(ReflectionContext *rctx, Reflection *r); #endif /* REFLECTION_H */ + diff --git a/src/reproject.c b/src/reproject.c index ad709d4..f62e8f3 100644 --- a/src/reproject.c +++ b/src/reproject.c @@ -9,4 +9,25 @@ * */ +#include <stdlib.h> + +#include "control.h" +#include "reflections.h" + +#define MAX_IMAGE_REFLECTIONS 1024 + +ImageReflection *reproject_get_reflections(ImageRecord *image, size_t *n, ReflectionContext *ref) { + + ImageReflection *refl; + int i; + + refl = malloc(MAX_IMAGE_REFLECTIONS*sizeof(ImageReflection)); + + i = 0; + + + *n = i; + return refl; + +} diff --git a/src/reproject.h b/src/reproject.h index 482cd8c..c65549c 100644 --- a/src/reproject.h +++ b/src/reproject.h @@ -16,6 +16,10 @@ #ifndef REPROJECT_H #define REPROJECT_H +#include "control.h" +#include "reflections.h" + +extern ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, ReflectionContext *ref); #endif /* REPROJECT_H */ |