aboutsummaryrefslogtreecommitdiff
path: root/src/image.h
blob: 62a4d2cd56a1ceb328745083d1aa3d1c83244cb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * image.h
 *
 * Handle images and image features
 *
 * (c) 2007-2008 Thomas White <taw27@cam.ac.uk>
 *
 *  dtr - Diffraction Tomography Reconstruction
 *
 */
 
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifndef IMAGE_H
#define IMAGE_H

#include "control.h"

typedef struct imagefeature_struct {

	struct imagerecord_struct	*parent;
	double				x;
	double				y;
	double				intensity;
	
	struct imagefeature_struct	*partner;	/* Partner for this feature (in another feature list) or NULL */
	double				partner_d;	/* Distance between this feature and its partner, if any. */
	
	struct reflection_struct	*reflection;	/* The reflection this was projected from, if any */
	
} ImageFeature;

typedef struct {

	ImageFeature		*features;
	int			n_features;

} ImageFeatureList;

typedef struct imagerecord_struct {

	uint16_t		*image;
	double			tilt;		/* Radians.  Defines where the pattern lies in reciprocal space */
	double			omega;		/* Radians.  Defines where the pattern lies in reciprocal space */
	double			slop;		/* Radians.  Defines where the pattern lies "on the negative" */
	
	FormulationMode		fmode;
	double			pixel_size;
	double			camera_len;
	double			lambda;
	double			resolution;
	
	int			width;
	int			height;
	double			x_centre;
	double			y_centre;
	
	ImageFeatureList	*features;	/* "Experimental" features */
	ImageFeatureList	*rflist;	/* "Predicted" features */

} ImageRecord;

typedef struct imagelist_struct {

	int		n_images;
	ImageRecord	*images;

} ImageList;

#include "reflections.h"

extern ImageList *image_list_new(void);
extern int image_add(ImageList *list, uint16_t *image, int width, int height, double tilt, ControlContext *ctx);
extern ImageFeatureList *image_feature_list_new(void);
extern void image_feature_list_free(ImageFeatureList *flist);
extern void image_add_feature(ImageFeatureList *flist, double x, double y, ImageRecord *parent, double intensity);
extern void image_add_feature_reflection(ImageFeatureList *flist, double x, double y, ImageRecord *parent, double intensity, Reflection *reflection);
extern ImageFeature *image_feature_closest(ImageFeatureList *flist, double x, double y, double *d, int *idx);
extern ImageFeature *image_feature_second_closest(ImageFeatureList *flist, double x, double y, double *d, int *idx);

#endif	/* IMAGE_H */