X-shooter Pipeline Reference Manual 3.8.15
xsh_utils_image.h
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2012-08-06 16:25:39 $
23 * $Revision: 1.29 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifndef XSH_UTILS_IMAGE_H
28#define XSH_UTILS_IMAGE_H
29
30/*----------------------------------------------------------------------------
31 Includes
32 ----------------------------------------------------------------------------*/
33
34#include <cpl.h>
35#include <xsh_error.h>
36#include <xsh_data_order.h>
37
38typedef float pixelvalue ;
39
40/*---------------------------------------------------------------------------
41 Defines
42 ---------------------------------------------------------------------------*/
43
44typedef struct _STATS_
45{
46 float cleanmean ; /* mean of pixel values without considering
47 the extreme values */
48 float cleanstdev ; /* standard deviation of pixel values without
49 considering the extreme values */
50 int npix ; /* number of clean pixel values */
52
53
54#define TRANSFO_AFFINE 0
55#define TRANSFO_DEG2 1
56#define TRANSFO_HOMOGRAPHIC 2
57
58/* Number of pixels set to 0 by the shift resampling */
59#define SHIFT_REJECT_L 2
60#define SHIFT_REJECT_R 2
61#define SHIFT_REJECT_T 2
62#define SHIFT_REJECT_B 2
63
64/*
65 * Kernel definition in terms of sampling
66 */
67
68
69/* Number of tabulations in kernel */
70#define TABSPERPIX (1000)
71#define KERNEL_WIDTH (2.0)
72#define KERNEL_SAMPLES (1+(int)(TABSPERPIX * KERNEL_WIDTH))
73
74#define TANH_STEEPNESS (5.0)
75
76
77
78cpl_image*
79xsh_image_compute_geom_corr(cpl_image* in);
80
81double *
82xsh_generate_interpolation_kernel(const char * kernel_type) ;
83
84cpl_image *
86 cpl_image * image_in,
87 char * kernel_type,
88 cpl_polynomial * poly_u,
89 cpl_polynomial * poly_v
90) ;
91
92
93cpl_image *
94xsh_image_search_bad_pixels_via_noise(cpl_imagelist * darks,
95 float thresh_sigma_factor,
96 float low_threshold,
97 float high_threshold,
98 int llx,
99 int lly,
100 int urx,
101 int ury);
102
103void xsh_pixel_qsort(pixelvalue *pix_arr, int npix) ;
104void xsh_show_interpolation_kernel(char * kernel_name) ;
105double * xsh_generate_tanh_kernel(double steep) ;
106
107double
108xsh_fixed_pattern_noise(const cpl_image *master,
109 double convert_ADU,
110 double master_noise);
111double
112xsh_fixed_pattern_noise_bias(const cpl_image *first_raw,
113 const cpl_image *second_raw,
114 double ron);
115
116double xsh_image_get_stdev_clean(const cpl_image *image,
117 double *dstdev);
118
119double xsh_image_get_stdev_robust(const cpl_image *image,
120 double cut,
121 double *dstdev);
122
123cpl_error_code xsh_image_warp_polynomial_scale(cpl_image *,
124 const cpl_polynomial *poly_x,
125 const cpl_polynomial *poly_y);
126cpl_image* xsh_sobel_lx(cpl_image* in);
127cpl_image* xsh_sobel_ly(cpl_image* in);
128cpl_image* xsh_scharr_x(cpl_image* in);
129cpl_image* xsh_scharr_y(cpl_image* in);
130cpl_error_code
131xsh_compute_ron(cpl_frameset* frames,
132 int llx,
133 int lly,
134 int urx,
135 int ury,
136 int nsampl,
137 int hsize,
138 const int reg_id,
139 double* ron,
140 double* ron_err);
141
142cpl_image * xsh_image_smooth_fft(cpl_image * inp, const int fx, const int fy);
143cpl_image * xsh_image_smooth_median_x(cpl_image * inp, const int r);
144cpl_image * xsh_image_smooth_mean_x(cpl_image * inp, const int r);
145cpl_image * xsh_image_smooth_median_y(cpl_image * inp, const int r);
146cpl_image * xsh_image_smooth_mean_y(cpl_image * inp, const int r);
147cpl_image * xsh_image_smooth_median_xy(cpl_image * inp, const int r);
148double
149xsh_image_fit_gaussian_max_pos_x_window(const cpl_image* ima,
150 const int llx,
151 const int urx,
152 const int ypos);
153
154cpl_frame*
156 const char* prefix,const char* rec_prefix,
157 const int win_min, const int win_max,
158 const int hsize,
159 const int method,const int compute_qc);
160
161cpl_frame*
163 const char* suffix,
164 const int hsize, const int method);
165cpl_frame*
166xsh_frame_image_ext_qc_trace_window(cpl_frame* frm_ima,
168 const char* suffix,
169 const int hsize,
170 const int method);
171
172cpl_error_code
173xsh_iml_merge_avg(cpl_imagelist** data,
174 cpl_imagelist** mask,
175 const cpl_image* data_ima,
176 const cpl_image* mask_ima,
177 const int mk);
178cpl_error_code
179xsh_iml_merge_wgt(cpl_imagelist** data,
180 cpl_imagelist** errs,
181 cpl_imagelist** qual,
182 const cpl_image* flux_b,
183 const cpl_image* errs_b,
184 const cpl_image* qual_b,
185 const int mk,const int decode_bp);
186cpl_error_code
187xsh_image_mflat_detect_blemishes(cpl_frame* flat_frame,
189
190cpl_error_code
191xsh_collapse_errs(cpl_image * errs, cpl_imagelist * list, const int mode);
192
193cpl_image*
195 cpl_image* ima1_in,
196 cpl_image* ima2_in,
197 xsh_order_list* qth_list,
198 xsh_order_list* d2_list,
199 const int xrad,
200 const int yrad);
201
202cpl_error_code xsh_frame_image_save2ext(cpl_frame* frm,
203 const char* name_o, const int ext_i,
204 const int ext_o);
205cpl_error_code xsh_frame_image_add_double(cpl_frame* frm, const double value);
206cpl_frame* xsh_frame_image_mult_by_fct(cpl_frame* frm,const int fctx, const int fcty);
207
208cpl_frame*
209xsh_frame_image_div_by_fct(cpl_frame* frm,const int fctx, const int fcty);
210cpl_error_code xsh_image_cut_dichroic_uvb(cpl_frame* frame1d);
211
212cpl_image*
213xsh_compute_scale(cpl_imagelist* iml_data, cpl_mask* bpm,
214 const int mode, const int win_hsz);
215cpl_image*
216xsh_compute_scale_tab(cpl_imagelist* iml_data, cpl_mask* bpm, cpl_table* tab_bpm,
217 const int mode, const int win_hsz);
218cpl_image*
219xsh_compute_scale_tab2(cpl_imagelist* iml_data, cpl_imagelist* iml_qual,
220 cpl_mask* bpm, cpl_table* tab_bpm, const int mode,
221 const int win_hsz, const int decode_bp);
222
223cpl_image*
224xsh_compute_scale_tab3(cpl_imagelist* iml_data, cpl_imagelist* iml_qual,
225 cpl_mask* bpm, cpl_table* tab_bpm, const int mode,
226 const int win_hsz, const int decode_bp);
227cpl_table*
228xsh_qual2tab(cpl_image* bpm,const int code);
229#endif
static char mode[32]
static xsh_instrument * instrument
float cleanstdev
float cleanmean
int lly
Definition: xsh_detmon_lg.c:86
int llx
Definition: xsh_detmon_lg.c:85
const char * method
Definition: xsh_detmon_lg.c:78
int urx
Definition: xsh_detmon_lg.c:87
int ury
Definition: xsh_detmon_lg.c:88
cpl_image * xsh_image_smooth_median_y(cpl_image *inp, const int r)
double * xsh_generate_interpolation_kernel(const char *kernel_type)
void xsh_show_interpolation_kernel(char *kernel_name)
double xsh_image_get_stdev_robust(const cpl_image *image, double cut, double *dstdev)
Get robust empirical stdev of data.
cpl_error_code xsh_image_mflat_detect_blemishes(cpl_frame *flat_frame, xsh_instrument *instrument)
Flag blemishes in a flat image.
cpl_image * xsh_compute_scale_tab3(cpl_imagelist *iml_data, cpl_imagelist *iml_qual, cpl_mask *bpm, cpl_table *tab_bpm, const int mode, const int win_hsz, const int decode_bp)
double xsh_fixed_pattern_noise_bias(const cpl_image *first_raw, const cpl_image *second_raw, double ron)
Compute fixed pattern noise in bias.
cpl_image * xsh_warp_image_generic(cpl_image *image_in, char *kernel_type, cpl_polynomial *poly_u, cpl_polynomial *poly_v)
cpl_error_code xsh_image_cut_dichroic_uvb(cpl_frame *frame1d)
float pixelvalue
cpl_image * xsh_compute_scale_tab(cpl_imagelist *iml_data, cpl_mask *bpm, cpl_table *tab_bpm, const int mode, const int win_hsz)
cpl_image * xsh_sobel_lx(cpl_image *in)
Compute X Sobel filter transformation.
void xsh_pixel_qsort(pixelvalue *pix_arr, int npix)
cpl_image * xsh_scharr_y(cpl_image *in)
Compute Y Scharr filter transformation.
cpl_error_code xsh_image_warp_polynomial_scale(cpl_image *, const cpl_polynomial *poly_x, const cpl_polynomial *poly_y)
Compute area change ratio for a 2D polynomial transformation.
cpl_frame * xsh_frame_image_mult_by_fct(cpl_frame *frm, const int fctx, const int fcty)
double xsh_image_fit_gaussian_max_pos_x_window(const cpl_image *ima, const int llx, const int urx, const int ypos)
cpl_table * xsh_qual2tab(cpl_image *bpm, const int code)
double xsh_fixed_pattern_noise(const cpl_image *master, double convert_ADU, double master_noise)
Compute fixed pattern noise in flat field.
cpl_image * xsh_image_smooth_fft(cpl_image *inp, const int fx, const int fy)
cpl_image * xsh_image_smooth_mean_y(cpl_image *inp, const int r)
cpl_error_code xsh_iml_merge_avg(cpl_imagelist **data, cpl_imagelist **mask, const cpl_image *data_ima, const cpl_image *mask_ima, const int mk)
merge imagelist via average
cpl_frame * xsh_frame_image_qc_trace_window(cpl_frame *frm_ima, xsh_instrument *instrument, const char *suffix, const int hsize, const int method)
Trace object position in an image.
cpl_image * xsh_image_smooth_mean_x(cpl_image *inp, const int r)
struct _STATS_ Stats
cpl_image * xsh_image_search_bad_pixels_via_noise(cpl_imagelist *darks, float thresh_sigma_factor, float low_threshold, float high_threshold, int llx, int lly, int urx, int ury)
search bad pixels
cpl_error_code xsh_frame_image_save2ext(cpl_frame *frm, const char *name_o, const int ext_i, const int ext_o)
cpl_image * xsh_sobel_ly(cpl_image *in)
Compute Y Sobel filter transformation.
cpl_frame * xsh_frame_image_ext_qc_trace_window(cpl_frame *frm_ima, xsh_instrument *instrument, const char *suffix, const int hsize, const int method)
Trace object position in an image.
cpl_image * xsh_compute_scale_tab2(cpl_imagelist *iml_data, cpl_imagelist *iml_qual, cpl_mask *bpm, cpl_table *tab_bpm, const int mode, const int win_hsz, const int decode_bp)
cpl_error_code xsh_collapse_errs(cpl_image *errs, cpl_imagelist *list, const int mode)
cpl_image * xsh_image_smooth_median_x(cpl_image *inp, const int r)
cpl_frame * xsh_cube_qc_trace_window(cpl_frame *frm_cube, xsh_instrument *instrument, const char *prefix, const char *rec_prefix, const int win_min, const int win_max, const int hsize, const int method, const int compute_qc)
Trace object position in a cube.
cpl_image * xsh_combine_flats(cpl_image *ima1_in, cpl_image *ima2_in, xsh_order_list *qth_list, xsh_order_list *d2_list, const int xrad, const int yrad)
Combine flat frames line adjusting illumination level to merge them smoothly.
cpl_image * xsh_compute_scale(cpl_imagelist *iml_data, cpl_mask *bpm, const int mode, const int win_hsz)
cpl_error_code xsh_compute_ron(cpl_frameset *frames, int llx, int lly, int urx, int ury, int nsampl, int hsize, const int reg_id, double *ron, double *ron_err)
compute ron taking random windows of given size in a given region on 2 frames difference
double * xsh_generate_tanh_kernel(double steep)
cpl_frame * xsh_frame_image_div_by_fct(cpl_frame *frm, const int fctx, const int fcty)
cpl_image * xsh_image_compute_geom_corr(cpl_image *in)
Pixel area geometric trasformation computation.
cpl_error_code xsh_frame_image_add_double(cpl_frame *frm, const double value)
cpl_image * xsh_scharr_x(cpl_image *in)
Compute X Scharr filter transformation.
cpl_image * xsh_image_smooth_median_xy(cpl_image *inp, const int r)
cpl_error_code xsh_iml_merge_wgt(cpl_imagelist **data, cpl_imagelist **errs, cpl_imagelist **qual, const cpl_image *flux_b, const cpl_image *errs_b, const cpl_image *qual_b, const int mk, const int decode_bp)
merge imagelist via average
double xsh_image_get_stdev_clean(const cpl_image *image, double *dstdev)
Get clean (3*sigma clip) empirical stdev of data.