Masking Facts in PixInsight



::Index  <Prev  >Next

The Masking Procedure in PixInsight

Masking Rules

Maskable Processes

Masked Processes in ProcessContainer



The Masking Procedure in PixInsight

The basic masking procedure works in PixInsight as it commonly does in most imaging applications. Let F and M be two different images. We assume that there exists an active masking relation from M to F, that is, M is acting as a mask for F. Also let P() be a process that can be masked. Then, for each pair of coordinates x, y, if fx,y is a pixel of F and mx,y is the corresponding pixel of M, we have:

gx,y = mx,y × P(fx,y)  +  (1 — mx,y) × fx,y

where gx,y is the resulting pixel of the processed image G, and pixel values are assumed to be in the normalized range from 0 to 1, where 0 is black and 1 is white. The equation above tells us that the value of each pixel in the mask M works by modulating the process P(). For white mask pixels, the process is fully applied, so the processed pixel value P(fx,y) just replaces the original. For black mask pixels, no process occurs, so the original pixel value fx,y is left unchanged. Finally, for intermediate mask values, the mask pixel value mx,y is the fraction of processed pixel value that will enter the result.


Masking Rules

Any image can work as a mask in PixInsight. Just that simple. Knowing that masks are essential for virtually any nontrivial image processing in astrophotography, our intention was to implement a masking system as richly featured and flexible as possible. For this purpose, the following rules apply to masks in PixInsight:

  • An image cannot be selected as a mask for itself.
  • Cyclic masking relations are not allowed. In other words, if A and B are images, and A is being used as a mask for B, then B cannot be used as a mask for A.
  • Multiple masking relations are allowed, that is, an image can be selected as a mask for several different images.
  • The mask and masked images must have the same dimensions.
  • For RGB color images, both grayscale and RGB color images can be selected as masks.
    • If a grayscale image M is used as a mask for a RGB color image F, the unique (gray) channel of M is used as a mask for each individual channel of F.
    • If a RGB color image M is used as a mask for a RGB color image F, each individual channel of the mask M will mask its counterpart channel of F.
  • For grayscale images, only grayscale images can be selected as masks.

Alpha channels are commonly used as transparency masks in many imaging applications, but they cannot be used for this purpose in PixInsight LE 1.0.

When an image is working as a mask for another one, modifying the mask does not invalidate the masking relation unless something is changed that makes it no longer possible. For example, you can apply CurvesTransform or SGBNR to a mask, and it will continue working as such without problems, but if you rotate or crop it, for example, this will terminate the masking relation.


Maskable Processes

The following processes can be masked in PixInsight LE 1.0:

General category

Invert
MedianFilter
MinMaxFilter
SCNR
SGBNR
PixelMath

Transfer Curves category

CurvesTransform
HistogramsTransform

Wavelets category

ATrousWaveletTransform

Masked processes can be fully used with preview objects in PixInsight. This means that you can preview any maskable process with or without an active mask.

When an instance of a maskable process is executed on a view that has an active masking relation, that relation is stored in the process instance, which is appended to the view's processing history. This way, masking relations are preserved throughout the entire life of process instances, including storing them in process set module (.pi-psm) files, applying them to other views, converting them into process icons, etc.


Masked Processes in ProcessContainer

The ProcessContainer process cannot be masked. However, since masking relations are preserved in process instances, including those contained by ProcessContainer, specific masks are appropriately applied when each individual process is executed. This involves quite complex relations between many different objects in PixInsight.



::Index  <Prev  >Next