Author Topic: Need Help on Processing Comet  (Read 27945 times)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Need Help on Processing Comet
« Reply #15 on: 2010 June 29 12:30:53 »
Hi Wade,

Thank you for uploading the images. Here is my solution to this nice image processing problem.

The original data set consists of five images of the 2009/R1 McNaught comet. Each image has been guided on the comet's head and there are time gaps between exposures which allow us to remove the stars by pixel rejection. However, the task is by no means as easy as it may seem from its statement, as we have seen in previous posts on this thread.

Our main goal here is to remove all the stars and keep just the comet's image. This task is not difficult, as we're going to see soon. However, we have an important constraint that poses the true challenge of this problem: we want to preserve, as far as possible, the SNR improvement that results from averaging five images (sqrt(5) = 2.24). Normal integration/rejection methods don't provide a satisfactory result, as we have seen from the original post, so we're going to implement a completely different strategy.

The first problem that we have is that the five images are not statistically compatible. They have varying background and signal levels, as can be seen on the following screenshot.


Click on the image for a full size version

In the above screenshot, the five images are being represented with the same screen transfer function (STF) applied. This clearly shows the differences that we have to fix before starting to work on the solution of the problem. Before fixing these differences, any comparison between the five pixels at any given coordinates would be meaningless. This is because each pixel is referred to a different distribution in terms of dispersion and central values. This is what we call statistically incompatible images. Fixing these incompatibilities is what we call image normalization.

The ImageIntegration tool implements efficient normalization procedures. In this case, however, the images have strong sky gradients that require a more accurate normalization. The StarAlignment tool implements an accurate mosaic frame adaptation routine that we can use to normalize these images very easily: just register the images with the frame adaptation option enabled, and apply the computed adaptation coefficients with PixelMath. Naturally, the newly registered images will be discarded --we already have the five images registered on the comet's head.

Below is the StarAlignment instance used to compute the adaptation functions.


Click on the image for a full size version

The frame adaptation transformation is a linear function of the form y = a + b*x, where a is the intercepting Y-axis coordinate and b is the slope dy/dx. These are the computed coefficients for the images in this example:

Image
a
b
002L  +0.000000  1.000000
003L  +0.001065  0.934481
004L  +0.000950  0.915482
005L  +0.000822  0.860648
006L  +0.002124  0.706960

These adaptation functions are very easy to apply with PixelMath. The result follows. As before, the STF applied is the same for the five images.


Click on the image for a full size version

The next step is removing the stars. This can be done very efficiently with a min/max rejection. In this case, we have rejected the four brightest pixels of each stack. Note that this has been equivalent to computing the minimum of each pixel stack.


Click on the image for a full size version

This achieves our first goal: remove the stars. The result is not perfect, as the brightest stars in the image remain visible, but this is about as good a star removal as we can get. We are not done, however: the signal-to-noise ratio of the resulting image is very poor; approximately as poor as the ratio of one of the individual frames. This happens simply because we have rejected four pixels from each five-pixel stack.

We can improve this result significantly, as we're going to demonstrate. Our next step is integrating the five frames without rejection. This generates the straight average of the five comet images, which includes the comet and all of the stars.


Click on the image for a full size version

Since we have isolated the comet, we can subtract it from the total integration with PixelMath. This produces a new image with all the stars without the comet.


Click on the image for a full size version

We are getting close to our final result. Now we have three images: the comet alone, the stars alone, and everything together. That's all we need to isolate the comet with the best possible SNR improvement. Consider the following equation:

C = I - S if S >= x
C = I - S*(1 - (x - S)/x) if S < x

where C is our final image with the isolated comet, I is the total integration image, S is the image with isolated stars, and x is given by:

x = k*med( S )

where med(f) represents the median value of f and k is a constant.

The above equations subtract the stars from the integrated image. However, they don't subtract the stars equally for all pixels of the integrated image. For relatively bright star pixels (S >= x), the stars are completely removed. For relatively dark star pixels (S < x), the stars are partially removed as a function of their deviation from a reference value. The reference value is the median of the stars image, and the k constant is an empiric adaptation multiplier that must be found by trial and error. By avoiding a total subtraction, we are preserving most of the signal-to-noise improvement that we have achieved by averaging five frames.

In PixelMath language, the above equations can be written as:

x = k*med( stars );
$T - iif( stars > x, stars, stars*(1 - (x - stars)/x) )


