Author Topic: Structuring element - Morphological Transform  (Read 5506 times)

Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Structuring element - Morphological Transform
« on: 2010 July 19 14:54:32 »
I am on a roll here, and I apologize for all the questions!

What does the Structuring element on the MorphologicalTransform do?
Which one is best to use to reduce star sizes?

Thanks!
E.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Structuring element - Morphological Transform
« Reply #1 on: 2010 July 19 21:05:26 »
Hi Emanuele

You may imagine the structuring element as the neighbourhood you are defining to operate through the image. Each white square tells that this pixel should be included in the statistical calculation (maximum, minimum, etc). So, if you have the following kernel (structuring element):
0 1 0
1 1 1
0 1 0
(0 is black, 1 is white) and select the maximum operator, you'll be comparing the actual pixel with the top, right, bottom and left ones, and replacing the actual pixel value with the highest of those 5. Larger kernels will generate a more aggressive behaviour, since you are including more pixels in the calculation.
Also the shape of the kernel is very important. It will largely depend on your aim, and the morphology of the objects in the image. But, basically, you want to build a structuring element closely related to you object of interest. For example, for stars, circular patterns work great. Also works fine a combination of square and diamond shaped filters, one after the another.

Now, getting down to your last question. If you want a mild effect, choose a 2 way filter, the first one a square and the second a diamond, both 3x3. Play with the amount and iterations untill you get the results you want. I'm usually happy with 8-10 iterations, and 10-25% amount.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: Structuring element - Morphological Transform
« Reply #2 on: 2010 July 19 22:21:20 »
Hi, luckily that's how I understood it but I couldn't quite put it so clearly in words so I didn't try :) Am I right to understand that the structural element gets moved one pixel at a time rather than one 'tile' at a time? Now that I write it down it seems like a silly question. Of course each pixel (except the edges) gets processed. So what happens to the edge pixels? Do the structural element get moved half way off the image?

For star size reduction I typically first apply a star mask, sample my stars and see how big they are (approximately) and then build a round SE, say 7 pixels tall. I then run a few different 'amount' settings to see what I like best. Typically around .3 or .4. I usually do only 1 iteration.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Structuring element - Morphological Transform
« Reply #3 on: 2010 July 19 22:41:35 »
If the structuring element covers areas outside the image, those "virtual" pixels are ignored.

Well, I'm not 100% sure about that xD.
The convolutions algorithm uses Neuman boundary constrains (i.e. the image is mirroed outside its boundaries). If the same happens, in most cases the result is the same for a morphological filter, although some statistical calculations (like the percentile values) may have a shift.
Anyway, since I believe that the statistical calculation is done using dynamic arrays, outside pixels should be rejected instead of using simulated data.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: Structuring element - Morphological Transform
« Reply #4 on: 2010 July 21 11:26:27 »
any tips on generating a good star mask for use with the morphological tranform? try as i might i'm only getting star masks with the bigger stars, leaving a whole lot of smaller stars protected during red channel erosion...

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Structuring element - Morphological Transform
« Reply #5 on: 2010 July 21 11:52:46 »
Use a simple luminance mask. You may improve it a bit deleting some large scale layers with wavelets.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: Structuring element - Morphological Transform
« Reply #6 on: 2010 July 21 12:22:12 »
Hi,

I also find the star mask module a bit unwieldy. So many options! I think this may be suitable for improvement now that we have other star detection code available like that used by StarAlignment. I did however put together a demonstration for MWAIC using starmask and MT and found that when I created different starmasks the MT effect was virtually the same. So I decided not to worry too much about it. I generally reduce smoothness, scale and growth to smaller numbers than default to make the mask 'sharper'.

In my presentation I suggest creating a preview with a good cross-section of your image. Then drag a few copies of that preview onto the workspace to create images. Now create different starmasks and apply them as masks to those images. Now experiment with MT on these small images. Then decide which image you like best and redo the same starmask and MT on the entire image. With some practice it'll take only a few minutes to narrow down on a reasonable solution.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Re: Structuring element - Morphological Transform
« Reply #7 on: 2010 July 21 13:51:00 »
Guys ,

thank you to all of you for your replies! I did excatly what you guys suggested and the image that came out of it is IC4812 that I posted in the Gallery section!
I am starting to love PI, although I'd really like to see some "layers" so that I can save the image with all the different processing steps in it.


Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: Structuring element - Morphological Transform
« Reply #8 on: 2010 July 21 13:56:45 »
Hi,

I don't think you'll see layers as this is a different paradigm but you will see a fully saved undo-history, real soon I hope. Not being able to save your current status really is a shortcoming in PI and I'm surprised a lot of new features were deemed more important than that.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: Structuring element - Morphological Transform
« Reply #9 on: 2010 July 21 14:04:21 »
Hi,

I also find the star mask module a bit unwieldy. So many options! I think this may be suitable for improvement now that we have other star detection code available like that used by StarAlignment. I did however put together a demonstration for MWAIC using starmask and MT and found that when I created different starmasks the MT effect was virtually the same. So I decided not to worry too much about it. I generally reduce smoothness, scale and growth to smaller numbers than default to make the mask 'sharper'.

In my presentation I suggest creating a preview with a good cross-section of your image. Then drag a few copies of that preview onto the workspace to create images. Now create different starmasks and apply them as masks to those images. Now experiment with MT on these small images. Then decide which image you like best and redo the same starmask and MT on the entire image. With some practice it'll take only a few minutes to narrow down on a reasonable solution.

well, i was doing exactly this yesterday, but i just could not find a way to keep the smaller stars. the image was the veil nebula, and there's a lot of stars in that area.

Use a simple luminance mask. You may improve it a bit deleting some large scale layers with wavelets.

thanks carlos, i will try this.



Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Re: Structuring element - Morphological Transform
« Reply #10 on: 2010 July 21 14:54:17 »
Hi,

I don't think you'll see layers as this is a different paradigm but you will see a fully saved undo-history, real soon I hope. Not being able to save your current status really is a shortcoming in PI and I'm surprised a lot of new features were deemed more important than that.


I agree with you Sander.
 Specially because if I want to go back in a few days and try a different setting for an HDRWavelet, I won't be able to do that :( I'll have to begin from scratch!

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: Structuring element - Morphological Transform
« Reply #11 on: 2010 July 21 15:01:09 »
If you save the .psmx file then you can reconstruct your current undo stack if you apply one process at a time to the original image. But it's a tricky process. Even if you can't use the .psmx file for that purpose I still recommend you save it so at least you can see what you did.


- load history explorer on your active image
- drag process container icon onto the desktop
- right click the icon and save it to disk
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Emanuele

  • PixInsight Addict
  • ***
  • Posts: 270
Re: Structuring element - Morphological Transform
« Reply #12 on: 2010 July 22 13:13:22 »
thanks Sander. Will do that, but I hope this feature is really implemented fast.