88 check(qual0 = cpl_image_get_data_int(right->
qual));
89 check(qual1 = cpl_image_get_data_int(self->
qual));
93 for(i=0;i<self->
nx*self->
ny;i++) {
94 qual1[i] |= qual0[i] ;
111 const char* fname=NULL;
112 cpl_propertylist* plist=NULL;
113 cpl_image* image=NULL;
116 cpl_frame* master=NULL;
117 master=cpl_frame_duplicate(bpmap);
118 fname=cpl_frame_get_filename(bpmap);
119 plist=cpl_propertylist_load(fname,0);
120 image=cpl_image_load(fname,CPL_TYPE_INT,0,0);
122 sprintf(bname,
"%s.fits",btag);
125 cpl_frame_set_filename(master,bname);
126 cpl_frame_set_tag(master,btag);
142 nx = cpl_image_get_size_x(*image);
143 ny = cpl_image_get_size_y(*image);
146 for (iy = 0; iy <
ny; iy++) {
148 for (ix = 0; ix <
nx; ix++) {
150 if ((bppix[j] & decode_bp) > 0 ) {
151 cpl_image_reject(*image, ix + 1, iy + 1);
155 return cpl_error_get_code();
179 const cpl_mask * input_mask,
184 cpl_mask * kernel = NULL;
185 cpl_mask * filtered_mask = NULL;
186 cpl_mask * expanded_mask = NULL;
187 cpl_mask * expanded_filtered_mask = NULL;
190 cpl_ensure(input_mask != NULL, CPL_ERROR_NULL_INPUT, NULL);
191 cpl_ensure(kernel_nx >= 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
192 cpl_ensure(kernel_ny >= 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
193 cpl_ensure(
filter == CPL_FILTER_EROSION ||
filter == CPL_FILTER_DILATION ||
194 filter == CPL_FILTER_OPENING ||
filter == CPL_FILTER_CLOSING,
195 CPL_ERROR_ILLEGAL_INPUT, NULL);
198 cpl_ensure((kernel_nx&1) == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
199 cpl_ensure((kernel_ny&1) == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
201 kernel = cpl_mask_new(kernel_nx, kernel_ny);
202 cpl_mask_not(kernel);
206 expanded_mask = cpl_mask_new(
207 cpl_mask_get_size_x(input_mask) + 2 * kernel_nx,
208 cpl_mask_get_size_y(input_mask) + 2 * kernel_ny);
210 cpl_mask_copy(expanded_mask, input_mask, kernel_nx + 1, kernel_ny +1 );
212 expanded_filtered_mask = cpl_mask_new(cpl_mask_get_size_x(expanded_mask),
213 cpl_mask_get_size_y(expanded_mask));
215 if(cpl_mask_filter(expanded_filtered_mask, expanded_mask, kernel,
filter,
216 CPL_BORDER_ZERO) != CPL_ERROR_NONE) {
218 cpl_mask_delete(kernel);
219 cpl_mask_delete(expanded_filtered_mask);
220 cpl_mask_delete(expanded_mask);
225 filtered_mask = cpl_mask_extract(expanded_filtered_mask,
226 kernel_nx+1, kernel_ny + 1,
227 cpl_mask_get_size_x(input_mask) + kernel_nx,
228 cpl_mask_get_size_y(input_mask) + kernel_ny);
232 cpl_mask_delete(kernel);
233 cpl_mask_delete(expanded_filtered_mask);
234 cpl_mask_delete(expanded_mask);
236 return filtered_mask;
249 cpl_mask *mask = NULL;
251 assure( qual != NULL, CPL_ERROR_NULL_INPUT,
252 "QUAL input is NULL pointer" );
253 cpl_size
nx=cpl_image_get_size_x(qual);
254 cpl_size
ny=cpl_image_get_size_y(qual);
256 mask=cpl_mask_new(
nx,
ny);
257 int* pqual=cpl_image_get_data_int(qual);
258 cpl_binary* pmask=cpl_mask_get_data(mask);
260 for(
int i=0;i<
size;i++){
261 if( (pqual[i] & code) ==0 ) {
263 pmask[i]=CPL_BINARY_1;
280 cpl_mask *mask = NULL;
282 assure( qual != NULL, CPL_ERROR_NULL_INPUT,
283 "QUAL input is NULL pointer" );
284 cpl_size
nx=cpl_image_get_size_x(qual);
285 cpl_size
ny=cpl_image_get_size_y(qual);
287 mask=cpl_mask_new(
nx,
ny);
288 int* pqual=cpl_image_get_data_int(qual);
289 cpl_binary* pmask=cpl_mask_get_data(mask);
291 for(
int i=0;i<
size;i++){
292 if( (pqual[i] & decode_bp) >0 ) {
294 pmask[i]=CPL_BINARY_1;
313 assure( bpmap != NULL, CPL_ERROR_NULL_INPUT,
314 "BpMap is NULL pointer" );
316 check(bppix = cpl_image_get_data_int (bpmap));
338 nx=cpl_image_get_size_x(image);
339 ny=cpl_image_get_size_y(image);
340 mask=cpl_mask_new(
nx,
ny);
341 pmsk=cpl_mask_get_data(mask);
342 pmap=cpl_image_get_data_int(bpmap);
348 pmsk[pix]=CPL_BINARY_1;
353 cpl_image_reject_from_mask(image,mask);
366 check(
nx = cpl_image_get_size_x(bpmap));
367 check(
ny = cpl_image_get_size_y(bpmap));
369 check(
data = cpl_image_get_data_float(bpmap));
371 for(i=0;i<
nx*
ny;i++){
388 cpl_mask* old = NULL;
389 cpl_binary* maskdata = NULL;
390 int i = 0,
nx = 0,
ny = 0;
393 assure(bpmap != NULL, CPL_ERROR_NULL_INPUT,
"BpMap is NULL pointer" ) ;
394 assure(mask != NULL, CPL_ERROR_NULL_INPUT,
"mask is NULL pointer" ) ;
397 check(
nx = cpl_image_get_size_x(bpmap));
398 check(
ny = cpl_image_get_size_y(bpmap));
399 assure(
nx == cpl_mask_get_size_x(mask),CPL_ERROR_ILLEGAL_INPUT,
400 "mask %" CPL_SIZE_FORMAT
" and image %d must have same size in x",
401 cpl_mask_get_size_x(mask),
nx);
402 assure(
ny == cpl_mask_get_size_y(mask),CPL_ERROR_ILLEGAL_INPUT,
403 "mask %" CPL_SIZE_FORMAT
" and image %d must have same size in y",
404 cpl_mask_get_size_y(mask),
ny);
407 check( old = cpl_image_get_bpm(bpmap));
410 check(maskdata = cpl_mask_get_data(mask));
415 for(i=0;i<
nx*
ny;i++){
422 check(cpl_mask_or(old,mask));
431 cpl_image_set (bpmap, ix, iy, (
double) flag);
432 cpl_image_reject (bpmap, ix, iy);
448 cpl_image *bpmap = NULL;
452 cpl_image *result = NULL;
454 xsh_msg(
"---> xsh_bpmap_collapse_bpmap_create" ) ;
455 bpmap = cpl_image_duplicate (cpl_imagelist_get (liste, 0));
456 assure (bpmap != NULL, cpl_error_get_code (),
"Cant duplicate first bpmap");
458 bppix = cpl_image_get_data_int (bpmap);
459 assure (bppix != NULL, cpl_error_get_code (),
"Cant get data int");
461 nimg = cpl_imagelist_get_size (liste);
463 nx = cpl_image_get_size_x (bpmap);
464 ny = cpl_image_get_size_y (bpmap);
468 for (i = 1; i < nimg; i++) {
470 cpl_image *current = NULL;
473 current = cpl_imagelist_get (liste, i);
474 assure (current != NULL, cpl_error_get_code (),
"Cant get bpmap #%d", i);
476 curpix = cpl_image_get_data_int (current);
477 assure (curpix != NULL, cpl_error_get_code (),
478 "Cant get data int for bpmap #%d", i);
480 for (j = 0; j < npix; j++)
481 bppix[j] |= curpix[j];
484 result = cpl_image_wrap_int (
nx,
ny, bppix);
485 assure (result != NULL, cpl_error_get_code (),
"Cant wrap final bpmap");
508 int i, count = 0, npix =
nx *
ny;
510 pixbuf = cpl_image_get_data_int (bpmap);
511 assure (pixbuf != NULL, cpl_error_get_code (),
"Cant get pixel buffer");
513 for (i = 0; i < npix; i++) {
514 if (*(pixbuf + i) != 0)
535 cpl_image **pimg = NULL;
536 cpl_vector *pixvector = NULL;
538 cpl_binary* mask_data = NULL;
545 check(
nx = cpl_image_get_size_x(median));
546 check(
ny = cpl_image_get_size_y(median));
547 check(nimg = cpl_imagelist_get_size(list));
553 for (i = 0; i < nimg; i++){
554 *(pimg + i) = cpl_imagelist_get (list, i);
555 assure(cpl_image_get_size_x(*(pimg + i)) ==
nx,CPL_ERROR_ILLEGAL_INPUT,
556 " data list x size is not equal to median frame");
557 assure(cpl_image_get_size_y(*(pimg + i)) ==
ny,CPL_ERROR_ILLEGAL_INPUT,
558 " data list y size is not equal to median frame");
563 check(mask_data = cpl_mask_get_data(bpmap));
565 for (iy = 1; iy <=
ny; iy++) {
567 for (ix = 1; ix <=
nx; ix++) {
570 if (mask_data[(iy-1)*
nx+ix-1] == CPL_BINARY_0){
571 for (k = 0; k < nimg; k++) {
575 check (val = cpl_image_get (pimg[k], ix, iy, &rej) ) ;
586 check(pixvector = cpl_vector_wrap(count,
data));
587 check(med = cpl_vector_get_median( pixvector));
588 check(cpl_image_set(median, ix, iy, med));
595 if (cpl_error_get_code() != CPL_ERROR_NONE){
616 cpl_image **pimg = NULL;
617 cpl_vector *pixvector = NULL;
619 cpl_binary* mask_data = NULL;
626 check(
nx = cpl_image_get_size_x(mean));
627 check(
ny = cpl_image_get_size_y(mean));
628 check(nimg = cpl_imagelist_get_size(list));
634 for (i = 0; i < nimg; i++){
635 *(pimg + i) = cpl_imagelist_get (list, i);
636 assure(cpl_image_get_size_x(*(pimg + i)) ==
nx,CPL_ERROR_ILLEGAL_INPUT,
637 " data list x size is not equal to median frame");
638 assure(cpl_image_get_size_y(*(pimg + i)) ==
ny,CPL_ERROR_ILLEGAL_INPUT,
639 " data list y size is not equal to median frame");
644 check(mask_data = cpl_mask_get_data(bpmap));
646 for (iy = 1; iy <=
ny; iy++) {
648 for (ix = 1; ix <=
nx; ix++) {
651 if (mask_data[(iy-1)*
nx+ix-1] == CPL_BINARY_0){
652 for (k = 0; k < nimg; k++) {
656 check (val = cpl_image_get (pimg[k], ix, iy, &rej) ) ;
667 check(pixvector = cpl_vector_wrap(count,
data));
668 check(avg = cpl_vector_get_mean( pixvector));
669 check(cpl_image_set(mean, ix, iy, avg ));
676 if (cpl_error_get_code() != CPL_ERROR_NONE){
694 assure( CPL_TYPE_INT == cpl_image_get_type(qual), cpl_error_get_code(),
695 "wrong ima qual data type");
696 int nx = cpl_image_get_size_x(qual);
697 int ny = cpl_image_get_size_y(qual);
703 int* pqual=cpl_image_get_data_int(qual);
704 cpl_mask* bpm=cpl_image_get_bpm(image);
705 cpl_binary* pbpm=cpl_mask_get_data(bpm);
707 for(
int j=0;j<
ny;j++) {
709 for(
int i=0;i<
nx;i++) {
710 if( pbpm[j_nx+i] == CPL_BINARY_1 ) {
717 return cpl_error_get_code();
732 const int* pright=NULL;
738 check(
nx = cpl_image_get_size_x(*self));
739 check(
ny = cpl_image_get_size_y(*self));
740 assure(
nx == cpl_image_get_size_x(right),CPL_ERROR_ILLEGAL_INPUT,
741 "addendum mask %" CPL_SIZE_FORMAT
" and original mask %d must have same size in x",
742 cpl_image_get_size_x(right),
nx);
743 assure(
ny == cpl_image_get_size_y(right),CPL_ERROR_ILLEGAL_INPUT,
744 "addendum mask %" CPL_SIZE_FORMAT
" and original mask %d must have same size in y",
745 cpl_image_get_size_y(right),
ny);
748 pself=cpl_image_get_data_int(*self);
749 pright=cpl_image_get_data_int_const(right);
756 pself[j_nx+i]|=pright[j_nx+i];
766 pself[j_nx+i]&=pright[j_nx+i];
772 return cpl_error_get_code();
790 const char* self_name=NULL;
791 const char* right_name=NULL;
792 cpl_image* map_self=NULL;
793 cpl_image* map_right=NULL;
794 cpl_propertylist* plist=NULL;
798 assure(self != NULL, CPL_ERROR_NULL_INPUT,
"BpMap is NULL pointer" ) ;
799 assure(right != NULL, CPL_ERROR_NULL_INPUT,
"mask is NULL pointer" ) ;
801 check(self_name=cpl_frame_get_filename(self));
802 check(right_name=cpl_frame_get_filename(right));
804 check(plist=cpl_propertylist_load(self_name,0));
806 check(map_self=cpl_image_load(self_name,CPL_TYPE_INT,0,0));
807 check(map_right=cpl_image_load(right_name,CPL_TYPE_INT,0,0));
808 xsh_msg(
"Bit-wise OR of %s with %s frame",
809 cpl_frame_get_tag(self),cpl_frame_get_tag(right));
821 check(cpl_image_save(map_self,
"BP_COMBINE.fits",CPL_BPP_IEEE_FLOAT,
822 plist,CPL_IO_DEFAULT));
823 cpl_frame_set_filename(self,
"BP_COMBINE.fits");
832 return cpl_error_get_code();
847 const char* frame_name=NULL;
848 const char* bpmap_name=NULL;
849 const char* frame_tag=NULL;
851 cpl_image* map_self=NULL;
852 cpl_image* map_right=NULL;
853 cpl_frame* product=NULL;
855 assure(frame != NULL, CPL_ERROR_NULL_INPUT,
"INPUT frame is NULL pointer" ) ;
856 assure(bpmap != NULL, CPL_ERROR_NULL_INPUT,
"BP MAP frame is NULL pointer" ) ;
858 check(frame_name=cpl_frame_get_filename(frame));
859 check(frame_tag=cpl_frame_get_tag(frame));
860 check(bpmap_name=cpl_frame_get_filename(bpmap));
863 check(map_right=cpl_image_load(bpmap_name,CPL_TYPE_INT,0,0));
872 return cpl_error_get_code();
896 const double kappa_low,
897 const double kappa_high,
899 const int high_niter,
904 cpl_propertylist** hplist,
905 cpl_propertylist** cplist)
916 cpl_image_get_size_x(masterbias),
917 cpl_image_get_size_y(masterbias),
928 cpl_image_accept_all(masterbias);
931 check(dark_med = cpl_image_get_median(masterbias));
934 lower = dark_med - stdev * kappa_low;
939 check_msg(*bpmcold = cpl_mask_threshold_image_create(masterbias,
941 "Cannot compute the cold pixel map");
945 check(*coldpix_nb = cpl_mask_count(*bpmcold));
955 cpl_image_get_size_x(masterbias),
956 cpl_image_get_size_y(masterbias),
968 cpl_image_accept_all(masterbias);
972 check(dark_med = cpl_image_get_median(masterbias));
975 upper = dark_med + stdev * kappa_high;
978 check_msg(*bpmhot = cpl_mask_threshold_image_create(masterbias,
980 "Cannot compute the hot pixel map");
983 check(*hotpix_nb = cpl_mask_count(*bpmhot));
993 return cpl_error_get_code();
1011 const double ks_low,
1012 const int cold_niter,
1013 const double ks_high,
1014 const int hot_niter,
1015 cpl_frame** cpix_frm,
1016 cpl_frame** hpix_frm)
1021 cpl_image* image=NULL;
1023 cpl_mask* bpmcold=NULL;
1024 cpl_mask* bpmhot=NULL;
1027 cpl_image* cpix_ima=NULL;
1028 cpl_image* hpix_ima=NULL;
1029 cpl_propertylist* cplist=NULL;
1030 cpl_propertylist* hplist=NULL;
1031 cpl_propertylist* plist=NULL;
1034 const char* cpix_pro_catg=NULL;
1035 const char* hpix_pro_catg=NULL;
1036 char* cpix_name=NULL;
1037 char* hpix_name=NULL;
1038 const char* name=NULL;
1040 check(name=cpl_frame_get_filename(frame_image));
1042 check(image=cpl_image_load(cpl_frame_get_filename(frame_image),
1043 CPL_TYPE_FLOAT,0,0));
1046 check(hplist=cpl_propertylist_new());
1047 check(cplist=cpl_propertylist_new());
1048 xsh_msg(
"determine hot and cold pixels");
1050 ks_low,ks_high,cold_niter,hot_niter,
1052 &bpmcold,&coldpix_nb,&hplist,&cplist));
1055 xsh_msg(
"Hot pix nb=%d Cold pix nb=%d",hotpix_nb,coldpix_nb);
1058 check(cpix_ima=cpl_image_new_from_mask(bpmcold));
1069 check(plist=cpl_propertylist_load(name,0));
1070 check(cpl_propertylist_append(plist,cplist));
1071 cpl_image_save(cpix_ima,cpix_name,CPL_BPP_32_SIGNED,plist,CPL_IO_DEFAULT);
1080 CPL_FRAME_TYPE_IMAGE,
1081 CPL_FRAME_GROUP_PRODUCT,
1082 CPL_FRAME_LEVEL_FINAL));
1085 check(hpix_ima=cpl_image_new_from_mask(bpmhot));
1095 check(plist=cpl_propertylist_load(name,0));
1096 check(cpl_propertylist_append(plist,hplist));
1097 cpl_image_save(hpix_ima,hpix_name,CPL_BPP_32_SIGNED,plist,CPL_IO_DEFAULT);
1104 CPL_FRAME_TYPE_IMAGE,
1105 CPL_FRAME_GROUP_PRODUCT,
1106 CPL_FRAME_LEVEL_FINAL));
1121 return cpl_error_get_code();
1149 cpl_image* msk=NULL;
1152 cpl_frame* msk_frm=NULL;
1154 nx=cpl_image_get_size_x(ima);
1155 ny=cpl_image_get_size_y(ima);
1156 msk=cpl_image_new(
nx,
ny,CPL_TYPE_DOUBLE);
1158 pima=cpl_image_get_data_double(ima);
1159 pmsk=cpl_image_get_data_double(msk);
1161 for(j=r;j<
ny-r;j++) {
1162 for(i=r;i<
nx-r;i++) {
1163 check(rms=cpl_image_get_stdev_window(ima,i-r+1,j-r+1,i+r,j+r));
1164 check(med=cpl_image_get_median_window(ima,i-r+1,j-r+1,i+r,j+r));
1165 if(pima[i+j*
nx]< med-
kappa*rms) {
1172 sprintf(name,
"%s.fits",tag);
1177 CPL_FRAME_GROUP_PRODUCT,
1178 CPL_FRAME_LEVEL_FINAL));
1210 cpl_image* msk=NULL;
1213 cpl_frame* msk_frm=NULL;
1215 nx=cpl_image_get_size_x(ima);
1216 ny=cpl_image_get_size_y(ima);
1217 msk=cpl_image_new(
nx,
ny,CPL_TYPE_DOUBLE);
1219 pima=cpl_image_get_data_double(ima);
1220 pmsk=cpl_image_get_data_double(msk);
1222 for(j=r;j<
ny-r;j++) {
1223 for(i=r;i<
nx-r;i++) {
1224 check(rms=cpl_image_get_stdev_window(ima,i-r+1,j-r+1,i+r,j+r));
1225 check(med=cpl_image_get_median_window(ima,i-r+1,j-r+1,i+r,j+r));
1226 if(pima[i+j*
nx]> med+
kappa*rms) {
1233 sprintf(name,
"%s.fits",tag);
1237 CPL_FRAME_GROUP_PRODUCT,
1238 CPL_FRAME_LEVEL_FINAL));
1267 nx=cpl_image_get_size_x(*ima);
1268 ny=cpl_image_get_size_y(*ima);
1270 pima=cpl_image_get_data_double(*ima);
1271 pmsk=cpl_image_get_data_double(msk);
1273 for(j=r;j<
ny-r;j++) {
1274 for(i=r;i<
nx-r;i++) {
1275 check(med=cpl_image_get_median_window(*ima,i-r+1,j-r+1,i+r,j+r));
1276 if(pmsk[i+j*
nx]==1) {
1283 return cpl_error_get_code();
1287static cpl_error_code
1295 const float* padd=NULL;
1301 check(nx1=cpl_image_get_size_x(*self));
1302 check(ny1=cpl_image_get_size_y(*self));
1305 check(nx2=cpl_image_get_size_x(add));
1306 check(ny2=cpl_image_get_size_y(add));
1308 pself=cpl_image_get_data_float(*self);
1309 padd=cpl_image_get_data_float_const(add);
1311 if (nx1 != nx2 || ny1 != ny2) {
1312 xsh_msg(
"Input image of different size");
1314 for(i=0;i<nx1*ny2;i++){
1315 if( (pself[i]==0) && (padd[i] !=0) ) {
1320 return cpl_error_get_code();
1330 cpl_image* shift=NULL;
1331 cpl_image* res=NULL;
1334 res=cpl_image_duplicate(ima);
1337 shift=cpl_image_duplicate(ima);
1338 cpl_image_shift(shift,1,0);
1343 shift=cpl_image_duplicate(ima);
1344 cpl_image_shift(shift,-1,0);
1349 shift=cpl_image_duplicate(ima);
1350 cpl_image_shift(shift,0,-1);
1355 shift=cpl_image_duplicate(ima);
1356 cpl_image_shift(shift,0,1);
1380 check(pqual=cpl_image_get_data_int(pre->
qual));
1381 for(i=0;i<
size;i++) {
1392 xsh_msg(
"datancom=%d",datancom);
1393 ncrh_avg=ncrh/datancom;
1398 return cpl_error_get_code();
1421 check(pqual=cpl_image_get_data_int(pre->
qual));
1422 for(i=0;i<
size;i++) {
1423 if( (bp_code_sat & pqual[i]) > 0 ) {
1429 xsh_msg(
"datancom=%d",datancom);
1430 nsat_avg=nsat/datancom;
1431 nsat_avg=((float)nsat/
size);
1436 return cpl_error_get_code();
1441 const double cor_val,
const int flag,
1442 const int is_flat,
int* nsat)
1450 double thresh_max=0;
1467 check(pima=cpl_image_get_data_float(pre->
data));
1468 check(pqual=cpl_image_get_data_int(pre->
qual));
1477 thresh_max=thresh_max -cor_val;
1483 double thresh_min=1-cor_val;
1491 if( pima[ipix] > thresh_max) {
1492 pqual[ipix] |= bp_code_sat;
1495 if ( cpima < thresh_min ) {
1496 pqual[ipix] |= bp_code_neg;
1503 for(i=0;i<knx;i++) {
1505 if( pima[ipix] > thresh_max) {
1514 return cpl_error_get_code();
1519 const double thresh_min,
1520 const double thresh_max,
1521 const double cor_val,
1530 pdata=cpl_image_get_data_float(pre->
data);
1531 for(i=0;i<
size;i++) {
1532 if(pdata[i]>=(thresh_min-cor_val) &&
1533 pdata[i]<=(thresh_max-cor_val)) {
1537 *frange=(double)(*nrange)/(
size);
1538 return cpl_error_get_code();
1544 const double cor_val,
int* nsat,
1552 pdata=cpl_image_get_data_float(pre->
data);
1553 for(i=0;i<
size;i++) {
1554 if(pdata[i]>=(sat_thresh-cor_val) || pdata[i]==-cor_val) (*nsat)++;
1556 *frac_sat=(double)(*nsat)/(
size);
1557 return cpl_error_get_code();
1565 const char* name=NULL;
1566 cpl_image* dima=NULL;
1567 cpl_image* eima=NULL;
1568 cpl_image* qima=NULL;
1569 cpl_propertylist* phead=NULL;
1570 cpl_propertylist* ehead=NULL;
1571 cpl_propertylist* qhead=NULL;
1582 name=cpl_frame_get_filename(frm);
1586 phead=cpl_propertylist_load(name,0);
1587 ehead=cpl_propertylist_load(name,1);
1588 qhead=cpl_propertylist_load(name,2);
1589 pima=cpl_image_get_data_int(qima);
1590 nx=cpl_image_get_size_x(qima);
1591 ny=cpl_image_get_size_y(qima);
1597 for(j=1;j<
ny-1;j++){
1599 for(i=1;i<
nx-1;i++){
1627 return cpl_error_get_code();
1655 cpl_image* ima=NULL;
1656 cpl_image* ext=NULL;
1657 cpl_propertylist* plist=NULL;
1658 const char* fname=NULL;
1659 cpl_frame* result=NULL;
1664 result=cpl_frame_duplicate(frame);
1665 fname=cpl_frame_get_filename(frame);
1666 plist=cpl_propertylist_load(fname,0);
1668 ext=cpl_image_extract(ima,xmin,ymin,xmax,ymax);
1669 sprintf(name_o,
"SUB_%s",fname);
1671 check( cpl_frame_set_filename( result, name_o));
1675 if( cpl_error_get_code() != CPL_ERROR_NONE) {
static xsh_instrument * instrument
cpl_error_code xsh_count_crh(xsh_pre *pre, xsh_instrument *instr, const int datancom)
cpl_mask * xsh_qual_to_cpl_mask(cpl_image *qual, const int decode_bp)
void xsh_badpixelmap_or(xsh_pre *self, const xsh_pre *right)
cpl_mask * xsh_code_is_in_qual(cpl_image *qual, const int code)
cpl_error_code xsh_frame_qual_update(cpl_frame *frame, const cpl_frame *bpmap, xsh_instrument *inst)
static cpl_error_code xsh_image_get_hot_cold_maps(cpl_image *masterbias, const double kappa_low, const double kappa_high, const int low_niter, const int high_niter, cpl_mask **bpmhot, int *hotpix_nb, cpl_mask **bpmcold, int *coldpix_nb, cpl_propertylist **hplist, cpl_propertylist **cplist)
cpl_error_code xsh_image_clean_mask_pixs(cpl_image **ima, cpl_image *msk, const int r)
cpl_error_code xsh_image_get_hot_cold_pixs(cpl_frame *frame_image, xsh_instrument *instrument, const double ks_low, const int cold_niter, const double ks_high, const int hot_niter, cpl_frame **cpix_frm, cpl_frame **hpix_frm)
cpl_image * xsh_image_flag_bptype_with_crox(cpl_image *ima)
cpl_image * xsh_bpmap_collapse_bpmap_create(cpl_imagelist *liste, const int decode_bp)
cpl_error_code xsh_badpixelmap_flag_saturated_pixels(xsh_pre *pre, xsh_instrument *instr, const double cor_val, const int flag, const int is_flat, int *nsat)
cpl_mask * xsh_bpm_filter(const cpl_mask *input_mask, cpl_size kernel_nx, cpl_size kernel_ny, cpl_filter_mode filter)
Allows the growing and shrinking of bad pixel masks. It can be used to e.g. set pixels to bad if the ...
static cpl_error_code xsh_flag_ima_bad_pix(cpl_image **image, int *bppix, const int decode_bp)
void xsh_image_flag_bp(cpl_image *image, cpl_image *bpmap, xsh_instrument *inst)
cpl_error_code xsh_badpixelmap_count_sat_pixels(xsh_pre *pre, const double sat_thresh, const double cor_val, int *nsat, double *frac_sat)
void xsh_bpmap_collapse_mean(cpl_image *mean, cpl_imagelist *list, cpl_mask *bpmap)
static cpl_error_code xsh_image_coadd(cpl_image **self, const cpl_image *add)
void xsh_bpmap_collapse_median(cpl_image *median, cpl_imagelist *list, cpl_mask *bpmap)
void xsh_bpmap_bitwise_to_flag(cpl_image *bpmap, int flag)
int xsh_bpmap_count(cpl_image *bpmap, int nx, int ny)
cpl_error_code xsh_badpixelmap_image_coadd(cpl_image **self, const cpl_image *right, const int mode)
void xsh_bpmap_set_bad_pixel(cpl_image *bpmap, int ix, int iy, int flag)
cpl_frame * xsh_image_local_cold_pixs(cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
cpl_frame * xsh_badpixelmap_crea_master_from_bpmap(cpl_frame *bpmap, xsh_instrument *inst)
cpl_error_code xsh_badpixelmap_count_range_pixels(xsh_pre *pre, const double thresh_min, const double thresh_max, const double cor_val, int *nrange, double *frange)
cpl_error_code xsh_badpixelmap_coadd(cpl_frame *self, const cpl_frame *right, const int mode)
cpl_error_code xsh_count_satpix(xsh_pre *pre, xsh_instrument *instr, const int datancom)
void xsh_bpmap_mask_bad_pixel(cpl_image *bpmap, cpl_mask *mask, int flag)
void xsh_set_image_cpl_bpmap(cpl_image *image, cpl_image *bpmap, const int decode_bp)
cpl_frame * xsh_image_local_hot_pixs(cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
cpl_frame * xsh_badpixelmap_extract(cpl_frame *frame, int xmin, int ymin, int xmax, int ymax)
This function create a sub bad pixel map frame from input bad pixel map frame. the sub frame is descr...
cpl_error_code xsh_badpixelmap_fill_bp_pattern_holes(cpl_frame *frm)
cpl_error_code xsh_badpixel_flag_rejected(cpl_image *qual, cpl_image *image)
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
#define XSH_ASSURE_NOT_NULL_MSG(pointer, msg)
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define assure(CONDITION, ERROR_CODE,...)
#define check_msg(COMMAND,...)
#define XSH_ASSURE_NOT_NULL(pointer)
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
#define xsh_msg(...)
Print a message on info level.
#define xsh_msg_dbg_low(...)
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
void xsh_pfits_set_total_frac_sat(cpl_propertylist *plist, double value)
Write the fraction of saturated pixels value.
void xsh_pfits_set_total_nsat(cpl_propertylist *plist, int value)
Write the total number of saturated pixels value.
void xsh_pfits_set_qc_ncrh_mean(cpl_propertylist *plist, const double value)
Write the QC.NCRH.AVG value.
int xsh_pfits_get_qc_nhpix(const cpl_propertylist *plist)
find out the QC.NHPIX value
void xsh_pfits_set_qc_ncrh(cpl_propertylist *plist, int value)
Write the QC.NCRH value.
void xsh_pfits_set_qc_nhpix(cpl_propertylist *plist, int value)
Write the QC.NHPIX value.
void xsh_pfits_set_qc_noisepix(cpl_propertylist *plist, int value)
Write the QC.NHPIX value.
void xsh_unwrap_vector(cpl_vector **v)
Unwrap a vector and set the pointer to NULL.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_mask(cpl_mask **m)
Deallocate an image mask and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
cpl_propertylist * data_header
#define QFLAG_CAMERA_DEFECT
#define QFLAG_ADC_SATURATION
#define QFLAG_QUESTIONABLE_PIXEL
#define QFLAG_ELECTRONIC_PICKUP
#define QFLAG_WELL_SATURATION
#define QFLAG_COSMIC_RAY_REMOVED
#define QFLAG_ALL_PIX_BAD
#define QFLAG_SATURATED_DATA
#define QFLAG_NEGATIVE_DATA
#define QFLAG_LOW_QE_PIXEL
#define QFLAG_COSMIC_RAY_UNREMOVED
#define XSH_PRE_DATA_TYPE
#define XSH_PRE_QUAL_TYPE
#define XSH_PRE_ERRS_TYPE
static cpl_error_code TYPE_ADD() xsh_ksigma_clip(const CPL_TYPE *pi, cpl_binary *pm, int llx, int lly, int urx, int ury, int nx, double var_sum, int npixs, double kappa, int nclip, double tolerance, double *mean, double *stdev)
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_MASTER_BP_MAP_FLAT
#define XSH_QC_MASTER_RMS_C
#define XSH_QC_MASTER_MEAN
#define XSH_QC_MASTER_RMS
#define XSH_QC_HOT_PIX_NUM_C
#define XSH_QC_COLD_PIX_NUM
#define XSH_QC_COLD_PIX_NUM_C
#define XSH_QC_MASTER_MEAN_C
#define XSH_QC_HOT_PIX_NUM
#define XSH_FREE(POINTER)
#define XSH_MALLOC(POINTER, TYPE, SIZE)
#define XSH_CALLOC(POINTER, TYPE, SIZE)