MKScripts for PixInsight

MK Star Reduction

  • Version 1.3
  • Runs in PixInsight

Reduce stars with the Transfer Method using an image with stars and its starless version.

MK Star Reduction reduces stars using the Transfer Method: it compares an image that contains stars with its starless counterpart and transfers a controlled reduction back into the image. Choose a single strength with optional small- or large-star protection, or set separate strengths for small and large stars. Compare the result with split view, a before/after toggle and a navigator before applying it.

At a glance

  • Star reduction with the Transfer Method
  • Single reduction strength from 0.00 to 0.90
  • Scale protection: protect large stars or protect small stars
  • Separate strengths for small and large stars
  • Split view with a draggable divider
  • Original/reduced toggle and navigator preview
  • Replace the target image or create a new image
  • Undo button for the replaced target
Current version
1.3
Menu
Script › MK Scripts › Star Reduction
Installed from
https://mhkastro.github.io/MKScripts/
Author
Mohammed Khalifa

The script window

The MK Star Reduction window in split view, with the original image on the left half and the star-reduced result on the right half. (opens a larger version)
MK Star Reduction: compare the original and the reduced image in split view.

Installation

Repository URL https://mhkastro.github.io/MKScripts/
  1. Open Manage Repositories. In PixInsight, choose Resources → Updates → Manage Repositories.
  2. Add the MKScripts repository. Click Add, paste the repository URL into the box and confirm.
  3. Check for updates. Choose Resources → Updates → Check for Updates and select the MKScripts packages you want.
  4. Exit PixInsight to install. The update is installed when you exit PixInsight, which then restarts automatically.

Full instructions: Installing MKScripts in PixInsight.

What the tool does#

MK Star Reduction makes stars smaller and less dominant with the Transfer Method. It compares two versions of the same image:

  • the image with stars, the image you want to improve;
  • the starless image, the same image with the stars removed.

From these two images, the script calculates a star-reduced version of the image with stars. It offers two ways to control the effect:

  • One Reduction Strength, optionally with Star Protection to protect either large or small stars.
  • Separate Small Stars Strength and Large Stars Strength controls, using a scale mask built from the two images.

A large preview lets you compare the result in a split view, toggle between original and reduced, and move around with a navigator. When you apply the result, you can replace the target image or create a new image.

Requirements and input preparation#

  • PixInsight 1.9.4 or a later 1.9.x version.
  • At least two open images. Otherwise the script stops with the message "You need to have at least two images open (a star image and a starless image)."
  • A matching starless image. Create it from the image with stars using a star-removal tool of your choice. The two images must have the same dimensions and alignment. The script uses PixelMath on both images together and does not check this itself.
  • Different selections. The two image selections must be different images.

The preview shows the image data without an automatic stretch, so linear images look dark. The script does not check whether data is linear or stretched.

Installation and launch#

  1. Install MKScripts from the repository: in PixInsight choose Resources → Updates → Manage Repositories → Add, paste https://mhkastro.github.io/MKScripts/, then run Resources → Updates → Check for Updates. Full steps: Installing MKScripts in PixInsight.
  2. Open the image with stars and its starless version.
  3. Choose Script › MK Scripts › Star Reduction.

Basic workflow#

  1. Select the images: Image with stars and Starless image. The preview is calculated as soon as both are set and different.
  2. Choose a method.
    • Single strength: choose Star Protection (None, Protect Large Stars or Protect Small Stars) and set Reduction Strength.
    • Separate strengths: tick Use separate reduction strengths for small and large stars, then set Small Stars Strength and Large Stars Strength.
  3. Click Refresh Preview. Moving the strength sliders does not update the preview by itself.
  4. Compare. In Split View, the original is on the left and the reduced image on the right. Drag the divider to compare. Toggle Original switches the whole preview between before and after.
  5. Choose the output under Output Mode: Replace target image (default) or Create new image.
  6. Click Apply.
    • Replace target image modifies the image with stars. Undo reverts the last operation on that image.
    • Create new image opens a new image named after the target with _StarReduced appended.
  7. Click Close when you are finished.

Controls#

Images and method#

Control Default What it does
Image with stars First open image without "starless" in its name The image to reduce. With Replace target image, this image is modified.
Starless image First open image with "starless" in its name; otherwise the second open image The starless counterpart used for the Transfer Method.
Star Protection None None: reduction everywhere. Protect Large Stars: reduction is applied through a scale mask that limits it mainly to small stars. Protect Small Stars: the reverse, limiting it mainly to large stars. Disabled when separate strengths are used.
Use separate reduction strengths for small and large stars Off Replaces the single strength slider with Small Stars Strength and Large Stars Strength.