with the following symbols defined:

x, k=2.0

I've found that k=2 is a good value for the images in this example. Fortunately, the k constant isn't very critical; a good value can be found after three or four iterations. The result after applying this PixelMath transformation can be seen on the following screenshot.


Click on the image for a full size version

Finally, the image has some residual noise that is basically impulsional noise composed of pixel "holes" (pepper noise) as a result of rejected bright pixels in previous stages of our processing. This noise is very easy to fix with a median filter. This is the image before noise reduction:


Click on the image for a full size version

and after noise reduction, my final result:


Click on the image for a full size version

Hope this helps!
« Last Edit: 2011 October 04 00:28:46 by Juan Conejero »
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mmirot

  • PixInsight Padawan
  • ****
  • Posts: 881
Re: Need Help on Processing Comet
« Reply #16 on: 2010 June 29 13:22:43 »
Wow!

Nice work Juan. I have to go back and play with my comet images again.

Max

Offline mmirot

  • PixInsight Padawan
  • ****
  • Posts: 881
Re: Need Help on Processing Comet
« Reply #17 on: 2010 June 29 13:38:30 »
What would be the best way to add back the registered star field?

Max

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #18 on: 2010 June 29 14:26:39 »
Juan,

All I can say is WOW! You are a processing GENIUS!

I'll have to carefully go over your procedure again so I can reproduce the result in the luminance, red, green, and blue channels.  It would have taken me a lifetime to get results this awesome. 

I may have missed it, but where did you get the actual frame adaptation transformation coefficients?  Was it through experimentation or some other tool?  Keep in mind, I'm mathematically challenged.  :)

It will be a while before I post the final image since I still have to take a good background image (i.e. tracking on the stars).   At this time, this area is still very low.  I'm hoping to capture the data in August or September.

Thanks for all your help,

Wade

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #19 on: 2010 June 29 14:42:12 »
Juan,

Quote
where did you get the actual frame adaptation transformation coefficients?

After reading over it again, I see you used the StarAlignment tool. 

Wade

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #20 on: 2010 June 29 15:08:15 »
Juan,

There appears to be a slight remaining gradient from the lower-right corner to the upper-left corner.  Do you think the final image would benefit from a single run of DBE?  If so, what settings do you recommend?

Thanks,

Wade

Offline mmirot

  • PixInsight Padawan
  • ****
  • Posts: 881
Re: Need Help on Processing Comet
« Reply #21 on: 2010 June 29 16:32:00 »
Juan,

There appears to be a slight remaining gradient from the lower-right corner to the upper-left corner.  Do you think the final image would benefit from a single run of DBE?  If so, what settings do you recommend?

Thanks,

Wade

I was thinking the same thing.

Max

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #22 on: 2010 June 29 21:54:32 »
Juan,

I went through the procedure.  For some odd reason, I keep getting "echos" of the brighter stars in my final image.  It looks very similar to the "comet" image when using Min/Max integration.  Does this have something to do with us using different PixInsight versions.  I carefully repeated the process and got the same result as seen here:



Any suggestions on what could be causing this difference?

Wow, that Frame Adaption process is slow.  It took 8037 seconds to complete on my machine.  I think it's time to invest in a faster computer.

Thanks,

Wade

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #23 on: 2010 June 29 22:06:11 »
Juan,

One final question, I'm not sure how you built your morphological transform.  Could you describe the steps.

Thanks,

Wade

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Need Help on Processing Comet
« Reply #24 on: 2010 June 29 23:49:36 »
Hi Wade,

Quote
Quote
where did you get the actual frame adaptation transformation coefficients?
After reading over it again, I see you used the StarAlignment tool.
Quote
Wow, that Frame Adaption process is slow.

We still don't have an independent process to apply the adaptation routine, so we have to use StarAlignment to compute the coefficients and apply them manually with PixelMath. This is very inefficient.

That will change in the next version though ;)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Need Help on Processing Comet
« Reply #25 on: 2010 June 30 00:02:22 »
Wade,

Quote
For some odd reason, I keep getting "echos" of the brighter stars in my final image.  It looks very similar to the "comet" image when using Min/Max integration.

That isn't odd, I get exactly the same result (sorry I didn't show the whole final result). Those echoes are inevitable and are produced by bright stars that cannot be completely rejected because their images overlap across frames. Where the five images of a bright star overlap, we have data redundancy that makes rejection impossible.

