StellarPix
← Back to Learn
ProcessingPublic tutorial · No membership required10 min read

Enhance Local Contrast with LocalHistogramEqualization (LHE)

Bring out structure in a stretched image with a controlled local-contrast adjustment. Learn how kernel radius, contrast limit, Amount, and masks work together, and check for noise, halos, and overprocessing.

Sources reviewed October 25, 2026

What LHE is useful for

LocalHistogramEqualization increases contrast within neighborhoods of an image rather than applying the same global curve everywhere. It can make nebular filaments, dust lanes, or galaxy structure easier to distinguish. It can also make noise and artifacts more visible.

This lesson uses LHE as an optional finishing step after a permanent stretch. It does not replace gradient correction, recover clipped cores, or restore detail missing from the data. A result that appears more textured is not automatically more informative.

For a separated-star workflow, test LHE on the stretched starless object before restoring stars. For an image with stars still present, use restrained settings and appropriate protection. Keep a pre-LHE checkpoint so the comparison remains reversible.

1. Prepare a stretched working copy

Finish the intended linear processing and apply a permanent stretch first. Turn STF off: the image should still have its intended brightness. If it becomes almost black, return to the stretching lesson rather than applying this finishing recipe to linear pixels.

Save Target_before_LHE.xisf and make a duplicate. Inspect it at fit-to-window and 1:1, noting faint background noise, bright edges, star-removal remnants, and existing halos. Those features can become more conspicuous after local contrast enhancement.

Choose several representative test areas: useful object structure, a bright region, and a low-signal background. A small preview containing only attractive detail can hide the damage elsewhere. Use previews for exploration, then validate on the complete image because local neighborhoods at preview edges differ from the full frame.

2. Understand the main controls

Find LocalHistogramEqualization through All Processes. Reset a reused instance and read the installed tooltips for the current controls. Work with one parameter at a time.

Kernel radius is measured in pixels, so a value does not represent the same sky scale after resizing or with another camera. Histogram resolution describes the algorithm’s internal histogram; it is not a command to convert your working image to an 8-bit export.

ControlWhat to compareCommon mistake
Kernel radiusThe pixel neighborhood used for local contrast; smaller and larger values emphasize different scalesUsing a small radius that exaggerates noise and bright-edge rings
Contrast limitHow strongly the local transfer can increase contrastRaising it until every faint feature looks harsh
AmountThe contribution of the processed result blended with the originalLeaving full strength when a subtle contribution is enough
Histogram resolution / kernel shapeAdditional algorithm settings to hold fixed during the first comparisonsChanging every control simultaneously

3. Protect the background with a mask

For a simple first mask, use ChannelExtraction in CIE L*a*b* mode to extract CIE L* from a duplicate of the stretched color image. For a grayscale target, duplicate the image itself. Give the mask a clear identifier such as Target_LHE_mask and preserve matching dimensions and geometry.

Use HistogramTransformation or CurvesTransformation on the mask copy to darken low-signal background while leaving useful object regions lighter. Keep transitions gradual. Do not apply these mask-building changes to the science image by mistake.

Attach the mask through Mask → Select Mask and enable it. In PixInsight, white permits processing, black protects, and gray allows a partial effect. Inspect the mask image and overlay, checking inversion rather than assuming the colored overlay means the right areas are protected.

A lightness mask often includes bright stars and cores as well as the object. It is not automatically a star-protection mask. For the beginner exercise, a clean starless base simplifies that problem; otherwise review additional star protection or reduce the effect. The linked masking example demonstrates a more developed background-and-star approach.

4. Make one restrained trial

