diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/image.c | 144 | ||||
-rw-r--r-- | src/image.h | 184 |
2 files changed, 0 insertions, 328 deletions
diff --git a/src/image.c b/src/image.c deleted file mode 100644 index 75a8af0a..00000000 --- a/src/image.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * image.c - * - * Handle images and image features - * - * (c) 2006-2010 Thomas White <taw@physics.org> - * - * Part of CrystFEL - crystallography with a FEL - * - */ - - -#include <stdlib.h> -#include <assert.h> -#include <math.h> -#include <stdio.h> - -#include "image.h" -#include "utils.h" - -/** - * SECTION:image - * @short_description: Data structure representing an image - * @title: Image - * @section_id: - * @see_also: - * @include: "image.h" - * @Image: - * - * The <structname>image</structname> structure represents an image, usually one - * frame from a large series of diffraction patterns, which might be from the - * same or different crystals. - */ - - -struct _imagefeaturelist -{ - struct imagefeature *features; - int n_features; -}; - - -void image_add_feature(ImageFeatureList *flist, double fs, double ss, - struct image *parent, double intensity, const char *name) -{ - if ( flist->features ) { - flist->features = realloc(flist->features, - (flist->n_features+1) - *sizeof(struct imagefeature)); - } else { - assert(flist->n_features == 0); - flist->features = malloc(sizeof(struct imagefeature)); - } - - flist->features[flist->n_features].fs = fs; - flist->features[flist->n_features].ss = ss; - flist->features[flist->n_features].intensity = intensity; - flist->features[flist->n_features].parent = parent; - flist->features[flist->n_features].name = name; - flist->features[flist->n_features].valid = 1; - - flist->n_features++; - -} - - -ImageFeatureList *image_feature_list_new() -{ - ImageFeatureList *flist; - - flist = malloc(sizeof(ImageFeatureList)); - - flist->n_features = 0; - flist->features = NULL; - - return flist; -} - - -void image_feature_list_free(ImageFeatureList *flist) -{ - if ( !flist ) return; - - if ( flist->features ) free(flist->features); - free(flist); -} - - -struct imagefeature *image_feature_closest(ImageFeatureList *flist, - double fs, double ss, - double *d, int *idx) -{ - int i; - double dmin = +HUGE_VAL; - int closest = 0; - - for ( i=0; i<flist->n_features; i++ ) { - - double ds; - - ds = distance(flist->features[i].fs, flist->features[i].ss, - fs, ss); - - if ( ds < dmin ) { - dmin = ds; - closest = i; - } - - } - - if ( dmin < +HUGE_VAL ) { - *d = dmin; - *idx = closest; - return &flist->features[closest]; - } - - *d = +INFINITY; - return NULL; -} - - -int image_feature_count(ImageFeatureList *flist) -{ - if ( flist == NULL ) return 0; - return flist->n_features; -} - - -struct imagefeature *image_get_feature(ImageFeatureList *flist, int idx) -{ - /* Sanity check */ - if ( flist == NULL ) return NULL; - if ( idx > flist->n_features ) return NULL; - - if ( flist->features[idx].valid == 0 ) return NULL; - - return &flist->features[idx]; -} - - -void image_remove_feature(ImageFeatureList *flist, int idx) -{ - flist->features[idx].valid = 0; -} diff --git a/src/image.h b/src/image.h deleted file mode 100644 index e21ebe85..00000000 --- a/src/image.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * image.h - * - * Handle images and image features - * - * (c) 2006-2011 Thomas White <taw@physics.org> - * - * Part of CrystFEL - crystallography with a FEL - * - */ - - -#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> - - -#define MAX_CELL_CANDIDATES (32) - - -/* 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; - * - * UnitCell *indexed_cell; - * UnitCell *candidate_cells[MAX_CELL_CANDIDATES]; - * int ncells; - - * struct detector *det; - * struct beam_params *beam; - * char *filename; - * const struct copy_hdf5_field *copyme; - * - * int id; - * - * double m; - * - * double lambda; - * double div; - * double bw; - * double i0; - * int i0_available; - * double osf; - * double profile_radius; - * int pr_dud; - * - * int width; - * int height; - * - * RefList *reflections; - * - * 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>candidate_cells</structfield> is an array of unit cells directly - * returned by the low-level indexing system. <structfield>ncells</structfield> - * is the number of candidate unit cells which were found. The maximum number - * of cells which may be returned is <function>MAX_CELL_CANDIDATES</function>. - * <structfield>indexed_cell</structfield> contains the "correct" unit cell - * after cell reduction or matching has been performed. The job of the cell - * reduction is to convert the list of candidate cells into a single indexed - * cell, or <function>NULL</function> on failure. - * - * <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; - - UnitCell *indexed_cell; - UnitCell *candidate_cells[MAX_CELL_CANDIDATES]; - int ncells; - - 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 */ - - /* Information about the crystal */ - double m; /* Mosaicity in radians */ - - /* Per-shot radiation values */ - double lambda; /* Wavelength in m */ - double div; /* Divergence in radians */ - double bw; /* Bandwidth as a fraction */ - double i0; /* Incident intensity */ - int i0_available; /* 0 if f0 wasn't available - * from the input. */ - double osf; /* Overall scaling factor */ - double profile_radius; /* Radius of reflection */ - int pr_dud; /* Post refinement failed */ - - int width; - int height; - - /* Integrated (or about-to-be-integrated) reflections */ - RefList *reflections; - - /* Detected 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); - -#endif /* IMAGE_H */ |