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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/*
* image.h
*
* Handle images and image features
*
* Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
* 2009-2013 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
* CrystFEL is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CrystFEL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef IMAGE_H
#define IMAGE_H
#include <stdint.h>
#include <complex.h>
#include <sys/types.h>
#include "utils.h"
#include "cell.h"
#include "detector.h"
#include "reflist.h"
#include "crystal.h"
#include "index.h"
/* Structure describing a feature in an image */
struct imagefeature {
struct image *parent;
double fs;
double ss;
double intensity;
/* Reciprocal space coordinates (m^-1 of course) of this feature */
double rx;
double ry;
double rz;
/* Internal use only */
int valid;
const char *name;
};
/* An opaque type representing a list of image features */
typedef struct _imagefeaturelist ImageFeatureList;
/**
* image:
*
* <programlisting>
* struct image
* {
* float *data;
* uint16_t *flags;
* double *twotheta;
*
* Crystal **crystals;
* int n_crystals;
* IndexingMethod indexed_by;
*
* struct detector *det;
* struct beam_params *beam;
* char *filename;
* const struct copy_hdf5_field *copyme;
*
* int id;
*
* double lambda;
* double div;
* double bw;
*
* int width;
* int height;
*
* long long int num_peaks;
* long long int num_saturated_peaks;
* ImageFeatureList *features;
* };
* </programlisting>
*
* The field <structfield>data</structfield> contains the raw image data, if it
* is currently available. The data might be available throughout the
* processing of an experimental pattern, but it might not be available when
* simulating, scaling or merging patterns. Similarly,
* <structfield>flags</structfield> contains an array of the same dimensions
* as <structfield>data</structfield> to contain the bad pixel flags.
* <structfield>twotheta</structfield> likewise contains an array of 2*theta
* (scattering angle) values in radians, since these values are generated as a
* by-product of the scattering vector calculation and can be used later for
* calculating intensities from differential scattering cross sections.
*
* <structfield>crystals</structfield> is an array of %Crystal directly
* returned by the low-level indexing system. <structfield>n_crystals</structfield>
* is the number of crystals which were found in the image.
*
* <structfield>copyme</structfield> represents a list of HDF5 fields to copy
* to the output stream.
**/
struct image;
struct image {
float *data;
uint16_t *flags;
double *twotheta;
Crystal **crystals;
int n_crystals;
IndexingMethod indexed_by;
struct detector *det;
struct beam_params *beam; /* The nominal beam parameters */
char *filename;
const struct copy_hdf5_field *copyme;
int id; /* ID number of the thread
* handling this image */
/* Per-shot radiation values */
double lambda; /* Wavelength in m */
double div; /* Divergence in radians */
double bw; /* Bandwidth as a fraction */
int width;
int height;
/* Detected peaks */
long long int num_peaks;
long long int num_saturated_peaks;
ImageFeatureList *features;
};
/* Feature lists */
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,
struct image *parent, double intensity,
const char *name);
extern void image_remove_feature(ImageFeatureList *flist, int idx);
extern struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double fs, double ss,
double *d, int *idx);
extern int image_feature_count(ImageFeatureList *flist);
extern struct imagefeature *image_get_feature(ImageFeatureList *flist, int idx);
extern void image_add_crystal(struct image *image, Crystal *cryst);
#endif /* IMAGE_H */
|