VIRCAM Pipeline  2.3.12
casu_inpaint.c
1 /* $Id: casu_inpaint.c,v 1.2 2015/08/07 13:06:54 jim Exp $
2  *
3  * This file is part of the CASU Pipeline utilities
4  * Copyright (C) 2015 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: jim $
23  * $Date: 2015/08/07 13:06:54 $
24  * $Revision: 1.2 $
25  * $Name: $
26  */
27 
28 /* Includes */
29 
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 #include <cpl.h>
35 #include <string.h>
36 
37 #include "casu_mods.h"
38 #include "catalogue/casu_utils.h"
39 #include "casu_filt.h"
40 #include "catalogue/casu_fits.h"
41 #include "casu_mask.h"
42 #include "casu_stats.h"
43 
46 /*---------------------------------------------------------------------------*/
81 /*---------------------------------------------------------------------------*/
82 
83 extern int casu_inpaint(casu_fits *in, int nbsize, int *status) {
84  int i,nx,ny;
85  float *data,*skymap,avback;
86  cpl_binary *bpm;
87  cpl_image *im;
88 
89  /* Inherited status */
90 
91  if (*status != CASU_OK)
92  return(*status);
93 
94  /* Set the data arrays */
95 
96  im = casu_fits_get_image(in);
97  data = cpl_image_get_data_float(im);
98  bpm = cpl_mask_get_data(cpl_image_get_bpm(im));
99  nx = (int)cpl_image_get_size_x(im);
100  ny = (int)cpl_image_get_size_y(im);
101 
102  /* Model out the background */
103 
104  casu_backmap(data,bpm,nx,ny,nbsize,&avback,&skymap,status);
105 
106  /* Now inpaint the bad bits */
107 
108  for (i = 0; i < nx*ny; i++)
109  if (bpm[i])
110  data[i] = skymap[i];
111  freespace(skymap);
112 
113  /* Get out of here */
114 
115  GOOD_STATUS
116 }
117 
118 
121 /*
122 
123 $Log: casu_inpaint.c,v $
124 Revision 1.2 2015/08/07 13:06:54 jim
125 Fixed copyright to ESO
126 
127 Revision 1.1.1.1 2015/06/12 10:44:32 jim
128 Initial import
129 
130 Revision 1.6 2015/03/12 09:16:51 jim
131 Modified to remove some compiler moans
132 
133 Revision 1.5 2015/01/29 11:51:56 jim
134 modified comments
135 
136 Revision 1.4 2015/01/09 12:13:15 jim
137 *** empty log message ***
138 
139 Revision 1.3 2014/03/26 15:49:55 jim
140 Modified to use casu_backmap routine
141 
142 Revision 1.2 2013/11/21 09:38:14 jim
143 detabbed
144 
145 Revision 1.1.1.1 2013-08-27 12:07:48 jim
146 Imported
147 
148 
149 */
cpl_image * casu_fits_get_image(casu_fits *p)
Definition: casu_fits.c:436
int casu_inpaint(casu_fits *in, int nbsize, int *status)
Inpaint pixels or patches in a map.
Definition: casu_inpaint.c:83
int casu_backmap(float *map, cpl_binary *bpm, int nx, int ny, int nbsize, float *avback, float **skymap, int *status)
Model background of an image.
Definition: casu_backmap.c:108