# Image Editor

The Image Editor is specifically designed for processing stacked images obtained from Lucky Imaging. It supports the following features.

## Features

### Wavelet Processing
Wavelet Processing is one of the most powerful and popular image processing techniques in planetary astrophotography, primarily used for sharpening and noise control. The concept behind Wavelet Processing is straightforward:

1. Smooth the image with a filter, such as a blur filter, to intentionally remove details from the image.
2. Subtract the smoothed image from the original image. This creates an image showing the details that were smoothed out of the original.
3. Amplify the details in this difference image and add them back into the original image, resulting in a new image with sharpened details.
4. Repeat this process multiple times at different pixel scales, amplifying details of varying sizes at each level.

Planet Stacker X supports two different wavelet processing algorithms:

#### Gaussian Wavelets

This newer technique has gained popularity in recent years and uses a Gaussian blur as the smoothing filter. In this mode, the number in the stepper controls the radius of the Gaussian blur, while the slider controls the intensity of detail amplification. Additionally, the denoise stepper can apply an extra Gaussian blur at each level to reduce noise inherent in this technique.

#### Starlet Wavelets

The standard wavelet processing algorithm uses an evenly spaced convolution filter, which increases in size at each wavelet scale. In this mode, both the stepper and slider control how much to enhance the detail levels at each scale. The denoise stepper applies a threshold that determines when to include pixels in a particular detail scale level. The size of the convolution filter changes based on the selected options:

- When Dyadic is selected, the filter size scales exponentially (1-2-4-8).
- When Linear is selected, the filter size increases linearly (1-2-3-4).

Three different smoothing functions are supported:

- BSpline: Pixels in the center of the convolution are given significantly more weight than those at the edges. This emphasizes fine details and sharp edges but can introduce more noise and smooth out larger details.
- Linear Interpolation: Pixels in the center receive more weight, based on a linear function relative to their position. This offers a good balance between accentuating edges and preserving larger details.
- Mean: All pixels are given equal weight. This is ideal when you want to preserve large structures, though it may de-emphasize edges.

It's highly recommended to experiment with different options and filters to achieve the best results for your data.

### Deconvolution
Deconvolution attempts to increase image sharpness by counteracting the natural blurring caused by atmospheric distortion and optical imperfections, based on a provided Point Spread Function (PSF).

In a perfect imaging environment with no atmosphere and a perfect telescope, a point light source, such as a star, would appear as the size of a single pixel on the sensor.

Realistically, due to atmospheric distortion and optical imperfections in a telescope, a point light source is spread over several pixels. The brighter the star, the more pixels it tends to be spread across. A PSF is a mathematical model that describes how this blurring effect distributes light from point sources across the sensor.

If you can calculate the PSF, or even make an educated guess, you can use a process known as deconvolution to counteract this effect and "unblur" the image. Specifically, the software uses Richardson-Lucy deconvolution, an iterative algorithm, where each iteration sharpens the image incrementally until the blurring effect is minimized.

You can estimate the ideal PSF by identifying stars or other point light sources in your image and averaging their radius in pixels. If no stars are available, you can make an informed guess by considering how many arcseconds of sky each pixel of your sensor covers and starting from there. 

### RGB Balancing
Use RGB Balancing to adjust the color balance by modifying the levels of the Red, Green, and Blue channels. This is ideal for correcting color casts and achieving accurate color representation, especially when dealing with RAW data, which often contains more green than a natural image. There is also an "Auto Balance" button that attempts to balance color casts automatically.

### RGB Shift
When imaging planets through thick atmosphere—common when the target is near the horizon—the atmosphere can cause red and blue light to refract at different angles, leading to red and blue halos in the image. This phenomenon is known as atmospheric dispersion. Use RGB Shift to counteract this by shifting the red or blue channels to align them.

It is recommended to try auto shift first and manually adjust the RGB shift only if auto shift produces artifacts or fails to correct the issue.

### Noise Reduction
This feature applies a general noise reduction filter to the entire image. It can sometimes yield better results than denoising each individual wavelet layer with the wavelet processing tool.

### Median Smoothing
Reduces noise by replacing each pixel's value with the median of the neighboring pixels. This is particularly effective for removing small artifacts while preserving sharp edges.

### Curves Editor
Applies a tone curve to each pixel in the image. This is one of the most effective tools for creating deep contrast between features in an image.

### Deringing
When performing Wavelet Processing, rings can sometimes appear around bright areas of the image. The Deringing feature removes these ring artifacts.

### Exposure
Adjusts the overall brightness of the image. This is useful for correcting underexposed or overexposed images to bring out more detail.

### Gamma
Modifies the gamma curve of the image to adjust the midtones without affecting the shadows and highlights. This helps improve the overall contrast and brightness perception.

### Saturation
Adjusts the intensity of colors in the image. Users can increase saturation for a more vibrant appearance or decrease it for a more muted look.

### Example Workflow
1. Load a stacked planetary image into the image editor.
2. Enable RGB SHIFT and turn on "Auto". If chromatic aberation is still present, uncheck "Auto" and manually align the channels.
3. Enabling RGB BALANCE and tap the "Auto Balance" button. Perform further color corrections as needed.
4. Enable DECONVOLUTION. If you have a reference point light in the image such a star, then adjust the PSF until the PSF matchs the reference point light. Otherwise do best guess efforts based on the pixel size of the camera.
5. Enable WAVELETS. Choose Gaussian as the wavelet style. In the Sharp boxes, input values like 0.5, 1.0, 1.5, and 2.0. Adjust the sliders until the image reaches the desired sharpness. Apply Denoise to the first and/or layer to remove noise artifacts.
6. (Optional) Duplicate the image and repeat step 4 with Starlet as the wavelet style. Play with the sliders. See what looks best for your image. Compare this with Gaussian wavelets and see which you like the best.
7. If you see ringing artifacts, enable DERINGING and asjust the slider until the rings go away.
8. Enable NOISE REDUCTION. Adjust the slider and/or enable MEDIAN SMOOTHING to denoise any leftover Wavelet artifacts.
8. Adjust GAMMA, SATURATION and EXPOSURE according to preference.
9. Enable CURVES. Apply a contrast curve by adding to points, dragging the bottom down and to the right and the top to the up and left creating an S shape.
10. Continue to iterate until you get the image you want.

### General Tips
- Always work on a copy of your original image to preserve the unprocessed data.
- Apply sharpening techniques sparingly to avoid over-processing, which can result in unnatural-looking images.
- Use the Curves Editor in conjunction with Exposure and Gamma adjustments to achieve a balanced tonal range.
- For images with significant chromatic aberration, start with the RGB Shift tool before making other color adjustments.
