File: cmpack_image.h

package info (click to toggle)
c-munipack 2.1.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,888 kB
  • sloc: ansic: 200,762; cpp: 106,123; lex: 9,035; yacc: 4,916; sh: 4,074; fortran: 2,613; xml: 2,105; python: 1,182; makefile: 546; perl: 104
file content (284 lines) | stat: -rw-r--r-- 10,574 bytes parent folder | download | duplicates (2)
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/**
	\file
	\brief Class that can store and manipulate CCD images

	\author David Motl <dmotl@volny.cz>
	
	\par Copying
	This program 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, version 2.
	
	$Id: cmpack_image.h,v 1.1 2015/07/06 08:33:22 dmotl Exp $
*/

#ifndef _CMPACK_IMAGE_H_INCLUDED
#define _CMPACK_IMAGE_H_INCLUDED

#include "cmpack_common.h"

/********************   Public data types   ********************************/

/**
	\brief CCD image context 
	\details This private structure is used to keep and manipulate CCD image 
	data in memory
*/
typedef struct _CmpackImage CmpackImage;

/******************************   CmpackImage methods   ********************************/

#ifdef __cplusplus
extern "C" {
#endif

/** 
	\brief Compute number of bytes that are required to store the image 
	\details The function computes size of memory buffer required
	to store image data in given size and format
	\param[in] width			width of image in pixels
	\param[in] height			height of image in pixels
	\param[in] format			image data format
	\return pointer to new reference or zero on failure
*/
	CMPACK_EXPORT(int, cmpack_image_size, (int width, int height, CmpackBitpix format));

/**
	\brief Create a new image with internal memory buffer
	\details The function creates a new CCD image and allocates it
	according to specified parameters. The content of the image is undefined.
	\param[in] width			width of image in pixels
	\param[in] height			height of image in pixels
	\param[in] format			image data format
	\return pointer to new reference or zero on failure
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_new, (int width, int height, CmpackBitpix format));

/**
	\brief Create a new image that uses given memory buffer
	\details The function creates a new CCD image. The image will use given
	memory buffer which must be big enough to hold the image data. The buffer
	is not freed when the image is destroyed.
	\param[in] width			width of image in pixels
	\param[in] height			height of image in pixels
	\param[in] format			image data format
	\param[in] data				image buffer
	\param[in] datalen			size of image buffer in bytes
	\return pointer to new reference or zero on failure
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_from_data, (int width, int height, CmpackBitpix format,
		void* data, int datalen));

/**
	\brief Create a new empty image.
	\details The function creates an empty new CCD image. The dimensions
	of the image are zero, the format is undefined.
	\return pointer to new reference or zero on failure
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_new_empty, (void));

/**
	\brief Make a new reference to the CCD image
	\details The function makes a new reference to the image and returns a 
	pointer to it. The reference counter is incremented by one. The caller 
	is responsible to call cmpack_image_destroy() when the reference is 
	no longer needed.
	\param[in]	img				image context
	\return pointer to a new reference
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_reference, (CmpackImage* img));

/**
	\brief Make copy of the image
	\details The function makes deep copy of the source image to 
	the target image.
	\param[in] src				source image context
	\return new CmpackImage object
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_copy, (const CmpackImage* src));

/**
	\brief Release a reference to the CCD image
	\details The function releases a reference to the image. The reference 
	counter is decreased by one and when it was the last reference to the 
	image, the object is released from the memory.
	\param[in]	img				image context
*/
	CMPACK_EXPORT(void, cmpack_image_destroy, (CmpackImage* img));

/**
	\brief Get width of the image
	\details The function retrieves the width of the CCD frame in pixels.
	\param[in] img				image context
	\return image width in pixels
*/
	CMPACK_EXPORT(int, cmpack_image_width, (const CmpackImage* img));

/**
	\brief Get height of the image
	\details The function retrieves the height of the CCD frame in pixels.
	\param[in] img				image context
	\return image height in pixels
*/
	CMPACK_EXPORT(int, cmpack_image_height, (const CmpackImage* img));

/**
	\brief Get image data format
	\details The function returns a value (one of CMPACK_BITPIX_xxx constants)
	that indicates in which format the image data are stored in the memory.
	\param[in] img				image context
	\return image data type on success, zero on failure
*/
	CMPACK_EXPORT(CmpackBitpix, cmpack_image_bitpix, (const CmpackImage* img));

/**
	\brief Get pointer to the image data
	\details The function returns a pointer to the allocated memory block 
	that holds the image data. The pixels are stored row by row, without 
	padding.
	\param[in] img				image context
	\return pointer to image data or NULL if the image is empty
*/
	CMPACK_EXPORT(void*, cmpack_image_data, (CmpackImage* img));

/**
	\brief Get const pointer to the image data
	\details The function returns a pointer to the allocated memory block 
	that holds the image data. The pixels are stored row by row, without 
	padding.
	\param[in] img				image context
	\return pointer to image data or NULL if the image is empty
*/
	CMPACK_EXPORT(const void*, cmpack_image_const_data, (const CmpackImage* img));

/**
	\brief Get single pixel value
	\details The function retrieves value of a single pixel
	\return pixel value or zero on failure
*/
	CMPACK_EXPORT(double, cmpack_image_getpixel, (const CmpackImage* img, int x, int y));

/**
	\brief Convert image data to another format
	\details The function converts the source image to specified format
	\param[in] img				source image
	\param[in] format			new image format
	\return new CmpackImage object
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_convert, (const CmpackImage* img, CmpackBitpix format));

/**
	\brief Pixel binning
	\details The function sums blocks of pixels in the source image
	and stores the output to the target image.
	\param[in] src				source image
	\param[in] hbin				number of columns merged together
	\param[in] vbin				number of rows merged together
	\return new CmpackImage object
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_binning, (const CmpackImage* src, int hbin, int vbin));

/**
	\brief Image transformation using a matrix
	\details The function transforms an image
	\param[in] src				source image
	\param[in] nulvalue			pixel value below valid range
	\param[in] badvalue			pixel value above valid range
	\param[in] border			image border (can be NULL)
	\param[in] matrix			transformation matrix
	\return new CmpackImage object
*/
	CMPACK_EXPORT(CmpackImage*, cmpack_image_matrix_transform, (const CmpackImage* src, double nulvalue,
		double badvalue, const CmpackBorder* border, const CmpackMatrix* matrix));

/**
	\brief Transpose (flip) image
	\details The function transposes the source image and stores the 
	output to the same image. Both operations may be applied simultaneously.
	\param[in] img				image context
	\param[in] hflip			nonzero = horizontal flip
	\param[in] vflip			nonzero = vertical flip
	\return zero on success, error code on failure
*/
	CMPACK_EXPORT(int, cmpack_image_transpose, (CmpackImage* img, int hflip, int vflip));

/**
	\brief Set all pixels to specified value
	\details This function is used to initialize image data
	\param[in,out] img				image context
	\param[in] value				new pixel value
	\return zero on success, error code on failure
*/
	CMPACK_EXPORT(int, cmpack_image_fill, (CmpackImage* img, double value));

/**
	\brief Set pixels inside specified region to given value
	\details This function is used to set a region to given value.
	\param[in,out] img				image context
	\param[in] left					first column to be changed
	\param[in] top					first row to be changed
	\param[in] width				number of columns to be changed
	\param[in] height				number of rows to be changed
	\param[in] value				new pixel value
	\return zero on success, error code on failure
*/
	CMPACK_EXPORT(int, cmpack_image_fillrect, (CmpackImage* img, int left, int top, int width, int height,
		double value));

/**	
	\brief Automatic brightness/contrast
	\details The function determines suitable black and white values for 
	given image data. This function is used to determine the mapping before 
	the image is presented to the user.
	\param[in] img				image context
	\param[in] nulvalue			pixel value below valid range
	\param[in] badvalue			pixel value above valid range
	\param[out] blacklevel		lower mapping limit in ADU
	\param[out] whitelevel		upper mapping limit in ADU
*/
	CMPACK_EXPORT(int, cmpack_image_autogb, (CmpackImage* img, double nulvalue, double badvalue,
		double* blacklevel, double* whitelevel));

/**	
	\brief Compute minimum and maximum pixel values
	\details The function determines the minimum and maximum pixel values.
	\param[in] img				image context
	\param[in] nulvalue			pixel value that indicates invalid pixel
	\param[in] badvalue			ignored
	\param[out] minvalue		minimum pixel value in ADU
	\param[out] maxvalue		maximum pixel value in ADU
*/
	CMPACK_EXPORT(int, cmpack_image_minmax, (CmpackImage* img, double nulvalue, double badvalue,
		double* minvalue, double* maxvalue));

/**	
	\brief Compute mean and deviation
	\details The function determines the mean value and standard deviation
	using the robust mean algorithm.
	\param[in] img				image context
	\param[in] nulvalue			pixel value that indicates invalid pixel
	\param[in] badvalue			ignored
	\param[out] mean			mean value in ADU
	\param[out] stddev			standard deviation in ADU
*/
	CMPACK_EXPORT(int, cmpack_image_meandev, (CmpackImage* img, double nulvalue, double badvalue,
		double* mean, double* stddev));

/**	
	\brief Make histogram
	\details The function makes a histogram of pixel values. The caller
	must specify number of bins, minimum pixel value and bin width.
	\param[in] img				image context
	\param[in] channel_count	number of channels
	\param[in] channel_width	width of each channel in ADU
	\param[in] zero_offset		pixel value of the first channel in ADU
	\param[out] hist			histogram data
*/
	CMPACK_EXPORT(int, cmpack_image_histogram, (CmpackImage* img, int channel_count,
		double channel_width, double zero_offset, unsigned* hist));

#ifdef __cplusplus
}
#endif

#endif