blob: 00848cf4b9c5c5d5b133282d3f54dd5748c4b1a2 (
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* image.c
*
* Handle images and image features
*
* (c) 2007 Thomas White <taw27@cam.ac.uk>
*
* dtr - Diffraction Tomography Reconstruction
*
*/
#include <stdlib.h>
#include <assert.h>
#include "control.h"
#include "image.h"
int image_add(ImageList *list, uint16_t *image, int width, int height, double tilt, ControlContext *ctx) {
if ( list->images ) {
list->images = realloc(list->images, (list->n_images+1)*sizeof(ImageRecord));
} else {
assert(list->n_images == 0);
list->images = malloc(sizeof(ImageRecord));
}
list->images[list->n_images].tilt = tilt;
list->images[list->n_images].omega = ctx->omega;
list->images[list->n_images].image = image;
list->images[list->n_images].width = width;
list->images[list->n_images].height = height;
list->images[list->n_images].lambda = ctx->lambda;
list->images[list->n_images].fmode = ctx->fmode;
list->images[list->n_images].x_centre = ctx->x_centre;
list->images[list->n_images].y_centre = ctx->y_centre;
list->images[list->n_images].slop = 0.0;
list->images[list->n_images].features = NULL;
if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
list->images[list->n_images].pixel_size = ctx->pixel_size;
list->images[list->n_images].camera_len = 0;
list->images[list->n_images].resolution = 0;
} else if ( ctx->fmode == FORMULATION_CLEN ) {
list->images[list->n_images].pixel_size = 0;
list->images[list->n_images].camera_len = ctx->camera_length;
list->images[list->n_images].resolution = ctx->resolution;
}
list->n_images++;
return list->n_images - 1;
}
ImageList *image_list_new() {
ImageList *list;
list = malloc(sizeof(ImageList));
list->n_images = 0;
list->images = NULL;
return list;
}
void image_add_feature(ImageFeatureList *flist, double x, double y, ImageRecord *parent, double intensity) {
if ( flist->features ) {
flist->features = realloc(flist->features, (flist->n_features+1)*sizeof(ImageFeature));
} else {
assert(flist->n_features == 0);
flist->features = malloc(sizeof(ImageFeature));
}
flist->features[flist->n_features].x = x;
flist->features[flist->n_features].y = y;
flist->features[flist->n_features].intensity = intensity;
flist->features[flist->n_features].parent = parent;
flist->features[flist->n_features].partner = NULL;
flist->features[flist->n_features].partner_d = 0.0;
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);
}
|