Author Topic: Creating a circular mask  (Read 2526 times)

Offline dougggg

  • Newcomer
  • Posts: 18
    • View Profile
Creating a circular mask
« on: 2017 January 27 13:57:47 »
Sometimes when applying an operation to the nucleus of a galaxy it is useful to have a circular mask that is strong at the center and gradually blending into the background near its edge. The mask can be created with PixelMath with the equation:

iif (sqrt((x()-XCenter)^2 + (y()-YCenter)^2) < Radius, (Radius - sqrt((x()-XCenter)^2 + (y()-YCenter)^2))/Radius,0)

where Radius, XCenter and YCenter are defined as symbol values with (XCenter, YCenter) as the location of the center of circular mask.

The attached image shows the mask created.

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1176
    • View Profile
    • astrobin
Re: Creating a circular mask
« Reply #1 on: 2017 January 27 14:09:26 »
You  might like the inellipse function in Pixelmath.



inellipse( xc, yc, rx, ry )

Returns one if the current coordinates are included in the specified ellipse; returns zero otherwise.

Aliases: inEllipse,InEllipse




Mike

Offline dougggg

  • Newcomer
  • Posts: 18
    • View Profile
Re: Creating a circular mask
« Reply #2 on: 2017 January 27 14:31:39 »
The problem is that inellipse looks like it produces sharp edges. My equation gradually blends the mask into the background so it leaves less trace. I'm sure there's room for improvement though.

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1176
    • View Profile
    • astrobin
Re: Creating a circular mask
« Reply #3 on: 2017 January 27 17:19:38 »
It does leave a sharp edge but that can be handle with the convolution tool or in pixelmath. I like the convolution tool since I can preview the results and the extra parameters for shape and rotation.

Just wanted to show that pixelmath can handle a circle with a built in function.


Mike

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
    • View Profile
Re: Creating a circular mask
« Reply #4 on: 2017 January 28 07:32:02 »
Perhaps I am just not thinking this through, but . . .

You are looking for a 'feathered mask'; brightest at the centre; fading out to the edges. You feel that this mask should be elliptical in shape, and which you will presumably stretch and rotate the mask to align with the shape of the core of the galaxy in your image. What you then 'do' with the mask thereafter doesn't really matter - the choices are endless.

However, what you have done is to create an 'artistic representation' of a mask - in the way that so many non-astro-centric image-processing programs have advised you to do for decades (all founded in what was available when processing had to be done, chemically, 'in the darkroom').

Why not extract the mask 'directly from the image itself'?

That way you get the brightness contours that are applicanle to your actual image (not just a smooth blend due to some mathematical approximation).

Similarly, why rely on your ellipse as being anything even close to the approximate shape of your target? Why not use the 'actual shape' of the target itself - again 'directly extracted' from your image?

PixInsight provides all of this power - although, yes, you will need to gradually learn the tools available to be able to bring this power to work on your images.

The use of 'paint-on' masks (including mathematically-created shape approximations) has long since been superceded by pwoerful graphic processing platforms such as PI.

Don't get me wrong - I am not saying, "Don't do this" (quite the opposite, I would encourage everyone to 'get clever' with PixelMath) - what I am saying is, "Don't forget to explore the statistically-based PI tools that have been developed to perform 'artistic' operations in a more 'scientific' fashion".

Hope this helps.
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chr├ętien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline IanL

  • PixInsight Addict
  • ***
  • Posts: 116
    • View Profile
    • The Imaging Toolbox
Re: Creating a circular mask
« Reply #5 on: 2017 January 30 01:27:21 »
I concur that creating a mask based on the data is typically the best way to proceed, but there are cases where rendering a mask is required. Two examples from my own experience:

1. In solar imaging it is often necessary to process the disk and the edge-on view of the chromosphere and prominences differently, or indeed to composite two different exposures optimised for each. If the Etalon is perfectly tuned so the sweet spot is centered on the disk then using range selection will create a good starting point for a mask. If the sweet spot is not centered it is not possible to do so. Sometimes the capture is not ideal (especially when creating time lapse animations over three or four hours), and sometimes it is a deliberate choice to get the clearest image of a particular feature. Either way the resulting mask will be skewed and subsequent operations suffer. Given that the edge of the Sun's photosphere is circular (for any reasonable purpose here - it is slightly oblate but on the order of fractions of a pixel) and has a well defined boundary in the properly tuned areas, it is necessary to create a circular mask by rendering, and perfectly justifiable in my opinion.

2. I am currently battling some very large halos and other reflection artefacts in my LRGB and Narrowband filters. I am doing what I can to eliminate them at source, but doubtful it will be 100% possible with my current equipment. Changing equipment isn't an option financially and so I need to rescue what I can from my data. The halos are way beyond what can be dealt with by the star halo reducer script, but a drawn/rendered circular mask and a histogram transformation kills them completely without adding or removing other data. Range selection or similar techniques cannot create an effective mask for this purpose.

I understand the point that is being made here and support it, but discussion of tools for rendering masks isn't forbidden knowledge!

Offline Geoff

  • PixInsight Padawan
  • ****
  • Posts: 885
    • View Profile
Re: Creating a circular mask
« Reply #6 on: 2017 January 30 02:45:07 »
Some similar comments arose in this thread http://pixinsight.com/forum/index.php?topic=5624.msg38539#msg38539
There are some great comments by Juan.
Geoff
Don't panic! (Douglas Adams)
Astrobin page at http://www.astrobin.com/users/Geoff/
Webpage (under construction) http://geoffsastro.smugmug.com/

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1176
    • View Profile
    • astrobin
Re: Creating a circular mask
« Reply #7 on: 2017 January 30 03:01:03 »
And just to be clear, my comments were just to show another way of making a circular mask with PixelMath by a function that is part of Pixelmath. I'm not judging or condoning how others would use this information. I actually use PixInsight more for daytime photography then for astro work so I find any extra information always helpful.



Mike