Author Topic: Problematic mask  (Read 8155 times)

Offline swag72

  • Member
  • *
  • Posts: 56
Problematic mask
« on: 2012 January 26 11:39:16 »
I am really struggling with halo's in my image and I think that perhaps one of my biggest issues is my mask. I am aiming to use star mask and a luminance mask, calculated in PixelMath to get a combined mask where I can mask out just the galaxy. Below is my mask, I think that the big problem is that I have such a large area masked / unmasked outside of the stars that I am getting colours hence halo's within that area.

So, my mask looks poor - How can I improve it? How can I get the star mask to

a) include the bright star (that I struggle with) yet not include the bright Galaxy
b) Not have such a large area around the star, so that only the star itself is changed, not the area surrounding it.

I have tried so many settings and now can't see what more I can do.

Hope someone can help.


Problematic PI mask by swag72, on Flickr

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Problematic mask
« Reply #1 on: 2012 January 26 12:00:55 »
Hi Sara,

To help you I need to take a look at the image. Can you upload it somewhere?
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline swag72

  • Member
  • *
  • Posts: 56
Re: Problematic mask
« Reply #2 on: 2012 January 26 12:12:21 »
Cheers Juan - Here is a link to the RGB image prior to any stretching, just DBE, Crop and Background neutralised.

http://dl.dropbox.com/u/41385123/RGB.tif

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Problematic mask
« Reply #3 on: 2012 January 26 15:21:50 »
Hi Sara,

I've made a quick test with your image and the result is quite good IMO. This is the TIFF image with STF AutoStretch applied:


The first step is to remove those light pollution gradients, which is very easy with DBE:


This is the result after two DBE iterations (with the same samples shown above in both iterations):


Now this is the lightness component of the RGB image with STF AutoStretch applied. This is incorrect because the image is linear, so the lightness component doesn't exist, but for mask generation purposes it's OK to generate a "working grayscale version" of the image:


I have transferred the STF instance to HistogramTransformation. Then I have applied HT to get a nonlinear (stretched) grayscale version of the image. This nonlinear image will be the basis to build a star mask. After a bit of parameter tweaking, this is the result:


And here is the mask visible on the RGB image:


This mask is quite good but it lacks a few dim stars. If a really exhaustive mask is required to protect (or unprotect) every star in the image, a slightly more complex technique based on HDR compression can be used. Let me know if you want me to explain. Rogelio has a nice tutorial on his website where he uses this method:

http://blog.deepskycolors.com/archive/2011/09/08/star-size-reduction-via-Morphological-.html

If you want to shrink or expand the mask, you can do that very easily with MorphologicalTransformation. For example, this is the result after an erosion filter with a 5x5 circular structure:


Hope this helps. As you can see, mask generation in PixInsight is different from the tricky procedures that are customary in other applications. Our techniques are robust, efficient and adaptable to each particular case because PixInsight has the right tools and resources to face real image processing problems.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline swag72

  • Member
  • *
  • Posts: 56
Re: Problematic mask
« Reply #4 on: 2012 January 27 00:10:30 »
Hi Juan - That is brilliant - Thank you so much for taking the time to show me this. From this I was wanting to make a mask that included only the galaxy - I think that is a combination of the star mask and linear mask then put into pixelmath? That was the mask I was trying to do in the first post.

Your screen shots are excellent and give me a good basis for starting to build better masks.

I hope this post is useful to others who may be struggling as well. Great stuff.

Offline sleshin

  • PixInsight Old Hand
  • ****
  • Posts: 431
Re: Problematic mask
« Reply #5 on: 2012 January 27 08:19:46 »

This mask is quite good but it lacks a few dim stars. If a really exhaustive mask is required to protect (or unprotect) every star in the image, a slightly more complex technique based on HDR compression can be used. Let me know if you want me to explain.

Juan,

I would be very interested and appreciative if you would explain how you would go about making the mask so that every star is included from the brightest to the smallest dim ones.

Thanks,

Steve
Steve Leshin

Stargazer Observatory
Sedona, Arizona

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Problematic mask
« Reply #6 on: 2012 January 28 05:11:43 »
Hi Steve,

As often happens in astrophotography, the star mask generation problem is actually a dynamic range problem. Bright and large objects usually block stars and other small-scale structures that we want to include in the mask. To isolate all of these structures, we have to compress the dynamic range first.

Let's take a look again at the stretched working grayscale version of Sara's M82 image:


