Hi I have a fits image that I read in with pyfits.getdata
which has heavy vignetting along in the corners of the image. I create a second numpy
array with the same dimensions as the original image, having a value for a bad pixel as 1 and a usable one as 0. To detect point sources I use pysex
on the original image. The pysex
routine detects fluctuation in the vignetted area as point sources. How can I interpolate over the array marking the bad pixels. I have tried scipy.interpolate.griddata
and scipy.interpolate.interp2d
and the required arguments are not clear, what is the simplest solution?
Asked
Active
Viewed 1,878 times
2

user2739303
- 31
- 4
-
I'm not familiar with `pysex` or the specifics of how it works, but have you considered trying using a [masked array](http://docs.scipy.org/doc/numpy/reference/maskedarray.generic.html#examples)? – Iguananaut Sep 03 '13 at 00:08
2 Answers
0
You have bad pixel at (x0,y0) = 5,10 and an other one at (x1,y1) = 50,100
output = Scipy.interpolate.map_coordinat(array,np.array([[5,50],[10,100]]))
1bad_value = output[0]
2bad_value = output[1]
it's like [x0,x1,x2,x3],[y0,y1,y2,y3] , not very intuitive I admit
You want more, This is a really good post : Fast interpolation of grid data
But actuallly I would use scipy.filter.uniform_filter for bad pixels. It gives you the value of the average of the neigbourgs. It is not as precise a a cubic interpolation but it is more robust. Even better scipy.filter.median_filter in case you have 2 bad pixels near each other.
0
I think map_coordinates
should be able to give you what your want:
index_vignetted = scipy.ndimage.map_coordinates(vignette, point_sources)
This will return you a vector with the value of your vignette for the pixel under the location of each point source.

Florian Franzen
- 1
- 1