Changing either image, the protection mode, or the separate-strengths option recalculates the preview automatically.

Strength#

Control Range Default What it does
Reduction Strength 0.00–0.90 0.30 Strength of the reduction with a single setting. Higher values reduce stars more strongly.
Small Stars Strength 0.00–0.90 0.30 Strength in small-star regions (separate-strengths mode).
Large Stars Strength 0.00–0.90 0.30 Strength in large-star regions (separate-strengths mode).

You can type a value in the box next to each slider. Values outside the range are clamped, and invalid entries become 0.00. After changing a strength, click Refresh Preview.

Output Mode#

Option What it does
Replace target image Default. Applies the result to the image with stars.
Create new image Creates a new image named <image name>_StarReduced and leaves the original unchanged.

Exactly one option is always selected.

Preview Controls and preview#

Control or action What it does
Zoom Shows the current zoom level.
Refresh Preview Recalculates the preview with the current settings.
Split View Shows the original on the left and the reduced image on the right of a movable divider. This is the default view.
Toggle Original / Toggle Reduced Switches the whole preview between before and after.
Drag the divider In split view, drag near the dividing line (within about 10 pixels) to move it.
Mouse wheel Zooms around the pointer, up to 800 %.
Drag (left, right or middle button) Pans the preview.
Double-click Zooms to fit.
Navigator Click or drag in the mini-map to jump to a region.

Buttons#

Button What it does
Apply Checks that the two images are different, then applies the reduction using the selected output mode.
Undo Undoes the most recent operation on the image with stars. It is meant for Replace target image mode. It acts on whatever was done last to that image.
Close Closes the dialog.

How it works#

For each pixel of the image with stars (T) and the starless image (S):

  1. The strength is converted to a curve parameter s = 0.51 − 0.51 × strength.
  2. Both images are transformed with PixInsight's midtones transfer function, mtf(1 − s, ·).
  3. The result is 1 − ((1 − mtf(1 − s, T)) ÷ (1 − mtf(1 − s, S))) × (1 − S), kept between 0 and 1.

Where the two images are identical (no star), the result equals the original pixel. Where a star is present, its contribution is reduced according to the strength.

For Star Protection and separate strengths, the script first builds a temporary scale mask from the difference between the two images. It uses a median filter to separate larger structures, then dilation and smoothing. Large-star regions are bright in this mask.

  • Protect Large Stars applies the reduction through the inverted mask.
  • Protect Small Stars applies it through the normal mask.
  • Separate strengths blend a small-star result and a large-star result using the mask.

Tips#

  • Start moderately. The default of 0.30 is a reasonable starting point; increase it while watching the split view.
  • Use separate strengths when large stars need more reduction than small ones, or the other way around.
  • Name your starless image with "starless" to save selecting it each time.
  • Keep the original: use Create new image while you experiment, then compare the results side by side.
  • Large images: the preview is calculated at full resolution, so refreshing can take a while. Adjust the strength, then refresh once.

Troubleshooting and limitations#

Symptom Explanation and solution
"You need to have at least two images open…" Open the image with stars and its starless version, then run the script again.
"The 'Stars' and 'Starless' image selections must be different." Select two different images.
The preview is empty or does not update after changing images Both selections point to the same image. Choose a different starless image.
The preview does not change when I move a slider Click Refresh Preview. Slider changes do not refresh the preview automatically.
An error appears when the preview is calculated Make sure both images have the same dimensions.
The preview looks very dark The data is probably linear. The preview is not stretched.
Undo removed something I did not expect Undo reverts the last operation on the image with stars, whatever it was.

Limitations:

  • Existing masks: when Star Protection is used with Replace target image, the script temporarily sets its own mask on the image with stars and removes the mask afterwards. A mask you had already applied to that image will no longer be applied. Reapply it if needed.
  • The preview is calculated at full resolution.
  • The script works on the main view of each image.
  • The dialog has a fixed size once it opens. The preview area alone requests at least 700 × 700 pixels.

Version information#

Item Value
Version 1.3
Source file MKStarReduction V1.3.js
Menu (feature ID) Script › MK Scripts › Star Reduction
Installed from MKScripts repository (https://mhkastro.github.io/MKScripts/)
Repository release date 27 July 2026
PixInsight versions 1.9.4 – 1.9.x
Tested in PixInsight Not yet recorded for this guide

Release notes for each version are listed in the Releases section of this page.

Updates

New versions are delivered through the MKScripts repository: use Resources › Updates › Check for Updates in PixInsight.

License

Being publicly available does not make the scripts open source. See the terms of use.