#include <xsh_utils_wrappers.h>
#include <xsh_utils_image.h>
#include <xsh_error.h>
#include <xsh_utils.h>
#include <xsh_pfits_qc.h>
#include <xsh_pfits.h>
#include <xsh_dfs.h>
#include <xsh_data_pre.h>
#include <xsh_data_instrument.h>
#include <math.h>
#include <string.h>
Go to the source code of this file.
Defines | ||||||||||||||||||||||
#define | FLAG -1.e+9 | |||||||||||||||||||||
Functions | ||||||||||||||||||||||
xsh_show_interpolation_kernel | ||||||||||||||||||||||
static cpl_image * | xsh_image_crop (const cpl_image *image, int xlo, int ylo, int xhi, int yhi) | |||||||||||||||||||||
Crop image. | ||||||||||||||||||||||
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. | ||||||||||||||||||||||
double | xsh_image_get_stdev_clean (const cpl_image *image, double *dstdev) | |||||||||||||||||||||
Get clean (3*sigma clip) empirical stdev of data. | ||||||||||||||||||||||
double | xsh_fixed_pattern_noise (const cpl_image *master, double convert_ADU, double master_noise) | |||||||||||||||||||||
Compute fixed pattern noise in flat field. | ||||||||||||||||||||||
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_error_code | xsh_image_warp_polynomial_scale (cpl_image *out, const cpl_polynomial *poly_x, const cpl_polynomial *poly_y) | |||||||||||||||||||||
Compute area change ratio for a 2D polynomial transformation. | ||||||||||||||||||||||
cpl_image * | xsh_scharr_x (cpl_image *in) | |||||||||||||||||||||
Compute X Scharr filter transformation. | ||||||||||||||||||||||
cpl_image * | xsh_scharr_y (cpl_image *in) | |||||||||||||||||||||
Compute Y Scharr filter transformation. | ||||||||||||||||||||||
cpl_image * | xsh_sobel_lx (cpl_image *in) | |||||||||||||||||||||
Compute X Sobel filter transformation. | ||||||||||||||||||||||
cpl_image * | xsh_sobel_ly (cpl_image *in) | |||||||||||||||||||||
Compute Y Sobel filter transformation. | ||||||||||||||||||||||
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 | ||||||||||||||||||||||
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 | ||||||||||||||||||||||
xsh_clean_mean() | ||||||||||||||||||||||
his routine computes the clean mean of a given data
| ||||||||||||||||||||||
static float | xsh_clean_mean (float *array, int n_elements, float throwaway_low, float throwaway_high) | |||||||||||||||||||||
static cpl_error_code | xsh_compute_geom_corr (const double dxdu, const double dydv, const double dxdv, const double dydu, const double du, const double dv, double *dA) | |||||||||||||||||||||
Pixel area geometric trasformation computation. | ||||||||||||||||||||||
cpl_image * | xsh_image_compute_geom_corr (cpl_image *in) | |||||||||||||||||||||
Pixel area geometric trasformation computation. | ||||||||||||||||||||||
xsh_sinc | ||||||||||||||||||||||
static double | xsh_sinc (double x) | |||||||||||||||||||||
reverse_tanh_kernel | ||||||||||||||||||||||
Bring a hyperbolic tangent kernel from Fourier to normal space.
Bring back a hyperbolic tangent kernel from Fourier to normal space. Do not try to understand the implementation and DO NOT MODIFY THIS FUNCTION. | ||||||||||||||||||||||
static void | reverse_tanh_kernel (double *data, int nn) | |||||||||||||||||||||
xsh_image_smooth_fft | ||||||||||||||||||||||
| ||||||||||||||||||||||
static cpl_image * | xsh_gen_lowpass (const int xs, const int ys, const double sigma_x, const double sigma_y) | |||||||||||||||||||||
Generate a low pass filter for FFT convolution . | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_fft (cpl_image *inp, const int fx, const int fy) | |||||||||||||||||||||
xsh_generate_interpolation_kernel | ||||||||||||||||||||||
Generate an interpolation kernel to use in this module.
Provide the name of the kernel you want to generate. Supported kernel types are: {tabular}{ll} NULL & default kernel, currently "tanh" \ "default" & default kernel, currently "tanh" \ "tanh" & Hyperbolic tangent \ "sinc2" & Square xsh_sinc \ "lanczos" & Lanczos2 kernel \ "hamming" & Hamming kernel \ "hann" & Hann kernel {tabular} The returned array of doubles is ready of use in the various re-sampling functions in this module. It must be deallocated using cpl_free(). | ||||||||||||||||||||||
double * | xsh_generate_interpolation_kernel (const char *kernel_type) | |||||||||||||||||||||
xsh_pixel_qsort | ||||||||||||||||||||||
void | xsh_pixel_qsort (pixelvalue *pix_arr, int npix) | |||||||||||||||||||||
xsh_image_smooth_mean_y | ||||||||||||||||||||||
Smooth an image using a simple mean.
This function applies a running mean or radius r along y. The returned image is a newly allocated object, it must be deallocated using xsh_free_image(). | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_mean_y (cpl_image *inp, const int r) | |||||||||||||||||||||
xsh_image_smooth_median_y | ||||||||||||||||||||||
Smooth an image using a simple mean.
This function applies a running median or radius r along y. The returned image is a newly allocated object, it must be deallocated using xsh_free_image(). | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_median_y (cpl_image *inp, const int r) | |||||||||||||||||||||
xsh_image_smooth_mean_x | ||||||||||||||||||||||
Smooth an image using a simple mean.
This function applies a running mean or radius r along x. The returned image is a newly allocated object, it must be deallocated using xsh_free_image(). | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_mean_x (cpl_image *inp, const int r) | |||||||||||||||||||||
xsh_image_smooth_median_x | ||||||||||||||||||||||
Smooth an image using a simple mean.
This function applies a running median or radius r along x. The returned image is a newly allocated object, it must be deallocated using xsh_free_image(). | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_median_x (cpl_image *inp, const int r) | |||||||||||||||||||||
xsh_image_smooth_median_xy | ||||||||||||||||||||||
Smooth an image using a simple mean.
This function applies a running median or radius r along x. The returned image is a newly allocated object, it must be deallocated using xsh_free_image(). | ||||||||||||||||||||||
cpl_image * | xsh_image_smooth_median_xy (cpl_image *inp, const int r) | |||||||||||||||||||||
xsh_image_clean_badpixel | ||||||||||||||||||||||
cpl_error_code | xsh_image_clean_badpixel (cpl_frame *in) | |||||||||||||||||||||
xsh_image_fit_gaussian_max_pos_x_window | ||||||||||||||||||||||
Determine image peack position according Gaussian fit
| ||||||||||||||||||||||
double | xsh_image_fit_gaussian_max_pos_x_window (const cpl_image *ima, const int llx, const int urx, const int ypos) | |||||||||||||||||||||
xsh_image_fit_gaussian_max_pos_y_window | ||||||||||||||||||||||
Determine image peack position according Gaussian fit
| ||||||||||||||||||||||
static double | xsh_image_fit_gaussian_max_pos_y_window (const cpl_image *ima, const int lly, const int ury, const int xpos) | |||||||||||||||||||||
static cpl_table * | xsh_image_qc_trace_window (cpl_image *data_ima, cpl_propertylist *head, const int hsize, const int method) | |||||||||||||||||||||
Trace object position in an image. | ||||||||||||||||||||||
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_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. | ||||||||||||||||||||||
static cpl_error_code | xsh_util_compute_qc_residuals (cpl_table *table, xsh_instrument *instrument, cpl_propertylist *plist) | |||||||||||||||||||||
cpl_frame * | xsh_cube_qc_trace_window (cpl_frame *frm_cube, xsh_instrument *instrument, const char *suffix, 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_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_image * | xsh_image_mflat_detect_blemishes (cpl_frame *flat_frame, xsh_instrument *instrument) | |||||||||||||||||||||
Flag blemishes in a flat image. | ||||||||||||||||||||||
cpl_frame * | xsh_image_mflat_detect_hotcold (cpl_frame *flat_frame, xsh_instrument *instrument, const int mode) | |||||||||||||||||||||
Flag blemishes in a flat image. | ||||||||||||||||||||||
xsh_warp_image_generic | ||||||||||||||||||||||
Warp an image according to a polynomial transformation.
Warp an image according to a polynomial transform. Provide two polynomials (see poly2d.h for polynomials in this library) Pu and Pv such as: {verbatim} x = xsh_poly2d_compute(Pu, u, v) y = xsh_poly2d_compute(Pv, u, v) {verbatim} Attention! The polynomials define a reverse transform. (u,v) are coordinates in the warped image and (x,y) are coordinates in the original image. The transform you provide is used to compute from the warped image, which pixels contributed in the original image. The output image will have strictly the same size as in the input image. Beware that for extreme transformations, this might lead to blank images as result. See the function xsh_generate_interpolation_kernel() for possible kernel types. If you want to use a default kernel, provide NULL for kernel type. The returned image is a newly allocated objet, use cpl_image_delete() to deallocate it. | ||||||||||||||||||||||
#define | hk_gen(x, s) (((tanh(s*(x+0.5))+1)/2)*((tanh(s*(-x+0.5))+1)/2)) | |||||||||||||||||||||
cpl_image * | xsh_warp_image_generic (cpl_image *image_in, char *kernel_type, cpl_polynomial *poly_u, cpl_polynomial *poly_v) | |||||||||||||||||||||
xsh_generate_tanh_kernel | ||||||||||||||||||||||
Generate a hyperbolic tangent kernel.
The following function builds up a good approximation of a box filter. It is built from a product of hyperbolic tangents. It has the following properties: {itemize} It converges very quickly towards +/- 1. The converging transition is very sharp. It is infinitely differentiable everywhere (i.e. smooth). The transition sharpness is scalable. {itemize} The returned array must be deallocated using cpl_free(). | ||||||||||||||||||||||
#define | KERNEL_SW(a, b) tempr=(a);(a)=(b);(b)=tempr | |||||||||||||||||||||
double * | xsh_generate_tanh_kernel (double steep) | |||||||||||||||||||||
xsh_image_stats_on_rectangle() | ||||||||||||||||||||||
computes the mean and standard deviation of a given rectangle on an image by leaving the extreme intensity values.
| ||||||||||||||||||||||
#define | PIX_SWAP(a, b) { pixelvalue temp=(a);(a)=(b);(b)=temp; } | |||||||||||||||||||||
#define | PIX_STACK_SIZE 50 | |||||||||||||||||||||
static Stats * | xsh_image_stats_on_rectangle (cpl_image *im, float loReject, float hiReject, int llx, int lly, int urx, int ury) |
#define FLAG -1.e+9 |
Definition at line 38 of file xsh_utils_image.c.
Referenced by xsh_clean_mean().
Definition at line 484 of file xsh_utils_image.c.
Referenced by xsh_generate_tanh_kernel().
#define KERNEL_SW | ( | a, | |||
b | ) | tempr=(a);(a)=(b);(b)=tempr |
Definition at line 558 of file xsh_utils_image.c.
Referenced by reverse_tanh_kernel().
#define PIX_STACK_SIZE 50 |
Definition at line 1711 of file xsh_utils_image.c.
Referenced by xsh_pixel_qsort().
#define PIX_SWAP | ( | a, | |||
b | ) | { pixelvalue temp=(a);(a)=(b);(b)=temp; } |
Definition at line 1710 of file xsh_utils_image.c.
Referenced by xsh_pixel_qsort().
static void reverse_tanh_kernel | ( | double * | data, | |
int | nn | |||
) | [static] |
Definition at line 574 of file xsh_utils_image.c.
References KERNEL_SW, m, M_PI, and n.
Referenced by xsh_generate_tanh_kernel().
float xsh_clean_mean | ( | float * | array, | |
int | n_elements, | |||
float | throwaway_low, | |||
float | throwaway_high | |||
) | [static] |
Definition at line 1811 of file xsh_utils_image.c.
References FLAG, n, xsh_msg_error, and xsh_pixel_qsort().
Referenced by xsh_image_stats_on_rectangle().
static cpl_error_code xsh_compute_geom_corr | ( | const double | dxdu, | |
const double | dydv, | |||
const double | dxdv, | |||
const double | dydu, | |||
const double | du, | |||
const double | dv, | |||
double * | dA | |||
) | [static] |
Pixel area geometric trasformation computation.
dxdu | relative derivative dx/du | |
dydv | relative derivative dy/dv | |
dxdv | relative derivative dx/dv | |
dydu | relative derivative dy/du | |
du | incremental du | |
dv | incremental dv | |
dA | resulting pixel area change |
Definition at line 108 of file xsh_utils_image.c.
Referenced by xsh_image_compute_geom_corr().
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
frames | input frameset | |
llx | image lower left x | |
lly | image lower left y | |
urx | image upper left x | |
ury | image upper left y | |
nsampl | number of sampling window | |
hsize | hal size of (square) window | |
reg_id | parameter switch | |
ron | output ron value | |
ron_err | output error on ron value |
Definition at line 1293 of file xsh_utils_image.c.
References check, xsh_error_msg, xsh_free_image(), xsh_free_propertylist(), XSH_PCATG, xsh_pfits_set_qc_ron1(), xsh_pfits_set_qc_ron1_err(), xsh_pfits_set_qc_ron2(), and xsh_pfits_set_qc_ron2_err().
Referenced by xsh_compute_ron_mbias(), and xsh_util_ronbias().
cpl_frame* xsh_cube_qc_trace_window | ( | cpl_frame * | frm_cube, | |
xsh_instrument * | instrument, | |||
const char * | suffix, | |||
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.
frm_cube | The frame whose frame need to be updated | |
instrument | The instrument setting structure | |
suffix | The product filename suffix | |
rec_prefix | The input recipe prefix string value | |
win_min | The win_min value allowed in the search | |
win_max | The win_max value allowed in the search | |
hsize | The half window size used in the object peack final search | |
method | The peack search method 0: Gaussian, 1: centroid | |
compute_qc | Switch to activate QC computation |
Definition at line 2907 of file xsh_utils_image.c.
References check, llx, urx, xsh_frame_product(), xsh_free_imagelist(), xsh_free_propertylist(), xsh_free_table(), xsh_image_fit_gaussian_max_pos_x_window(), xsh_instrument_arm_tostring(), xsh_pfits_get_cdelt3(), xsh_pfits_get_crval3(), and xsh_util_compute_qc_residuals().
Referenced by xsh_build_ifu_cube(), and xsh_util_ifu_build_cube().
double xsh_fixed_pattern_noise | ( | const cpl_image * | master, | |
double | convert_ADU, | |||
double | master_noise | |||
) |
Compute fixed pattern noise in flat field.
master | master image | |
convert_ADU | factor to convert from master units to ADU | |
master_noise | master noise (ADU) for a shift of zero |
Definition at line 764 of file xsh_utils_image.c.
References assure, xsh_free_image(), and xsh_image_crop().
double xsh_fixed_pattern_noise_bias | ( | const cpl_image * | first_raw, | |
const cpl_image * | second_raw, | |||
double | ron | |||
) |
Compute fixed pattern noise in bias.
first_raw | First raw bias frame | |
second_raw | Second raw bias frame | |
ron | Read out noise (ADU) for a shift of zero |
Definition at line 844 of file xsh_utils_image.c.
References assure, nx, ny, xsh_free_image(), xsh_image_crop(), and xsh_image_get_stdev_robust().
Referenced by xsh_compute_fpn_mbias().
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.
frm_ima | The image frame where object traces need need to be found | |
instrument | The instrument setting structure | |
suffix | The product filename suffix | |
hsize | The half window size used in the object peack final search | |
method | The peack search method 0: Gaussian, 1: centroid |
Definition at line 2721 of file xsh_utils_image.c.
References check, xsh_frame_product(), xsh_free_image(), xsh_free_propertylist(), xsh_free_table(), xsh_image_qc_trace_window(), xsh_instrument_arm_tostring(), and xsh_msg.
Referenced by xsh_scired_slit_stare().
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.
frm_ima | The image frame where object traces need need to be found | |
instrument | The instrument setting structure | |
suffix | The product filename suffix | |
hsize | The half window size used in the object peack final search | |
method | The peack search method 0: Gaussian, 1: centroid |
Definition at line 2661 of file xsh_utils_image.c.
References check, xsh_frame_product(), xsh_free_image(), xsh_free_propertylist(), xsh_free_table(), xsh_image_qc_trace_window(), and xsh_instrument_arm_tostring().
Referenced by xsh_scired_slit_stare().
static cpl_image * xsh_gen_lowpass | ( | const int | xs, | |
const int | ys, | |||
const double | sigma_x, | |||
const double | sigma_y | |||
) | [static] |
Generate a low pass filter for FFT convolution .
xs | x size of the generated image. | |
ys | y size of the generated image. | |
sigma_x | Sigma for the gaussian distribution. | |
sigma_y | Sigma for the gaussian distribution. |
This function generates an image of a 2d gaussian, modified in such a way that the different quadrants have a quadrants of the gaussian in the corner. This image is suitable for FFT convolution. Copied from eclipse, src/iproc/generate.c
The returned image must be deallocated.
Definition at line 1959 of file xsh_utils_image.c.
References x, xsh_msg_error, and y.
Referenced by xsh_image_smooth_fft().
double* xsh_generate_interpolation_kernel | ( | const char * | kernel_type | ) |
Definition at line 204 of file xsh_utils_image.c.
References KERNEL_SAMPLES, KERNEL_WIDTH, M_PI, TANH_STEEPNESS, x, xsh_generate_interpolation_kernel(), xsh_generate_tanh_kernel(), xsh_msg_error, and xsh_sinc().
Referenced by xsh_generate_interpolation_kernel(), xsh_show_interpolation_kernel(), and xsh_warp_image_generic().
double* xsh_generate_tanh_kernel | ( | double | steep | ) |
Definition at line 509 of file xsh_utils_image.c.
References hk_gen, KERNEL_SAMPLES, reverse_tanh_kernel(), TABSPERPIX, width, and x.
Referenced by xsh_generate_interpolation_kernel().
cpl_error_code xsh_image_clean_badpixel | ( | cpl_frame * | in | ) |
Definition at line 2346 of file xsh_utils_image.c.
References check, nx, ny, xsh_free_image(), xsh_free_propertylist(), XSH_PRE_DATA_BPP, XSH_PRE_ERRS_BPP, and XSH_PRE_QUAL_BPP.
cpl_image* xsh_image_compute_geom_corr | ( | cpl_image * | in | ) |
Pixel area geometric trasformation computation.
in | input image |
Definition at line 133 of file xsh_utils_image.c.
References assure, check, xsh_compute_geom_corr(), and xsh_free_image().
static cpl_image * xsh_image_crop | ( | const cpl_image * | image, | |
int | xlo, | |||
int | ylo, | |||
int | xhi, | |||
int | yhi | |||
) | [static] |
Crop image.
image | image | |
xlo | lower left x | |
ylo | lower left y | |
xhi | upper right x | |
yhi | upper right y |
Coordinates are inclusive, counting from 1
Definition at line 919 of file xsh_utils_image.c.
Referenced by xsh_fixed_pattern_noise(), and xsh_fixed_pattern_noise_bias().
double xsh_image_fit_gaussian_max_pos_x_window | ( | const cpl_image * | ima, | |
const int | llx, | |||
const int | urx, | |||
const int | ypos | |||
) |
Definition at line 2427 of file xsh_utils_image.c.
References check, XSH_GAUSSIAN_FIT::peakpos, xsh_free_vector(), xsh_msg_dbg_high, and xsh_vector_fit_gaussian().
Referenced by xsh_cube_qc_trace_window(), and xsh_ifu_trace_object_calibrate().
static double xsh_image_fit_gaussian_max_pos_y_window | ( | const cpl_image * | ima, | |
const int | lly, | |||
const int | ury, | |||
const int | xpos | |||
) | [static] |
Definition at line 2502 of file xsh_utils_image.c.
References check, XSH_GAUSSIAN_FIT::peakpos, xsh_free_vector(), xsh_msg_dbg_high, and xsh_vector_fit_gaussian().
Referenced by xsh_image_qc_trace_window().
double xsh_image_get_stdev_clean | ( | const cpl_image * | image, | |
double * | dstdev | |||
) |
Get clean (3*sigma clip) empirical stdev of data.
image | image | |
dstdev | (output) error of estimate |
Definition at line 717 of file xsh_utils_image.c.
References assure, kappa, xsh_free_image(), and xsh_free_mask().
Referenced by xsh_compute_fpn_mbias().
double xsh_image_get_stdev_robust | ( | const cpl_image * | image, | |
double | cut, | |||
double * | dstdev | |||
) |
Get robust empirical stdev of data.
image | image | |
cut | pixels outside median +- cut are ignored | |
dstdev | (output) error of estimate |
Definition at line 677 of file xsh_utils_image.c.
References assure, xsh_free_image(), and xsh_free_mask().
Referenced by xsh_fixed_pattern_noise_bias().
cpl_image* xsh_image_mflat_detect_blemishes | ( | cpl_frame * | flat_frame, | |
xsh_instrument * | instrument | |||
) |
Flag blemishes in a flat image.
flat_frame | input image | |
instrument | instrument arm setting |
Definition at line 3130 of file xsh_utils_image.c.
References binx, biny, check, kappa, niter, passure, size, XSH_ARM_NIR, xsh_free_array(), xsh_free_image(), xsh_free_matrix(), xsh_free_propertylist(), xsh_image_filter_median(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_pfits_get_binx(), and xsh_pfits_get_biny().
cpl_frame* xsh_image_mflat_detect_hotcold | ( | cpl_frame * | flat_frame, | |
xsh_instrument * | instrument, | |||
const int | mode | |||
) |
Flag blemishes in a flat image.
flat_frame | input image | |
instrument | arm setting | |
mode | hot/cold pix flag mode |
Definition at line 3284 of file xsh_utils_image.c.
References binx, biny, check, kappa, niter, passure, QFLAG_LOW_QE_PIXEL, QFLAG_WELL_SATURATION, size, XSH_ARM_NIR, XSH_BP_MAP_DP, XSH_BP_MAP_SP, xsh_frame_product(), xsh_free_array(), xsh_free_image(), xsh_free_matrix(), xsh_free_propertylist(), xsh_image_filter_median(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_pfits_get_binx(), xsh_pfits_get_biny(), and XSH_PRE_DATA_BPP.
Referenced by xsh_mflat().
static cpl_table* xsh_image_qc_trace_window | ( | cpl_image * | data_ima, | |
cpl_propertylist * | head, | |||
const int | hsize, | |||
const int | method | |||
) | [static] |
Trace object position in an image.
data_ima | The image where object traces need need to be found | |
head | The FITS header where to write QC | |
hsize | The half window size used in the object peack final search | |
method | The peack search method 0: Gaussian, 1: centroid |
Definition at line 2581 of file xsh_utils_image.c.
References check, llx, lly, ury, xsh_image_fit_gaussian_max_pos_y_window(), xsh_pfits_get_cdelt1(), and xsh_pfits_get_crval1().
Referenced by xsh_frame_image_ext_qc_trace_window(), and xsh_frame_image_qc_trace_window().
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
darks | sequence of darks (NDIT = 1) stored in a cube, at least 10 to get good statistics | |
thresh_sigma_factor | factor to determined standard deviation in each pixel to determine the threshold beyond which a pixel is declared as bad. | |
low_threshold | percentage (0...100) of extreme pixel values that is \ not considered for image statistics | |
high_threshold | percentage (0...100) of extreme pixel values that is \ not considered for image statistics | |
llx | lower left X corner pix | |
lly | upper left Y corner pix | |
urx | lower right X corner pix | |
ury | upper right Y corner pix |
Job this routine searches for static bad pixel positions This is done by building a cube of xsh_dark frames and examine the noise variations in each pixel. If big deviations from a clean mean pixel noise occurr, the pixel is declared as bad.
Definition at line 1428 of file xsh_utils_image.c.
References _STATS_::cleanmean, _STATS_::cleanstdev, n, QFLAG_HOT_PIXEL, xsh_image_stats_on_rectangle(), xsh_msg_error, and xsh_pixel_qsort().
Referenced by xsh_mdark().
cpl_image* xsh_image_smooth_fft | ( | cpl_image * | inp, | |
const int | fx, | |||
const int | fy | |||
) |
Definition at line 1882 of file xsh_utils_image.c.
References check, cknull_msg, filter, xsh_free_image(), and xsh_gen_lowpass().
cpl_image* xsh_image_smooth_mean_x | ( | cpl_image * | inp, | |
const int | r | |||
) |
Definition at line 2168 of file xsh_utils_image.c.
References check, and XSH_ASSURE_NOT_NULL.
Referenced by xsh_subtract_background().
cpl_image* xsh_image_smooth_mean_y | ( | cpl_image * | inp, | |
const int | r | |||
) |
Definition at line 2059 of file xsh_utils_image.c.
References check, XSH_ASSURE_NOT_NULL, and xsh_free_image().
Referenced by xsh_subtract_background().
cpl_image* xsh_image_smooth_median_x | ( | cpl_image * | inp, | |
const int | r | |||
) |
Definition at line 2226 of file xsh_utils_image.c.
References check, and cknull_msg.
Referenced by xsh_mflat_normalize().
cpl_image* xsh_image_smooth_median_xy | ( | cpl_image * | inp, | |
const int | r | |||
) |
Definition at line 2289 of file xsh_utils_image.c.
References check, and cknull_msg.
cpl_image* xsh_image_smooth_median_y | ( | cpl_image * | inp, | |
const int | r | |||
) |
Definition at line 2113 of file xsh_utils_image.c.
References check, and cknull_msg.
Stats * xsh_image_stats_on_rectangle | ( | cpl_image * | im, | |
float | loReject, | |||
float | hiReject, | |||
int | llx, | |||
int | lly, | |||
int | urx, | |||
int | ury | |||
) | [static] |
Definition at line 1587 of file xsh_utils_image.c.
References _STATS_::cleanmean, n, xsh_clean_mean(), and xsh_msg_error.
Referenced by xsh_image_search_bad_pixels_via_noise().
cpl_error_code xsh_image_warp_polynomial_scale | ( | cpl_image * | out, | |
const cpl_polynomial * | poly_x, | |||
const cpl_polynomial * | poly_y | |||
) |
Compute area change ratio for a 2D polynomial transformation.
out | Pre-allocated image to hold the result | |
poly_x | Defines source x-pos corresponding to destination (u,v). | |
poly_y | Defines source y-pos corresponding to destination (u,v). |
Given a polynomial transformation from (x, y) to (u, v) coordinate systems, such as the one used in cpl_image_warp_polynomial()
to "warp" (or "map") an image onto another, this function creates an image reporting for each pixel the scaling ratio between the unitary area in the system (u, v) and the same area before mapping, in the system (x, y).
This is trivially obtained by computing the absolute value of the determinant of the Jacobian of the transformation for each pixel of the image out.
Typically this function would be used to determine a flux-conservation correction map for the target image specified in function cpl_image_warp_polynomial()
. For example,
* cpl_image_warp_polynomial(out, in, poly_x, poly_y, xprof, xrad, yprof, yrad); * correction_map = cpl_image_new(cpl_image_get_size_x(out), * cpl_image_get_size_y(out), * cpl_image_get_type(out)); * cpl_image_warp_polynomial_scale(correction_map, poly_x, poly_y); * out_flux_corrected = cpl_image_multiply_create(out, correction_map); *
where out_flux_corrected is the resampled image out after correction for flux conservation.
Possible _cpl_error_code_ set in this function:
Definition at line 1011 of file xsh_utils_image.c.
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
[in] | data | imagelist |
[in] | mask | corresponding mask |
[out] | data_ima | average image |
[out] | mask_ima | corresponding mask |
[in] | mk | index |
Definition at line 3077 of file xsh_utils_image.c.
Referenced by xsh_build_ifu_cube(), and xsh_util_ifu_build_cube().
void xsh_pixel_qsort | ( | pixelvalue * | pix_arr, | |
int | npix | |||
) |
Definition at line 1725 of file xsh_utils_image.c.
References PIX_STACK_SIZE, PIX_SWAP, and xsh_msg_error.
Referenced by xsh_clean_mean(), and xsh_image_search_bad_pixels_via_noise().
cpl_image* xsh_scharr_x | ( | cpl_image * | in | ) |
Compute X Scharr filter transformation.
in | input image |
Definition at line 1130 of file xsh_utils_image.c.
References check.
Referenced by main(), and xsh_compute_flat_edges().
cpl_image* xsh_scharr_y | ( | cpl_image * | in | ) |
Compute Y Scharr filter transformation.
in | input image |
Definition at line 1169 of file xsh_utils_image.c.
References check.
Referenced by main().
void xsh_show_interpolation_kernel | ( | char * | kernel_name | ) |
Definition at line 648 of file xsh_utils_image.c.
References KERNEL_SAMPLES, TABSPERPIX, x, and xsh_generate_interpolation_kernel().
static double xsh_sinc | ( | double | x | ) | [static] |
Definition at line 294 of file xsh_utils_image.c.
References M_PI.
Referenced by xsh_generate_interpolation_kernel().
cpl_image* xsh_sobel_lx | ( | cpl_image * | in | ) |
Compute X Sobel filter transformation.
in | input image |
Definition at line 1207 of file xsh_utils_image.c.
References check.
Referenced by main(), and xsh_compute_flat_edges().
cpl_image* xsh_sobel_ly | ( | cpl_image * | in | ) |
Compute Y Sobel filter transformation.
in | input image |
Definition at line 1247 of file xsh_utils_image.c.
References check.
Referenced by main().
static cpl_error_code xsh_util_compute_qc_residuals | ( | cpl_table * | table, | |
xsh_instrument * | instrument, | |||
cpl_propertylist * | plist | |||
) | [static] |
Definition at line 2785 of file xsh_utils_image.c.
References check, qc_table, XSH_ARM_UVB, XSH_ARM_VIS, xsh_free_table(), xsh_instrument_get_arm(), XSH_QC_TRACE12_AVG, XSH_QC_TRACE12_MAX, XSH_QC_TRACE12_MED, XSH_QC_TRACE12_MIN, XSH_QC_TRACE12_RMS, XSH_QC_TRACE13_AVG, XSH_QC_TRACE13_MAX, XSH_QC_TRACE13_MED, XSH_QC_TRACE13_MIN, XSH_QC_TRACE13_RMS, XSH_QC_TRACE32_AVG, XSH_QC_TRACE32_MAX, XSH_QC_TRACE32_MED, XSH_QC_TRACE32_MIN, and XSH_QC_TRACE32_RMS.
Referenced by xsh_cube_qc_trace_window().
cpl_image* xsh_warp_image_generic | ( | cpl_image * | image_in, | |
char * | kernel_type, | |||
cpl_polynomial * | poly_u, | |||
cpl_polynomial * | poly_v | |||
) |
Definition at line 343 of file xsh_utils_image.c.
References TABSPERPIX, x, xsh_generate_interpolation_kernel(), xsh_msg_error, and y.
Referenced by main().