keflavich / image_registration

Image Registration for Astronomy
MIT License
154 stars 53 forks source link

Diffraction spikes show artifacts after shifting by shiftnd #29

Open astrobatty opened 3 years ago

astrobatty commented 3 years ago

Hi,

I'm trying to shift some CCD FITS images using chi2_shift then shiftnd. The x and y offsets between two images are calculated without any problem. However, when I try to shift my images with shiftnd the new images show some artifacts. There are diffraction spikes around the bright(ish) targets, and these features are shifted in a very strange way. Here is a plot, where the upper panel shows the original image and the bottom shows the shifted.

image

I can see a periodicity with a period of 1 pixel in the spikes which is introduced by shiftnd. This affects the photometry in a bad way. My only solution is to use integer offsets, but this means +/- 0.5 pixel uncertainty, which is greater than I can accept. Has anyone encountered this issue? Any solution?

Thanks

keflavich commented 3 years ago

Interesting, this is almost certainly an aliasing issue. A simple fix might be to apply a low-pass filter. Can't come up with an example right now, but if you fft, shift it, zero the corners, then shift back, it might fix this.

astrobatty commented 3 years ago

I tried to set the corners to zero, but as the information is in the high frequencies the result is a blurred image. Another try was zero-padding the original image, but the result didn't change.

keflavich commented 3 years ago

just setting the corners to zero shouldn't result in blurring. But some sort of tapering function is needed to prevent this ringing.

astrobatty commented 3 years ago

I set more than 1-1 value to zero. So, if I set only the corners to zero, then this is the result.

(Edit: changed the figure to a better example.)

image

keflavich commented 3 years ago

I think this is coming from a couple of super-bright, maybe saturated pixels? If they are genuinely saturated, try replacing them with the local median, then re-shifting. If they're not saturated and the star really is that bright, I'm afraid you have some dynamic range issues and I'm not 100% sure how to deal with them.

astrobatty commented 3 years ago

I checked all the stars and all of these problematic cases have at least one saturated pixel, that is the problem. Thanks for the suggestions.