The following values are an exercise for comparison, not recommended settings for every image. Start over from the same pre-LHE image for each alternative.

  1. On the masked working duplicate, open LHE. Try Kernel radius 64 pixels, Contrast limit 1.5, and Amount 0.25 as a modest first test. Leave histogram resolution and kernel shape at the installed defaults and record them.
  2. Test a representative preview or a disposable full-image duplicate. Keep STF off while judging this stretched input. Verify that the intended mask is enabled on the test target.
  3. Inspect useful structure and low-signal areas at 1:1, then compare at the expected display size. Check whether the mask actually prevents background noise from becoming more prominent.
  4. Save a trial or undo back to the baseline before testing another radius, such as 128 pixels with the other settings fixed. Do not apply the second test on top of the first.
  5. Once you prefer a scale, compare a lower Amount before increasing the contrast limit. A setting that is barely noticeable when toggled can be more useful than one that immediately draws attention to the processing.

5. Inspect for overprocessing

Blink the baseline and candidate with the same zoom and display conditions. Look for stronger separation of existing structures without new dark rims, bright halos, or coarse texture. Review faint dust and smooth transitions as carefully as bright filaments.

Reject a trial that makes low-signal areas look grainy, creates a mottled background, hardens star-removal scars, or produces a cut-out appearance around masked regions. Lower Amount, reconsider the radius, and inspect mask transitions before adding more noise reduction to conceal the effect.

Check bright cores for clipping and surrounding dark bands. LHE cannot recover saturated detail. A bright core needing a different dynamic-range treatment is a separate task, not a reason to keep raising local contrast.

On color data, compare saturation and apparent hue as well as brightness. Local contrast can change the visual balance even when your intention is structural. Avoid compensating with large simultaneous color changes during the test.

6. Finish the full image and restore stars

Apply the selected configuration once to a fresh full-image working copy, with the validated mask. Inspect the whole output again; do not accept a full-frame result solely because one preview looked good.

For a starless branch, save the accepted object image, then restore the separately prepared stars with ImageBlend using the linked lesson. Do not apply LHE to the stars layer merely because you used it on the nebula. Inspect the composite around star positions after restoration.

For stars-intact processing, inspect bright stars and their surroundings closely. If adequate protection proves difficult, skip the enhancement rather than accepting halos. Multiple-radius passes are optional advanced experiments; this first workflow uses one controlled pass.

Save Target_after_LHE.xisf, the pre-LHE master, mask, and process instance. Record whether stars were present, radius, contrast limit, Amount, other retained settings, and why the result was accepted. Continue to selective color finishing or export as needed.

Quick troubleshooting

Little or no change: verify the target, mask enable/inversion state, Amount, and contrast limit before increasing strength. A fully protective mask can prevent the operation where you expected it.

Background noise increases: inspect the mask and source signal quality, lower Amount, and compare a different radius. Contrast enhancement is not evidence that new detail has been recovered.

Halos or dark outlines: compare radius, strength, mask edges, and existing bright-star artifacts. Return to a fresh baseline instead of layering another correction on top.

Only the preview looks good: check context and neighborhood size, then test the full image. Keep previews large enough to include surrounding structure.

The result looks impressive at 1:1 but harsh when reduced: judge the intended presentation size too. Finishing should support the image as a whole.

This is an original practice sequence using the linked examples and guidance. Older references establish the local-contrast and masking approach; installed documentation governs current controls. There is no requirement to apply LHE to every image.

See the technique in practice

This lesson is public. Detailed project workflows and dataset downloads require an active membership. Dataset selections follow your membership allowance; reading a workflow does not use a selection.

  • Finding the Lion in gold, cyan and blue

    See this technique in the recorded Lion Nebula Sh2-132 workflow. Use that project’s documented order, retained settings, and limitations.

    Public overview · Member-only detailed workflow

    Explore story and member workflow →

    View member dataset →Member-only download · selection allowance applies

  • Let the shell stand alone

    See this technique in the recorded Crescent Nebula - NGC6888 workflow. Use that project’s documented order, retained settings, and limitations.

    Public overview · Member-only detailed workflow

    Explore story and member workflow →
  • Finding the Pelican in blue and gold

    See this technique in the recorded Pelican Nebula - IC5070 workflow. Use that project’s documented order, retained settings, and limitations.

    Public overview · Member-only detailed workflow

    Explore story and member workflow →