comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Coadd images that contain no stars
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Coadd images that contain no stars [message #80312] Wed, 30 May 2012 06:03
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 30:e maj 2012 kl. 13:53:43 UTC+2 skrev Helder:

> Well, thank! Really happy for the answer.

You are welcome. I'm glad it was useful.

/Mats
Re: Coadd images that contain no stars [message #80314 is a reply to message #80312] Wed, 30 May 2012 04:53 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, May 30, 2012 1:17:57 PM UTC+2, Mats Löfdahl wrote:
> Den onsdagen den 30:e maj 2012 kl. 10:58:53 UTC+2 skrev Helder:
>>> http://en.wikipedia.org/wiki/Phase_correlation
>>
>> Hi Russel and IDLers,
>> the phase correlation method basically calculates the correlation by using FFT() operations:
>> FFT_ImgA = FFT(ImgA,-1)
>> FFT_ImgB = FFT(ImgB,-1)
>> FFT_ImgA*CONJ(FFT_ImgB) / ABS(FFT_ImgA*CONJ(FFT_ImgB))
>> and then locating the maximum (with an appropriate function for higher accuracy).
>>
>> On the other hand the Astro-Library Correl_Images function "computes the 2-D cross-correlation function of two images for a range of (x,y) shifting by pixels of one image relative to the other". This is done using FOR loops for the pixel shifting.
>> This is generally speaking not the "IDL-way", but I guess there is no direct way around this. As far as I could see, the Astro I've looked a bit into this and found that the IDL CORREL() function is quite similar but not identical (but maybe I used the wrong keywords...).
>>
>> Now the question: how do these two methods compare? FFT procedures will perform well for images with sizes of 2^n, whereas the Astro-Library uses a recursive method to "zoom" in and this might give better accuracy.
>>
>> Does anybody have a better idea about how these two methods? When should they be used and when should they not be used?
>
>
> There are a couple of issues related to the wrap-around caused by the FFT assumption that the image is just one tile in an infinite mosaic of identical tiles. The magnitude of the problems depend on the kind of scene present in your image and the size of the image compared to the expected shifts. If the images are large compared to the expected shifts, the FFT method should be safe and accurate.
>
> Because of the FFT wrap-around, this happens/can happen if your images are small:
> * The peak corresponding to the actual shift is attenuated because part of the scene is not matched to features in the same "tile" but to features being wrapped in from the other side of the image. This effect is greater the larger the shift really is. It might be negligible if the scene consists mainly of some small but bright features entirely within the field of view (FOV) and more serious if the scene is extended with features that are about as strong over the entire FOV.
> * The correlation peak can also be attenuated if the matching feature is small in extent compared to the pixels and fall differently on the pixel grid in one image compared to the other.
> * There may be false peaks caused by features on one side of the FOV being similar to features wrapping in from the other side. These false peaks should normally be weaker than the peak corresponding to the true match but if the true peak is attenuated by the effect explained above, the false peak may be higher. (In most situations the risk that this happens should be small.)
> * The wrapping in of features from the other side of the image also affects the _shape_ of the correlation peak because the side of the peak corresponding to too large shifts is more attenuated than the side corresponding to too small shifts. If you are interested in interpolation of the peak in order to reach subpixel accuracy, this effect moves the peak toward smaller shifts and therefore causes a small but systematic underestimation of the shifts.
>
> Calculating your correlation function in the image domain is safe from these effects also for small images (although you have to sacrifice some of the FOV so you evaluate the correlation also for the largest considered shifts with actual scene within the evaluation window for both images). In addition you can consider other metrics than correlation for the best match.
>
> I looked into matters of this sort a couple of years ago, there is a paper in A&A that you might find useful: http://adsabs.harvard.edu/abs/2010A%26A...524A..90L
> I had a particular application in mind of course, but some of the methods and reasoning should be relevant to other situations. In addition to some methods used for calculating the correlation peak, I also discuss different methods for interpolating the peak in order to get shifts with subpixel accuracy.

Well, thank! Really happy for the answer. I've been banging my head on a wall for so much time that it's starting to hurt seriously!
It's also nice to find out that some of the methods I used for subpixel interpolation are also the same used in your paper... At least I was not that far away from a decent solution!

Cheers, Helder
Re: Coadd images that contain no stars [message #80315 is a reply to message #80314] Wed, 30 May 2012 04:17 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 30:e maj 2012 kl. 10:58:53 UTC+2 skrev Helder:
>> http://en.wikipedia.org/wiki/Phase_correlation
>
> Hi Russel and IDLers,
> the phase correlation method basically calculates the correlation by using FFT() operations:
> FFT_ImgA = FFT(ImgA,-1)
> FFT_ImgB = FFT(ImgB,-1)
> FFT_ImgA*CONJ(FFT_ImgB) / ABS(FFT_ImgA*CONJ(FFT_ImgB))
> and then locating the maximum (with an appropriate function for higher accuracy).
>
> On the other hand the Astro-Library Correl_Images function "computes the 2-D cross-correlation function of two images for a range of (x,y) shifting by pixels of one image relative to the other". This is done using FOR loops for the pixel shifting.
> This is generally speaking not the "IDL-way", but I guess there is no direct way around this. As far as I could see, the Astro I've looked a bit into this and found that the IDL CORREL() function is quite similar but not identical (but maybe I used the wrong keywords...).
>
> Now the question: how do these two methods compare? FFT procedures will perform well for images with sizes of 2^n, whereas the Astro-Library uses a recursive method to "zoom" in and this might give better accuracy.
>
> Does anybody have a better idea about how these two methods? When should they be used and when should they not be used?


There are a couple of issues related to the wrap-around caused by the FFT assumption that the image is just one tile in an infinite mosaic of identical tiles. The magnitude of the problems depend on the kind of scene present in your image and the size of the image compared to the expected shifts. If the images are large compared to the expected shifts, the FFT method should be safe and accurate.

Because of the FFT wrap-around, this happens/can happen if your images are small:
* The peak corresponding to the actual shift is attenuated because part of the scene is not matched to features in the same "tile" but to features being wrapped in from the other side of the image. This effect is greater the larger the shift really is. It might be negligible if the scene consists mainly of some small but bright features entirely within the field of view (FOV) and more serious if the scene is extended with features that are about as strong over the entire FOV.
* The correlation peak can also be attenuated if the matching feature is small in extent compared to the pixels and fall differently on the pixel grid in one image compared to the other.
* There may be false peaks caused by features on one side of the FOV being similar to features wrapping in from the other side. These false peaks should normally be weaker than the peak corresponding to the true match but if the true peak is attenuated by the effect explained above, the false peak may be higher. (In most situations the risk that this happens should be small.)
* The wrapping in of features from the other side of the image also affects the _shape_ of the correlation peak because the side of the peak corresponding to too large shifts is more attenuated than the side corresponding to too small shifts. If you are interested in interpolation of the peak in order to reach subpixel accuracy, this effect moves the peak toward smaller shifts and therefore causes a small but systematic underestimation of the shifts.

Calculating your correlation function in the image domain is safe from these effects also for small images (although you have to sacrifice some of the FOV so you evaluate the correlation also for the largest considered shifts with actual scene within the evaluation window for both images). In addition you can consider other metrics than correlation for the best match.

I looked into matters of this sort a couple of years ago, there is a paper in A&A that you might find useful: http://adsabs.harvard.edu/abs/2010A%26A...524A..90L
I had a particular application in mind of course, but some of the methods and reasoning should be relevant to other situations. In addition to some methods used for calculating the correlation peak, I also discuss different methods for interpolating the peak in order to get shifts with subpixel accuracy.
Re: Coadd images that contain no stars [message #80316 is a reply to message #80315] Wed, 30 May 2012 01:58 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
> http://en.wikipedia.org/wiki/Phase_correlation

Hi Russel and IDLers,
the phase correlation method basically calculates the correlation by using FFT() operations:
FFT_ImgA = FFT(ImgA,-1)
FFT_ImgB = FFT(ImgB,-1)
FFT_ImgA*CONJ(FFT_ImgB) / ABS(FFT_ImgA*CONJ(FFT_ImgB))
and then locating the maximum (with an appropriate function for higher accuracy).

On the other hand the Astro-Library Correl_Images function "computes the 2-D cross-correlation function of two images for a range of (x,y) shifting by pixels of one image relative to the other". This is done using FOR loops for the pixel shifting.
This is generally speaking not the "IDL-way", but I guess there is no direct way around this. As far as I could see, the Astro I've looked a bit into this and found that the IDL CORREL() function is quite similar but not identical (but maybe I used the wrong keywords...).

Now the question: how do these two methods compare? FFT procedures will perform well for images with sizes of 2^n, whereas the Astro-Library uses a recursive method to "zoom" in and this might give better accuracy.

Does anybody have a better idea about how these two methods? When should they be used and when should they not be used?

To make things more complicated I actually have to calculate the rotation and scaling for a given pivot point. If I can get the rotation and scaling, then I find the pivot point by testing the image drift/shift on a grid of pivot points and the one with the lowest drift/shift I then consider to be the pivot point.
This method is not very efficient when the drift/shift evaluation is unstable...

Cheers,
Helder

PS: Sorry for the bunch of questions, but I couldn't find any relevant literature that does not involve going through a full book and making use of half a paragraph to solve the problem.
Re: Coadd images that contain no stars [message #80325 is a reply to message #80316] Sun, 27 May 2012 22:26 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On May 27, 11:19 am, spasoklampa...@yahoo.com wrote:
> On May 27, 6:05 pm, Russell Ryan <rr...@stsci.edu> wrote:
>
>
>
>
>
>
>
>
>
>> On May 27, 10:56 am, spasoklampa...@yahoo.com wrote:
>
>>>      Hi,
>
>>>    I have two images from GALEX from a molecular cloud, that need to
>>> be combined to create an image. The problem is that there are no stars
>>> present. There is only the nebula. How is it possible to coadd these
>>> two frames? On each image half of the cloud is present and there is
>>> some overlap of course. Is there a way in IDL?
>
>>>     Thanks a lot
>
>> Why cant you just add them?  I'm confused....
>
>> Do you need to align the images?  If so, then you need to correlate
>> the two images to find the appropriate shifts.  Even then, and I know
>> how careful you need to be, the GALEX PSF varies across the FoV
>> significantly.  So coadding frames of anything can be very tricky if
>> they're not centered on precisely the same position in the sky.
>
>    Well the problem is that in the first frame half of the cloud
> appears in the lower left of frame, while in the second frame the
> other half appears in the upper right part of the frame. Since there
> are no stars present on both images, how is it possible to estimate
> the shifting to make the coaddition?

You need to correlate the images.

http://en.wikipedia.org/wiki/Phase_correlation

Just follow the description in the Method section. Maybe you don't
want the Hamming window... Either way, I think there is code in the
astro library to do this.
Re: Coadd images that contain no stars [message #80328 is a reply to message #80325] Sun, 27 May 2012 08:19 Go to previous message
spasoklampanas is currently offline  spasoklampanas
Messages: 8
Registered: May 2012
Junior Member
On May 27, 6:05 pm, Russell Ryan <rr...@stsci.edu> wrote:
> On May 27, 10:56 am, spasoklampa...@yahoo.com wrote:
>
>>      Hi,
>
>>    I have two images from GALEX from a molecular cloud, that need to
>> be combined to create an image. The problem is that there are no stars
>> present. There is only the nebula. How is it possible to coadd these
>> two frames? On each image half of the cloud is present and there is
>> some overlap of course. Is there a way in IDL?
>
>>     Thanks a lot
>
> Why cant you just add them?  I'm confused....
>
> Do you need to align the images?  If so, then you need to correlate
> the two images to find the appropriate shifts.  Even then, and I know
> how careful you need to be, the GALEX PSF varies across the FoV
> significantly.  So coadding frames of anything can be very tricky if
> they're not centered on precisely the same position in the sky.


Well the problem is that in the first frame half of the cloud
appears in the lower left of frame, while in the second frame the
other half appears in the upper right part of the frame. Since there
are no stars present on both images, how is it possible to estimate
the shifting to make the coaddition?
Re: Coadd images that contain no stars [message #80329 is a reply to message #80328] Sun, 27 May 2012 08:15 Go to previous message
spasoklampanas is currently offline  spasoklampanas
Messages: 8
Registered: May 2012
Junior Member
On May 27, 6:05 pm, Russell Ryan <rr...@stsci.edu> wrote:
> On May 27, 10:56 am, spasoklampa...@yahoo.com wrote:
>
>>      Hi,
>
>>    I have two images from GALEX from a molecular cloud, that need to
>> be combined to create an image. The problem is that there are no stars
>> present. There is only the nebula. How is it possible to coadd these
>> two frames? On each image half of the cloud is present and there is
>> some overlap of course. Is there a way in IDL?
>
>>     Thanks a lot
>
> Why cant you just add them?  I'm confused....
>
> Do you need to align the images?  If so, then you need to correlate
> the two images to find the appropriate shifts.  Even then, and I know
> how careful you need to be, the GALEX PSF varies across the FoV
> significantly.  So coadding frames of anything can be very tricky if
> they're not centered on precisely the same position in the sky.



In the first frame half of the cloud is seen in the lower left part of
the frame, while in the second frame the other is seen in the upper
right part of the image. So i need to create a single frame of the
cloud by adding them. The resolution is not my priority, since the
resolution will be degraded it to match frames with a pixel scale of
one arcminute. The problem is how i can estimate the dithering when
there are no stars?
Re: Coadd images that contain no stars [message #80330 is a reply to message #80329] Sun, 27 May 2012 08:05 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On May 27, 10:56 am, spasoklampa...@yahoo.com wrote:
>      Hi,
>
>    I have two images from GALEX from a molecular cloud, that need to
> be combined to create an image. The problem is that there are no stars
> present. There is only the nebula. How is it possible to coadd these
> two frames? On each image half of the cloud is present and there is
> some overlap of course. Is there a way in IDL?
>
>     Thanks a lot

Why cant you just add them? I'm confused....

Do you need to align the images? If so, then you need to correlate
the two images to find the appropriate shifts. Even then, and I know
how careful you need to be, the GALEX PSF varies across the FoV
significantly. So coadding frames of anything can be very tricky if
they're not centered on precisely the same position in the sky.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Lion Time Machine error
Next Topic: VM Save File Problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:37:35 PDT 2025

Total time taken to generate the page: 0.00786 seconds