Clarity adds local contrast, from fine texture to whole structures, without the bright and dark rims an unsharp mask leaves along edges. Instead of subtracting a blurred copy, it fits a local linear model in every neighborhood, and a linear function of an edge cannot leave the edge's own range of values, so no rim can form. It works on linear and stretched images alike.

Categories
  • Sharpening
Keywords
  • clarity
  • local contrast
  • guided filter
  • edges
  • halos
  • rims
  • unsharp mask
  • edge threshold
  • radius
  • structure
  • stretched data
  • linear data
  • DeepSharp

1Introduction

An unsharp mask subtracts a blurred copy of the image, and a blur crosses edges: beside a bright edge it subtracts too little on one side and too much on the other. That pair of bright and dark rims is its characteristic artifact. Clarity uses a guided filter instead: in every neighborhood it fits the image as a linear function of itself, smoothing where the variation is below the noise and keeping it exactly where it is above. The difference between the image and that fit is the detail, and it is added back. Since a linear function of an edge stays within the edge's values, the detail added cannot overshoot it.

Measured against an unsharp mask of the same radius and amount, in the ring around the brightest pixels of an image of the Veil, Clarity changed them by +0.001 sigma on average; the unsharp mask by −1.05, with a worst case of −44.

The rims meant here are the artifacts of the processing, not the optical halo a bright star can show, which is real light in the image.

Clarity is DeepSharp's Clarity method. DeepSharp's PixInsight module puts its seven methods on seven tabs of one process; in DSPX each is a process of its own in Process > Sharpening, and they share DeepSharp's engine and its results.

The Orion Nebula before and after Clarity
Clarity at its defaults. Left, the Orion Nebula in a stretched wide field of Orion; right, after Clarity with a radius of 16 pixels and an amount of 0.7. The nebula's structure and the dust around it stand out, with no rim along their edges.

2Quick Start

  1. Open the image and choose Process > Sharpening > Clarity. With the live preview (the eye) on, the result shows on the image as we change the settings.
  2. Set Radius to the size of what should gain contrast: small for texture, large for whole structures.
  3. Set Amount to taste.
  4. Click Apply.

3Interface & Parameters

The panel has two sections, Clarity and Output, each of which folds away with the arrow beside its title. Under them are the image the process applies to with the live preview's eye, the buttons and the system bar along the bottom.

The Clarity panel
The Clarity panel with its default settings.

3.1Clarity

Radius: The size of the neighborhood, in pixels, from 1 to 256; 16 by default. Everything finer than this becomes the detail that is added back; everything coarser is left as it is. Small radii bring out texture in nebulosity; large radii lift whole structures, arms, lanes and shells, and look more like local contrast than like sharpening.

Edge threshold: How many noise sigmas count as a real edge, from 0.1 to 20; 2 by default. Variation below this is treated as flat and smoothed, so its contrast is not amplified; variation above it is kept exactly. Low values enhance faint texture along with the noise; high values act only on strong structure. It is counted in sigmas because the sky and the star cores of a linear frame are three decades apart, and no fixed number would transfer from one image to another.

Amount: How much of the detail is added back, from 0 to 3; 0.70 by default. At 0 there is nothing to do, and the panel says so.

3.2Output

Output: Where the result goes.

3.3Apply, Preview and Instance

Live preview (the eye): At the end of the Applies to row; Preview in the system bar is the same switch. On by default. The image shows Clarity applied to the part in view, as the settings change, with the banner "PREVIEW only, nothing applied"; the image itself does not change until Apply. Before, in the banner, or the backslash key held, shows the image as it is. At a reduced zoom (Fit, 1:2...) the preview is computed on the reduced view with Radius scaled to it, and Exact, in the banner, computes the part in view at full resolution. At any zoom the preview is close, not exact: the noise that Edge threshold counts in is measured on the part in view, and the banner says so.

Applies to: The image Clarity works on, chosen in a list of the open images. It shows the image in front, and follows it as we bring other images to the front. Picking another image in the list makes the panel work on that one, its live preview included, without bringing it to the front; the pick stays while we work on other images, and Follow Active, the small button that appears beside the list, makes the panel follow the image in front again. An image that a tool or a run is working on is listed, but cannot be picked.

Apply: Applies Clarity to the image named in Applies to, as Output says, channel by channel for a color image. Apply ends the live preview; it starts again when a setting changes.

Instance: Shows the process as the panel has it now, as text: the settings as a DSPX process (.dsproc) or as a PixInsight process icon (.xpsm), chosen under Format. The icon is a DeepSharp icon with its method set to Clarity, which DeepSharp's PixInsight module opens on that tab. Copy puts the text on the clipboard; Save... saves it as a file and puts it on the Process Shelf.

Reset: Puts every setting back to its default.

The system bar along the bottom of the panel has the same commands as small icons: at the left, drag to apply and Apply; at the right, Instance, Help (this page) and Reset. Drag to apply, the first icon, carries the process with its settings: dropped on an image's window, it applies them to that image, whatever image the panel works on; dropped on the Process Shelf, it is kept there as a row of its own. With Edit > Preferences > Layout > Hide classic buttons, the bar alone has them.

4The Radius

The radius decides what Clarity is: with a few pixels it is a sharpening of texture; with tens of pixels it is local contrast, the larger shapes of the nebula pulled apart from their surroundings. Both are safe from rims, so the choice is only about which detail we want to bring forward.

The same part of the image with Clarity at radius 16 and at radius 64
Two radii. Left, radius 16, the default: the texture of the nebula is lifted. Right, radius 64, the same amount: the larger shapes gain contrast against their surroundings.

5Example

An image before Clarity The same image after Clarity
An image before and after Clarity.

6Usage Tips and Tricks

Presence rather than detail. Clarity is for structures that need to stand out, and for any edge that must not be given a rim.

After Texture Sharpen. After a stretch, Texture Sharpen first for the fine detail, then Clarity for the larger contrast the stretch flattened: in that order each effect stays legible.

Raise Edge threshold on noisy images. The grain is then treated as flat and left alone, and only real structure gains contrast.

Two passes, two radii. A small radius and a large one, applied one after the other, bring out the texture and the shapes without either rimming.

GPU. In DSPX mode the whole method runs on the graphics card when the image is a quarter of a megapixel or more: the luminance, the level and noise measure, the guided filter and the scaling of the channels. A 24 MP color image runs about fourteen times faster than on the processor, and a radius of any size costs the same. An image with a NaN or an infinite sample stays on the processor. The result agrees with the processor's to a few millionths of the range. Choose CPU only in Edit > Preferences > Performance / AI to keep it on the processor, and see The Processor and the GPU.

Deep Sharpen: a trained network undoes the measured blur of a linear image.

Deconvolution: Richardson-Lucy against the measured blur of a linear image.

Multiscale Sharpen: a gain for each size of detail.

Texture Sharpen: sharpens the faint texture and quiets the sky in one pass.

Flow Sharpen: sharpens across the structure, never along it.

Filament Sharpen: finds long thin structure, enhances it or makes a mask of it.

Unsharp Mask: the classic local contrast by a blurred copy, with its deringing.

HDR Compression: flattens the large scale brightness, so the structure inside bright areas shows.