Bear in mind that the best possible rejection that you can achieve for bright image features is always a minimum combination of all the frames. This is exactly what we've done in this example with a min/max combination by clipping four of the five pixels in each stack. Of course, a minimum combination is also the worst solution in terms of SNR improvement (i.e. it doesn't improve SNR). What we have achieved in this example is a combination of the best features from both techniques:

- The best possible rejection from a minimum combination.
- Minimize degradation of the highest possible SNR improvement from an average combination.

So you'll have to live with those echoes! :) I think they are a very minor issue; the image is still fantastic with them.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Need Help on Processing Comet
« Reply #26 on: 2010 June 30 00:15:34 »
Quote
There appears to be a slight remaining gradient from the lower-right corner to the upper-left corner.  Do you think the final image would benefit from a single run of DBE?  If so, what settings do you recommend?

The image would definitely show the comet better with that gradient removed. It depends on what you want to achieve though; it's a matter of personal preferences. The gradient is actually a natural feature (I think) due to the relative proximity of the comet to the horizon (correct me if I am wrong here). I personally would prefer the image with a flat illumination profile.

This gradient is very easy to fix --for ONE TIME in your images we have an easy-to-fix gradient ;D -- Just a few manual samples with DBE and it should be gone perfectly.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Need Help on Processing Comet
« Reply #27 on: 2010 June 30 02:04:31 »
Quote
One final question, I'm not sure how you built your morphological transform.  Could you describe the steps.

This transformation has some interesting aspects:

- The structure used. It is the 3x3 three-way structure (which you can pick by clicking the Manage button and browsing the list of predefined structural elements). Multi-way filtering is a powerful feature of PixInsight's implementation of morphological transformations. These filters work by applying a morphological operator (the median operator in this case) through several structural elements, then computing the average of the partial results as the final filter value for each pixel. A three-way morphological filter can preserve image features better than a simple one-way filter because it is a three-step ranking operation, where data from different spatial directions are ranked separately (diagonal, horizontal/vertical, and central pixels are processed separately).

In this case, I've used a three-way median filter because I was concerned about damaging the comet's image with a too 'rush' filtering process.

- Several iterations with a relatively low amount value, instead of a single application with amount=1. This usually yields softer results with better preservation of significant structures, especially with multi-way filters.

- A careful dosage of the low threshold parameter. This is another unique feature of PixInsight's morphological transformations. The low and high thresholds work protecting bright and dark features, respectively, from becoming too darkened or too brightened, in each case. Note that they work in a somewhat counter-intuitive opposite direction: low for bright and high for dark. In this case, a very small increment of the low threshold (0.0015) has been critical to remove all dark spots (pepper noise) without altering bright image features with the median filter.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #28 on: 2010 June 30 18:22:39 »
Juan,

Now, I'm working with the 3x3 binned color data.  I notice there's a lot more "pepper noise" in the images.  I've been experimenting with varying k; however, I'm not quite sure what I'm looking for.  How does one know they have picked a good number for k?  I can see that raising it to 4 produces a lot of "pepper noise"; whereas, setting it to 1.5 has the least noise.  However, 1.5 shows less comet tail too.

Finally, will the larger pixels in the 3x3 binned data have an impact on the morphological transform?  In other words, do I need to adapt it on a case by case basis or should the values chosen work for all my images?  If it does need changing, what am I looking for in finding the best values?

Thanks again for all your help,

Wade


Offline twade

  • PTeam Member
  • PixInsight Old Hand
  • ****
  • Posts: 445
    • http://www.northwest-landscapes.com
Re: Need Help on Processing Comet
« Reply #29 on: 2010 June 30 21:53:46 »
To all,

These gradients are killing me.  Unfortunately, I had some thin cirrus moving through the field which didn't help either.  At this point, this is the 3x3 binned color data up-sampled to 1x1.  Can anyone offer any ideas on how to make the background more neutral?  I had thought it would be easy to neutralize the background, but the gradients are making this nearly impossible.  Since I'm having problems with neutralizing the background, getting the colors of the comet correct is difficult too.  Any help would be greatly appreciated. 

Juan, I would be more than willing to upload the color data too. 

I had no idea creating a "pretty" comet image was this hard. 

Here's what I have so far (it is really ugly):



Keep in mind, this does not include the luminance image.

This has definitely been a learning experience.

Thanks,

Wade