00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef XSH_UTILS_IMAGE_H
00028 #define XSH_UTILS_IMAGE_H
00029
00030
00031
00032
00033
00034 #include <cpl.h>
00035 #include <xsh_error.h>
00036 #include <xsh_data_order.h>
00037
00038 typedef float pixelvalue ;
00039
00040
00041
00042
00043
00044 typedef struct _STATS_
00045 {
00046 float cleanmean ;
00047
00048 float cleanstdev ;
00049
00050 int npix ;
00051 } Stats ;
00052
00053
00054 #define TRANSFO_AFFINE 0
00055 #define TRANSFO_DEG2 1
00056 #define TRANSFO_HOMOGRAPHIC 2
00057
00058
00059 #define SHIFT_REJECT_L 2
00060 #define SHIFT_REJECT_R 2
00061 #define SHIFT_REJECT_T 2
00062 #define SHIFT_REJECT_B 2
00063
00064
00065
00066
00067
00068
00069
00070 #define TABSPERPIX (1000)
00071 #define KERNEL_WIDTH (2.0)
00072 #define KERNEL_SAMPLES (1+(int)(TABSPERPIX * KERNEL_WIDTH))
00073
00074 #define TANH_STEEPNESS (5.0)
00075
00076
00077
00078 cpl_image*
00079 xsh_image_compute_geom_corr(cpl_image* in);
00080
00081 double *
00082 xsh_generate_interpolation_kernel(const char * kernel_type) ;
00083
00084 cpl_image *
00085 xsh_warp_image_generic(
00086 cpl_image * image_in,
00087 char * kernel_type,
00088 cpl_polynomial * poly_u,
00089 cpl_polynomial * poly_v
00090 ) ;
00091
00092
00093 cpl_image *
00094 xsh_image_search_bad_pixels_via_noise(cpl_imagelist * darks,
00095 float thresh_sigma_factor,
00096 float low_threshold,
00097 float high_threshold,
00098 int llx,
00099 int lly,
00100 int urx,
00101 int ury);
00102
00103 void xsh_pixel_qsort(pixelvalue *pix_arr, int npix) ;
00104 void xsh_show_interpolation_kernel(char * kernel_name) ;
00105 double * xsh_generate_tanh_kernel(double steep) ;
00106
00107 double
00108 xsh_fixed_pattern_noise(const cpl_image *master,
00109 double convert_ADU,
00110 double master_noise);
00111 double
00112 xsh_fixed_pattern_noise_bias(const cpl_image *first_raw,
00113 const cpl_image *second_raw,
00114 double ron);
00115
00116 double xsh_image_get_stdev_clean(const cpl_image *image,
00117 double *dstdev);
00118
00119 double xsh_image_get_stdev_robust(const cpl_image *image,
00120 double cut,
00121 double *dstdev);
00122
00123 cpl_error_code xsh_image_warp_polynomial_scale(cpl_image *,
00124 const cpl_polynomial *poly_x,
00125 const cpl_polynomial *poly_y);
00126 cpl_image* xsh_sobel_lx(cpl_image* in);
00127 cpl_image* xsh_sobel_ly(cpl_image* in);
00128 cpl_image* xsh_scharr_x(cpl_image* in);
00129 cpl_image* xsh_scharr_y(cpl_image* in);
00130 cpl_error_code
00131 xsh_compute_ron(cpl_frameset* frames,
00132 int llx,
00133 int lly,
00134 int urx,
00135 int ury,
00136 int nsampl,
00137 int hsize,
00138 const int reg_id,
00139 double* ron,
00140 double* ron_err);
00141
00142 cpl_image * xsh_image_smooth_fft(cpl_image * inp, const int fx, const int fy);
00143 cpl_image * xsh_image_smooth_median_x(cpl_image * inp, const int r);
00144 cpl_image * xsh_image_smooth_mean_x(cpl_image * inp, const int r);
00145 cpl_image * xsh_image_smooth_median_y(cpl_image * inp, const int r);
00146 cpl_image * xsh_image_smooth_mean_y(cpl_image * inp, const int r);
00147 cpl_image * xsh_image_smooth_median_xy(cpl_image * inp, const int r);
00148 double
00149 xsh_image_fit_gaussian_max_pos_x_window(const cpl_image* ima,
00150 const int llx,
00151 const int urx,
00152 const int ypos);
00153
00154 cpl_frame*
00155 xsh_cube_qc_trace_window(cpl_frame* frm_cube,xsh_instrument* instrument,
00156 const char* prefix,const char* rec_prefix,
00157 const int win_min, const int win_max,
00158 const int hsize,
00159 const int method,const int compute_qc);
00160
00161 cpl_frame*
00162 xsh_frame_image_qc_trace_window(cpl_frame* frm_ima,xsh_instrument* instrument,
00163 const char* suffix,
00164 const int hsize, const int method);
00165 cpl_frame*
00166 xsh_frame_image_ext_qc_trace_window(cpl_frame* frm_ima,
00167 xsh_instrument* instrument,
00168 const char* suffix,
00169 const int hsize,
00170 const int method);
00171
00172 cpl_error_code
00173 xsh_iml_merge_avg(cpl_imagelist** data,
00174 cpl_imagelist** mask,
00175 const cpl_image* data_ima,
00176 const cpl_image* mask_ima,
00177 const int mk);
00178
00179 cpl_error_code
00180 xsh_image_mflat_detect_blemishes(cpl_frame* flat_frame,
00181 xsh_instrument* instrument);
00182
00183 cpl_error_code
00184 xsh_collapse_errs(cpl_image * errs, cpl_imagelist * list, const int mode);
00185
00186 cpl_image*
00187 xsh_combine_flats(
00188 cpl_image* ima1_in,
00189 cpl_image* ima2_in,
00190 xsh_order_list* qth_list,
00191 xsh_order_list* d2_list,
00192 const int xrad,
00193 const int yrad);
00194
00195 cpl_error_code xsh_frame_image_save2ext(cpl_frame* frm,
00196 const char* name_o, const int ext_i,
00197 const int ext_o);
00198 cpl_error_code xsh_frame_image_add_double(cpl_frame* frm, const double value);
00199 cpl_frame* xsh_frame_image_mult_by_fct(cpl_frame* frm,const int fctx, const int fcty);
00200
00201 cpl_frame*
00202 xsh_frame_image_div_by_fct(cpl_frame* frm,const int fctx, const int fcty);
00203 #endif