{'fraction_non_alphanumeric': 0.026419993508601105, 'fraction_numerical': 0.013372281726712107, 'mean_word_length': 4.8466793168880455, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Bad pixel modified interpolation for astronomical images

We present a new method of interpolation for the pixel brightness estimation in astronomical images. Our new method is simple and easily implementable. We show the comparison of this method with the widely used linear interpolation and other interpolation algorithms using one thousand astronomical images obtained from the Sloan Digital Sky Survey. The comparison shows that our method improves bad pixels brightness estimation with four times lower mean error than the presently most popular linear interpolation and has a better performance than any other examined method. The presented idea is flexible and can be also applied to presently used and future interpolation methods. The proposed method is especially useful for large sky surveys image reduction but can be also applied to single image correction.


Introduction
Astronomical images taken with image sensors are nowadays one of the most important tools of the modern astronomy (Saha 2009;McLen 2008). The most popular are CCD and CMOS sensors which consist of a matrix of pixels, where the light flux can be measured thanks to the photovoltaic effect (Litwiller 2001;Janesick 2001;Hobson 1978). Unfortunately, not every pixel can be used effectively. It is due to the possible imperfections located within the pixel. The most commonly encountered problems are: high dark current, rate saturating the pixel's potential well; nonlinear dark current dependencies (Widenhorn 2010;Dunlap 2012;Popowicz 2011a,b); transient events of the dark current due to the irradiation (especially important for flight missions) (Hopkinson 2008(Hopkinson , 1996, pixel nonlinear light response and CCD fabrication defects (Janesick 2001). In professional CCD systems there are several methods developed for investigation of the so-called bad pixels (Hilbert 2012a,b). The bad pixel masks are created to help during the image reduction. This calibration is usually repeated periodically because new bad pixels can appear. One way to reduce bad pixels impact on the image quality is to take many images with slight shifts. Such a set of dithered pictures is shifted back and averaged, ignoring the pixels from the mask (Fruchter 2002). Unfortunately, it is not possible if there is only a single image and in such cases an interpolation over bad pixels is necessary. The most popular method is a linear interpolation which is a standard procedure in the most widespread astronomical software package: Image Reduction and Analysis Facility (IRAF) (Massey 1997). In this paper, we propose a new method of bad pixel interpolation for astronomical images. In chapter 2 we present the data which was chosen for the methods comparison. Next, in chapter 3.1, we describe most popular interpolation methods and we also introduce biharmonic interpolation algorithm as a new alternative for bad pixel correction. In chapter 3.2 we summarize the methodology of our tests and discuss the results. In chapter 4.1 we present our new method which is a modification of the biharmonic interpolation. The modification is dedicated especially for astronomical pictures calibration. We suggest some further enhancements which improve its effectiveness and precision. The result of our modified method compared to the original biharmonic interpolation are presented in chapter 4.2. We conclude in section 5.

Data
The verification data set made use of the astronomical images obtained by the Sloan Digital Sky Survey (SDSS) Data Release 7 (York 2000;Szalay 1999). The SDSS uses 2.5m Ritchey-Chretien telescope located at Apache Point Observatory in New Mexico. The imaging camera consists of an array of 30 CCD with total field of view of 3 degrees and operating in drift-scan imaging mode. We used SDSS Science Archive Server 1 (SAS) to download 1000 astronomical images. The images were previously calibrated by standard SDSS pipeline reduction procedures. We chose SDSS g filter images located at random positions on the sky (randomized RA and DEC coordinates). We present exemplary image in Fig. 1

Present methods of bad pixel interpolation
Five interpolation algorithms were compared with respect to pixel brightness estimation in the astronomical images: the median of the surrounding pixels, the nearest neighbor interpolation, the linear interpolation, the cubic spline interpolation and the biharmonic interpolation. The first and also the simplest method among the presented methods is the nearest neighbors interpolation. The brightness of the pixel in such a case is simply replaced by the brightness of an adjacent pixel. It is to be chosen which of four adjacent pixels to select. Although the selection is arbitrary, it does not influence the overall estimation quality. The second method uses the median of surrounding pixels. In our tests, for this method, we chose the median of all 8 surrounding pixels' brightness. The next method is the most popular for bad pixel interpolation in astronomical images -the linear interpolation. It is implemented in widespread astronomical software package IRAF in the fixpix procedure (Massey 1997). The interpolation is based on the linear interpolation along columns or rows of the image. In such a case simple mean value of the pixels adjacent to the bad pixel (in a row or in a column) is computed. Again, the decision of choosing row or column interpolation does not change the mean estimation error. The spline interpolation algorithm uses piecewise polynomials, called splines, to interpolate over the bad pixel along columns or rows. It finds the smoothest curve that passes through data points (Ahlberg 1967). In our experiments we used cubic spline interpolation which means that we chose the third order polynomials. The last method is the biharmonic interpolation. This method has not been used for the bad pixel interpolation yet. It is based on the linear combination of Green functions centered at each data point. Originally, the idea was applied for GEOS-3 and SEASAT altimeter data in 1987 (Sandwell 1987).

Comparison test
As we mentioned, we used 1000 calibrated astronomical images from SDSS data server. From every single image, two hundreds of 7x7 pixel fragments were extracted. The fragments, containing whole or only parts of astronomical objects (e.g. stars, galaxies), were selected with use of a threshold-based algorithm. It prevented from choosing fragments with the image background. The objects were not centered in each fragment. We did not use any special algorithm for object classification, so both point-like and extended objects were included in our tests. The center pixel of every fragment was chosen as an unknown and its brightness was estimated using previously mentioned interpolation methods. The brightness estimation was compared with the true value to calculate an error. The error absolute and relative value histograms for given interpolation methods are presented in Fig. 3 and 4. Additionally, a mean error (E) was computed to enable a quick comparison of the methods' effectiveness. The following averaging formula was used: where: E label mean error, ∆ i -i-th estimation error (absolute or relative) and N -total number of estimations. We also present point-plots (Fig. 5) to visualize dependency between the estimation error and the brightness of interpolated pixel for all tested methods. There is a clear difference in effectiveness between the used methods. The best results were obtained with the biharmonic interpolation with a mean error equal to 465 [ADU] (ADU stands for Analog-Digital Units and is a measure of signal from a CCD/CMOS pixel) and 0.063 relative, while the typically used method -linear interpolation -has an error far greater (872 [ADU] and 0.125 relative). The basis and an implementation of the most accurate interpolation are quite simple. According to (Sandwell 1987) the biharmonic interpolation is based on computation of α i coefficients (2). For given values of the intermediate points, the system of equations (2) can be easily solved as it is a linear one. The biharmonic interpolation as the most accurate method was used as a starting point for further enhancement. It should be also noticed that there is no evidence of applying such an interpolation for astronomical images reduction.
where: w(x i , y i ) -value of the interpolated function for x i , y i coordinates, N -number of intermediate points.

Presentation of the idea
The idea of the modified interpolation is based on the similarity between the objects (both point sources like stars or extended objects like galaxies) encountered in the astronom-ical pictures. According to (McLen 2008) a light from a star, as a point source, is affected by the atmosphere (so-called "seeing") and is blurred so that it is registered in the image not as a point but as a point-spread-function (PSF). The PSF can be modeled by the Gaussian surface (Pan 2009). Usually each star in a high quality telescope system and for more than several seconds exposure shows very similar PSF. However, sometimes PSF can be different due to the seeing variations during the exposure or due to the optical aberrations. Our modified interpolation idea can be applied whether the PSF is stable or not.
We construct the database of 7x7 pixel fragments from the parts of collected images not affected by the bad pixels. Because of the fact that most of the image is usually the background, a special threshold-based selection algorithm is used again to choose as many fragments with the objects as it is possible. Additionally, every fragment is rotated three times (90 • , 180 • , 270 • ) to extend the database and to provide for different orientation of extended objects. After the fragments' acquisition, the biharmonic interpolation in every fragment is proceeded over the pixels except for the central pixel. The brightness estimation of the central pixel is compared with the true (already known) value and the estimation error (e k ) is computed. The biharmonic interpolation coefficients (α ik ) and the corresponding estimation error (e k ) are stored in the database as a single reference pair. The principle of supporting the interpolation with the database is to compare computed interpolation coefficients with the references from the database and to find the reference which is best suited. The mean square fitting error (3) between the reference and current coefficients is used during the search.
where: J k -mean square fitting error between k-th reference and current coefficients, α ik -i-th coefficient of k-th reference in the database, α * i -i-th coefficient of the interpolation of current fragment and k -the number of the most suitable reference.
After finding the best reference, the corresponding estimation error is basically subtracted from current estimation. In sum: the method uses the biharmonic interpolation and is based on a properly created database of known fragments of the image containing astronomical objects. During the interpolation, the database is searched to find the most suitable reference and to apply the corresponding correction to current brightness estimation. To improve the efficiency of the method, it is desired to find not one but a few (in the experiments the number of 5 fragments was used) of the most suitable references and to subtract a weighted average of the corresponding estimation errors (4).
where: e -averaged estimation error, J i -mean square fitting error between i-th best fitted reference and current coefficients, e i -estimation error of i-th best fitted reference.
Another additional improvement is to normalize every fragment before any interpolation -during the database creation and during a bad pixel correction (5). The normalization enables to compare fragments of very bright objects with dimmer ones. The bad pixel estimated brightness in such a solution has to be followed by a simple renormalization (6).
where: p i -normalized pixel brightness; p i -real pixel brightness; min(p), max(p)minimal and maximal real brightness among the pixels in a fragment.

Verification
The database was created using fragments from the first 10 pictures from the previously mentioned SDSS image set. Other images (990 pictures) were used as a verification set. The results are presented for three modified interpolation types (without averaging and normalization, with averaging and with averaging and normalization) and for the original biharmonic interpolation without modification (Fig. 6. and 7). In another test, it was examined if the modified interpolation can be useful for a single image correction. It means that the database had to be created from the parts of an image that were not affected by faulty pixels. Six randomly chosen images from the SDSS survey were used. 80% of the 7x7 pixel fragments were used as a database and the remaining 20% were the test set. The results are resented in Fig. 8. Additionally we compared the effectiveness of the method for the individual frame correction using database constructed from the same frame (minimal database) and from other 20 frames (large database). We analyzed 50 images for this test. The results are presented in Fig. 9. and 10.
The mean error for the test with a large database showed about 50% decrease after using the modified interpolation idea. According to the histograms ( Fig. 6 and 7) the number of small errors rose and the number of large errors decreased as the modified interpolation was used. The proposed enhancements improved also the results of the method. It was shown that both enhancements reduced the mean error by about the same value (20 [ADU]). However, in terms of relative error, the normalization improved the precision only slightly (form 0.044 to 0.042) in comparison to the weighting improvement (from 0.042 to 0.032).     The modified interpolation seems to work well also as a single image correction, where the database has to be created from fragments of the same image. However, with such a minimal database, the estimation improvement will be strongly dependent on the image and the positions of bad pixels (Fig. 8). For our set of 50 images, the use of larger database improved the estimation error noticeably ( Fig. 9 and 10). However it is to be mentioned, that for the images affected by strong PSF variation (e. g. due to the seeing problems), the results would be different.

Conclusions
In the article a comparison of some interpolation methods of bad-pixels correction in astronomical images was presented. The images from the Sloan Digital Sky Survey were used as an examination set. The biharmonic interpolation as the most accurate method was enhanced with the idea of supporting it with a database of known astronomical image fragments. The test with a large database and a minimal database proved the effectiveness of the method as a pixel's brightness estimator and its superiority over other interpolation methods examined in our tests. Moreover, the biharmonic interpolation has not been used for the astronomical images interpolation yet. With the supporting idea applied, its accuracy was about 4 times higher than for the linear interpolation, which is typically used for the astronomical image calibration. It should be added that the modified interpolation idea is flexible and it could be applied to any current or future interpolation method.