Interactive lasso-based mask generation for PixInsight. [more]
Categories:DeepSkyColors, MaskGeneration
Keywords: lasso, mask, selection, freehand, rectangle, ellipse, polygon, magic wand, region, feather, contract, expand, invert, tolerance, dynamic live preview.
[hide]
[hide]
Welcome to DynamicLasso — a PixInsight process module for building grayscale masks by drawing regions directly on an image. Instead of relying on pixel value ranges or star detection, we trace the areas we want by hand — freehand, as a rectangle, an ellipse, a polygon, or by using the magic wand — and DynamicLasso turns those regions into a standard mask image we can apply to any view.
Each region we draw is a discrete, editable step. We can keep adding regions, subtract from what we have, soften the edges with feathering, grow or shrink the selection with contract/expand, and invert the whole result. Because every action is recorded in a history, we can undo and redo freely, and the complete selection is serialized into the process instance — so it can be saved, dragged to a process icon, and re-applied later.
DynamicLasso is especially useful whenever a mask is easier to point at than to describe mathematically: isolating a galaxy or nebula, protecting a foreground, masking stars or a specific structure, or quickly carving out an arbitrary area for local adjustments.
[hide]
The only official distribution of DynamicLasso is via a PixInsight repository. This is the safest way to install a module or script, as the installation is handled by PixInsight itself, which will fetch the module directly and safely from our PixInsight repository at https://repo.deepskycolors.com/DynamicLasso/ Make sure the trailing / is part of the URL. Also, be sure to keep our repository URL in your list of PixInsight repositories to receive timely updates.
By distributing DynamicLasso only via our PixInsight repository, installation comes with the guarantee of our Developer and Repository certificates, verified by PixInsight itself from the moment it connects to our repository, until it validates and completes installation of the DynamicLasso module.
If we ever want to be sure that we have the latest version available to us, we go to PixInsigh’s RESOURCES menu, select Updates,
then Manage Repositories to make sure our repository is still there, then RESOURCES > Updates > Check for Updates.
DynamicLasso is a dynamic process, so it operates on whichever view we point it at first, and then we work with DynamicLasso to define our mask, rather than adjusting parameters on the process dialog first, and then selecting the target when we're ready to apply the process.
To launch it:
While in dynamic mode the cursor changes over a valid target view, and the overlay (the regions we draw) is rendered live on top of the image.
DynamicLasso runs on a trial-then-registered licensing model. During the trial period, the tool is fully functional with no feature restrictions. When the trial expires, DynamicLasso will display a notice at startup and will not open until a valid registration key is entered (see 3.7 Registration and licensing). No internet connection is needed: keys are validated offline.
[hide]
The DynamicLasso panel is organized top to bottom into: a tool toolbar (which also holds the history controls and the region counter at its right end), a Mask adjustments group containing the Feather, Contract/Expand, and Magic Wand (Tolerance) controls, and the classic PixInsight interface bar at the very bottom. The rest of the interaction happens directly on the image, where we draw and see the live overlay.
The toolbar at the top of the panel holds the drawing and mask-operation tools, plus the history controls at its right end. The drawing and operation buttons are grouped as: [Freehand] [Rectangle] [Ellipse] [Polygon] [Magic Wand] [Invert] [Preview] [Apply mask].
Drawing-mode buttons (mutually exclusive — we pick one):
Mask-operation buttons:
Note on Add vs. Subtract. By default each new region is added to the mask. To subtract a region instead (cut a bite out of the existing mask wherever it overlaps), we hold Alt while drawing. The subtract applies globally to the accumulated mask, not just to the most recent region.
The Feather control sets a soft-edge radius (a Gaussian sigma, in pixels) that is applied to new regions as we create them. A feather of 0 produces a hard-edged mask; larger values produce progressively softer transitions at the region borders.
Feathering is stored per region: each region remembers the feather value it was drawn with, so regions with different softness can coexist in the same mask. As we move through the history (see History bar), the slider updates to show the feather of the current region, so we always see the value that region was drawn with.
To change the feather of a region we have already drawn, we navigate the history to that region, set the slider to the new value, and click the small Apply (checkmark) button at the end of the Feather row. The button lights up whenever the slider differs from the current region's stored value, signalling a pending change; clicking it re-feathers that region in place. This is not a separate history step — undoing the region removes the feather change along with it. (Invert steps carry no feather, so the Apply button is unavailable on them.) When we import an existing instance, the slider snaps to the feather value of the most recently added region.
The Contract/Expand control resizes a region by a number of pixels before feathering is applied:
Just like Feather, Contract/Expand is stored per region and works the same way: the value applies to new regions as we draw them, the slider tracks the current region as we travel the history, and an Apply (checkmark) button at the end of the row commits a new value to a region we have already drawn (it lights up while a change is pending). The reset button next to it returns the displayed amount to 0 — handy as a quick way to clear the value before drawing the next region, or before Applying 0 to the current one. This is ideal for tightening a selection just inside an object’s boundary, or growing it to safely cover a structure plus a margin.
These two controls govern the Magic Wand tool and are active only while the wand is the selected drawing mode:
The wand grows a contiguous area — it spreads outward from the click point through connected matching pixels and stops at borders that exceed the tolerance, so it does not select matching pixels elsewhere in the image. Each wand selection is recorded as an ordinary region, so it participates in Add/Subtract, Feather, Contract/Expand, Invert, and the history exactly like a drawn shape.
The History buttons —
We can jump to any state in our history, then edit its feather and contract/expand settings, or delete the entire region from the sequence, leaving all other actions untouched.
The right end of the toolbar holds a set of history controls with a region counter beneath them. Every action — each added region, each subtract, and each invert — is one step we can move through:
The information label reports the current state (for example, the number of regions). Keyboard shortcuts work while the cursor is over the image (dynamic mode):
| Ctrl+Z | Undo |
| Ctrl+Shift+Z | Undo All |
| Ctrl+Y | Redo |
| Ctrl+Shift+Y | Redo All |
| Delete | Delete |
The toolbar's Dynamic Live preview (DLP) button opens a dedicated mask image window (a real image, not PixInsight's RealTime-Preview window) that mirrors the final result of our selection in real time. Unlike the overlay drawn on the target image — which is a fast visual approximation, and our canvas for defining the mask — the preview window shows the actual rendered mask with feathered edges, contract/expand morphology, and inversion all included.
The preview updates automatically after each stroke, undo/redo, invert, or contract/expand change. The window is sized to fit comfortably on screen, but we can resize and position it anywhere we like, as any other PixInsight window.
The preview image can be used as the mask of another image, while we continue working with DynamicLasso. This allows us to see how the mask we're defining will protect the target image at every DynamicLasso interaction. This is one of the reasons DynamicLasso uses a real image as "preview" window, instead of the static, low-quality, unflexible PixInsight's RealTime-Preview window. If DynamicLasso used PixInsight's RTP window, we would not be able to see the mask being applied in real time to any image we like, only how the mask looks. I believe this is much more usfeul.
Dynamic Live Preview in action —
Applying the DLP image as a mask to a duplicate of our target image allows us to continue working on our target image, while seeing in real-time the effects of everything we're doing.
Typically, we want to apply the preview window to a duplicate of our target image. Why not to the target image directly? We can, but that's also the image where we're drawing our mask regions, and if we apply the preview mask to it, unselected areas would be covered in red (the mask being applied), and we will not be able to see the actual image underneath. Applying the preview mask to a duplicate of the target image will allow us to continue adding or modifying regions to our target image, while seeing the effect of the mask on the duplicate.
When the preview window is being used as some image's mask, the masked view of that image is also regenerated at every step, so all involved windows/images stay in sync. Closing the preview window directly simply turns the toggle off, also achievable by clicking again on the Dynamic Live Preview toolbar button. Toggling it back will re-create the window, again.
The Preferences button (the wrench icon on the process interface bar) opens the DynamicLasso license information dialog. This dialog reports the current license state:
When the module is not yet licensed, the dialog shows a “Click here to register” link. Clicking it opens the registration dialog, where we enter our email and license key. The fields are validated as we type, and the Register button enables only once a valid email/key pair is entered. After a successful registration the info dialog refreshes in place to the “licensed to” state — no need to reopen it.
[hide]
A typical mask-building workflow:
Launch DynamicLasso and move the cursor over the target image. The first stroke locks that view as the target.
Choose a drawing mode (Freehand, Rectangle, Ellipse, Polygon, or Magic Wand) from the toolbar. For the Magic Wand, set the Tolerance and metric first (see Magic Wand options).
Set a Feather value if we want soft edges. (We can change feather between regions; each region keeps its own value.)
Draw our first region. It is added to the mask and appears in the overlay.
Add more regions as needed. Hold Alt while drawing to subtract a region (cut a hole) instead of adding. (In Polygon mode, hold Alt on the first click; in Magic Wand mode, hold Alt as you click.)
Use Contract/Expand to tighten or grow the selection, and Invert to flip it if we want to mask everything except what we drew.
Turn on Dynamic Live preview at any point to see the exact rendered mask, including soft edges and morphology.
Use the history controls (or Ctrl+Z / Ctrl+Y) to step back and forth as we refine the selection.
When satisfied, Execute the process (apply it to the view). DynamicLasso generates a grayscale mask image. If Apply mask is enabled, the mask is assigned to the target image and the target window is brought to front; otherwise the mask is produced as its own image window for us to use as we like.
How the mask is built (overview). Regions are processed in the order they were drawn. Added regions are filled and unioned into the mask; subtracted regions remove their overlap from the accumulated mask globally; invert steps complement the whole mask. Both feathering (a Gaussian blur of the region’s coverage) and contract/expand (which resizes coverage before that blur) are applied per region, using the value each region was drawn with. The result is a standard single-channel grayscale image suitable for use anywhere PixInsight accepts a mask.
[hide]
Build complex selections incrementally. Many small added regions plus a few Alt-drag subtracts are often faster and more controllable than one perfect freehand trace.
Use Rectangle/Ellipse with Shift for clean squares and circles when masking regular structures or framing.
Reach for the Polygon tool for straight edges. When a boundary is better described by a few straight segments than by a shaky freehand trace, click the corners — and remember Backspace to undo the last vertex before closing.
Let the Magic Wand do the tracing when a region is defined by tone or color (a bright core, a uniform background). Start with a low Tolerance and raise it until the selection just covers what we want; switch the metric to RGB when color, not brightness, separates the area from its surroundings.
Set Feather and Contract/Expand before drawing each region. Because these attributes are stored per region, we can mix crisp and soft regions in one mask — e.g., a hard core plus a soft halo.
Reach for Contract/Expand instead of redrawing. If a freehand trace is close but slightly too tight or too loose, we nudge the whole selection in or out with one control.
Fix a region's feather or contract/expand after the fact. We don't have to get softness or size right the first time — step back through the history to the region, change the slider, and click its Apply (checkmark) button. The slider always shows the current region's own values as we travel the history.
Invert is reversible and free. Draw the easier shape (often the object) and invert when we actually want to protect it — click Invert again to flip back.
Keep Dynamic Live preview on while fine-tuning feather and contract/expand: the on-image overlay is an approximation, but the preview window shows the true rendered edges.
Even better, apply the preview mask to a duplicate of our target image to see the mask being applied in real time after each iteration.
Use the keyboard while drawing: Ctrl+Z / Ctrl+Y (and the Shift variants for all-the-way) let us experiment without leaving the image.
Save our work as a process icon. Because the full set of regions and actions is serialized into the instance, we can drag the instance to a process icon and re-apply or tweak the exact same selection later.
Copyright © 2026 Deep Sky Colors. All Rights Reserved.