DynamicLasso


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.

Contents

[hide]

1 Introduction

[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.

Typical session —

Freehand masks can be a bit irregular if drawing with a mouse. We can use feathering or expansion to smooth their edges.

2 Setup and Installation

[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.

2.1 Launching DynamicLasso

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:

  1. Open the image we want to work on.
  2. In Process Explorer or via the PROCESS menu, locate DynamicLasso under either the DeepSkyColors or MaskGeneration categories.
  3. The DynamicLasso interface opens and PixInsight enters dynamic mode.
  4. Move the cursor over the target image and begin drawing — the first stroke selects that view as the target.

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 at startup —

The DynamicLasso tool the moment we open it for the first time in a PixInsight session.

2.2 Licensing

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.

3 The DynamicLasso Interface

[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 DynamicLasso Interface —

...

3.1 Toolbar

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):

  • Freehand — drag to trace an arbitrary lasso shape. Releasing the mouse closes the shape into a region.
  • Rectangle — drag from one corner to the opposite corner. Hold Shift while dragging to constrain it to a square.
  • Ellipse — drag to define a bounding rectangle; the ellipse is inscribed in it. Hold Shift to constrain to a circle.
  • Polygon — click to place straight-edged vertices one at a time; a rubber-band edge follows the cursor between clicks. Close the polygon by clicking on the first vertex, by double-clicking anywhere, or by pressing Enter. Backspace (or Delete) removes the last placed vertex, and Esc abandons the polygon. Whether the polygon adds or subtracts is decided at the first click (hold Alt on that first click to subtract).
  • Magic Wand — click a pixel to select a contiguous area of similar pixels (a flood fill from the click point). How similar a neighbor must be, and whether similarity is judged by luminance or by RGB, is set by the Magic Wand options. The wand is a single click — there is no drag.

Mask-operation buttons:

  • Invert — flips the current mask (selected becomes unselected and vice versa). The overlay updates immediately, and the invert becomes one step in the undo history — click again to invert back. Regions we draw after an invert add to the displayed result.
  • Dynamic Live preview (toggle) — when on, a separate mask image window (a real window, not PixInsight's RealTime-Preview window, and for good reasons) stays open and refreshes after every stroke, undo/redo, invert, or contract/expand change. It shows the final rendered mask — soft (feathered) edges, morphology, and invert included — without having to run Execute. (See 3.6 Dynamic Live preview.)
  • Apply mask (toggle) — when enabled, after execution the generated mask is assigned as the mask of the target image and the target window is brought to the front, so we can immediately see and use the mask in context.

The DynamicLasso Toolbar —

...

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.

Subtracting from a defined region —

We do not need to keep Alt pressed all the time when we subtract from a region. We just need to press Alt when we start drawing.

3.2 Feather

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.

Per-region feather —

Being able to adjust the feathering of each region individually gives us much better control as we fine tune our selections.

3.3 Contract / Expand

The Contract/Expand control resizes a region by a number of pixels before feathering is applied:

  • Negative values contract (erode) the selection, pulling the edges inward.
  • Positive values expand (dilate) the selection, pushing the edges outward.
  • Zero leaves the geometry unchanged.

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.

Per-region contraction/expansion —

Just like feather adjustments, each defined region has its own growing/shrinking values, that we can update at anytime by going to that node and modifying its original value.

3.4 Magic Wand options

These two controls govern the Magic Wand tool and are active only while the wand is the selected drawing mode:

  • Tolerance (0–1) — how different from the clicked pixel a neighboring pixel may be and still join the selection. A low tolerance selects only pixels very close to the seed; raising it grows the selection to span a wider range of tones or colors.
  • Metric — how similarity is measured. Luminance compares brightness; RGB compares the individual color channels (the largest per-channel difference must stay within tolerance), which is more selective about color.

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.

A wide selection using the magic wand —

The magic wand can easily define a very complex and large selection. For most applications, a tolerance higher than 0.3 is rarely needed.

3.5 History bar

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:

  • Delete — remove the current/last step.
  • Undo All — jump back to the empty state.
  • Undo — step back one action.
  • Redo — step forward one action.
  • Redo All — jump forward to the most recent action.

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+ZUndo
Ctrl+Shift+ZUndo All
Ctrl+YRedo
Ctrl+Shift+YRedo All
DeleteDelete

3.6 Dynamic Live preview

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.

3.7 Registration and licensing

The Preferences button (the wrench icon on the process interface bar) opens the DynamicLasso license information dialog. This dialog reports the current license state:

  • Licensed — shows the email the module is licensed to.
  • Trial — shows the number of trial days remaining.
  • Expired — prompts us to register to keep using the tool.

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.

4 Creating masks with DynamicLasso

[hide]

A typical mask-building workflow:

  1. Launch DynamicLasso and move the cursor over the target image. The first stroke locks that view as the target.

  2. 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).

  3. Set a Feather value if we want soft edges. (We can change feather between regions; each region keeps its own value.)

  4. Draw our first region. It is added to the mask and appears in the overlay.

  5. 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.)

  6. Use Contract/Expand to tighten or grow the selection, and Invert to flip it if we want to mask everything except what we drew.

  7. Turn on Dynamic Live preview at any point to see the exact rendered mask, including soft edges and morphology.

  8. Use the history controls (or Ctrl+Z / Ctrl+Y) to step back and forth as we refine the selection.

  9. 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.

5 Usage tips and tricks

[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.