This image is the result after applying DBE (in two iterations) to the original RGB image, extracting its L component as a new grayscale image, and applying a histogram transformation with STF AutoStretch parameters. To build an efficient star mask we have to solve two main problems. One is the subject of the image, M82, which is a bright, large-scale structure. Actually, M82 is not a big problem in this case because it is a well isolated structure. Other images pose much more difficult problems with larger nebulae extended under rich star fields. Anyway, the standard procedure is to compress the dynamic range with a rather aggressive instance of HDRMultiscaleTransform (formerly HDRWaveletTransform):


After this process the image has basically a flat illumination profile that facilitates isolation of small-scale structures. As an extreme example of this technique's power, the following screenshot shows a star mask for the M42/M43 region, where we have been able to isolate all of the stars inside these objects, including all the Trapezium stars:


Back to Sara's M82 image, the second problem is less evident but somewhat harder to fix: noise. The background is rather noisy, and the StarMask routine can easily get fooled with relatively bright noise structures whose shapes and sizes are comparable to those of the dimmest stars we want to isolate. The ATrousWaveletTransform tool can be used in these cases with two purposes: remove the background and suppress small-scale noise:


After this step the StarMask tool works like a charm:


Here you can see the generated star mask active for the original RGB image. As expected, every star in the image has its counterpart in the mask:


The core of M82 contains some small-scale, star-like bright structures that have been included in the mask. This is a correct and in general desirable result: if we want to (un)protect the stars, why should we give a different treatment to similar structures in the galaxy? In case we have a good reason to do so, we can either tweak the star mask generation process, or use the CloneStamp tool to remove the undesired mask structures. While we can easily figure out cases where this kind of manual interventions are necessary for a star mask, they are close to the line separating admissible from unacceptable practices, so they should be applied with caution, and not before thinking about what we want to do and why.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline niteman1946

  • PixInsight Addict
  • ***
  • Posts: 234
Re: Problematic mask
« Reply #7 on: 2012 January 28 06:27:49 »
Thanks Juan.

Mark

Offline swag72

  • Member
  • *
  • Posts: 56
Re: Problematic mask
« Reply #8 on: 2012 January 28 07:56:51 »
Excellent write up again Juan - Can you explain how, from that point you would go about creating a mask purely for the Galaxy? This has been my biggest struggle.

Offline sleshin

  • PixInsight Old Hand
  • ****
  • Posts: 431
Re: Problematic mask
« Reply #9 on: 2012 January 28 07:58:38 »
Another really helpful mini-tutorial, Juan. Thanks for taking the time to do it.

The ATrousWaveletTransform tool can be used in these cases with two purposes: remove the background and suppress small-scale noise:

One question, I was curious to see you used ATW rather than MMT for noise and background modification. Why not MMT? Any guidelines to when ATW is a better choice than MMT and vise versa?

Again, many thanks.

Steve
Steve Leshin

Stargazer Observatory
Sedona, Arizona

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Problematic mask
« Reply #10 on: 2012 January 28 09:04:30 »
For this task both tools can be used with nearly the same results:


Quote
Any guidelines to when ATW is a better choice than MMT and vise versa?

Each tool has its strong and weak points:

ATWT is much better than MMT to isolate medium and large scale structures. For this reason, ATWT works much better for local contrast enhancement (shapering) at medium and large scales. Its main drawback is generation of ringing artifacts, although we have implemented a good deringing algorithm..

ATWT is much faster than MMT, especially for noise reduction (in this case the difference can be of orders of magnitude).

ATWT applies a purely isotropic transform. Isotropy is a characteristic feature of most astronomical objects, especially deep-sky objects. Isotropy means that the transform works in the same way in all directions of 2-D space.

MMT is much better than ATWT to isolate small-scale structures. For this reason MMT tends to be better and more controllable than ATWT for high-frequency noise reduction.

MMT is better than ATWT for small-scale sharpening, especially because it uses a ringing-free transform.

MMT's behavior largely depends on the structuring elements used to apply successive median filters at growing scales. Although I've made efforts to preserve isotropy by approximating circular structuring elements, isotropy cannot be guaranteed completely at small scales. This is because approximating a circle with small kernels is very difficult, especially with kernel sizes of 3, 5, and 7 pixels. On the other hand, a circular structure tends to destroy corners. A square structure tends to transform circles into squares. This dilemma is the price we have to pay to have a ringing-free transform :)

The next multiscale processing tool, on which we are working now, implements a hybrid approach: the wavelet-median transform. The idea is to apply each transform where it is stronger: MMT to isolate significant structures at small scales and ATWT on smooth areas. I hope this will be another step forward.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline sleshin

  • PixInsight Old Hand
  • ****
  • Posts: 431
Re: Problematic mask
« Reply #11 on: 2012 January 28 10:30:44 »
Very helpful, Juan. Thanks.

Steve
Steve Leshin

Stargazer Observatory
Sedona, Arizona