Geometry, Merging & Export
Lens correction, guided perspective and the Transform sliders are applied on the GPU. The analysis tools (auto straighten, Auto Adjust, culling), negative conversion, the merges and file encoding run on the CPU.
Lens correction
RapidRAW ships with the Lensfun database (59 XML files) and follows Lensfun's models and conventions, so a profile gives the same result as in other Lensfun-based apps.
Finding the profile for each photo: the profile is not stored in the edit. Every time a photo is rendered, RapidRAW reads that photo's EXIF (camera, lens, focal length, aperture, subject distance) and builds the profile from it. Results are cached per file. That's why copy and paste works across photos with different focal lengths, and in Auto mode even across different lenses.
- Auto: the EXIF lens name is fuzzy-matched against the lenses of the camera's maker, with a penalty for much longer names. If nothing matches, all makers are searched. If that finds nothing too, or the photo has no lens name, a fixed-lens camera is found through its mount (only if exactly one lens uses that mount).
- Manual: the lens you picked is used, with the focal length, aperture and distance of each photo.
- Crop factor: your camera's crop factor comes from Lensfun's camera list. Profiles calibrated on a sensor more than about 4% smaller than yours are skipped, and a small score bonus prefers profiles with a fitting crop factor.
Choosing the calibration:
| Correction | How the values are chosen |
|---|---|
| Distortion | Smooth (Hermite spline) interpolation between the calibrated focal lengths, with the terms scaled by the focal length before interpolating. Outside the calibrated range, the nearest calibration is used. |
| Chromatic aberration (TCA) | Same, for the red and blue terms. Both the linear and the full poly3 model are supported. |
| Vignetting | Every calibration is weighted by its distance to your shot in focal length, 1/aperture and 1/distance, then the terms are averaged. If no calibration is close enough, vignetting is turned off. Needs the aperture in EXIF; a missing subject distance counts as 1000 m. |
The models:
| Correction | Model | Formula |
|---|---|---|
| Distortion | poly3 |
rd = r · (1 − k1 + k1·r²) |
| Distortion | poly5 |
rd = r · (1 + k1·r² + k2·r⁴) |
| Distortion | ptlens |
rd = r · (a·r³ + b·r² + c·r + 1 − a − b − c) |
| TCA | linear, poly3 |
rd = r · (v + c·r + b·r²) for red and for blue (linear only has v) |
| Vignetting | pa |
brightness × (1 + k1·r² + k2·r⁴ + k3·r⁶) |
The radius is normalized like in Lensfun. For distortion and TCA, r = 1 is half the short side of the frame the lens was calibrated on (aspect ratio from the profile, 3:2 if missing). For vignetting, r = 1 is half the diagonal. Both are adjusted by the ratio between the calibration crop factor and yours.
Applying it: one GPU pass (transform.wgsl) uses inverse mapping: for every output pixel, it calculates where it comes from in the original and samples it with bilinear interpolation. The order is perspective and Transform, the auto crop zoom, the manual Distortion slider, lens distortion, TCA (red and blue sampled at their own radii), then vignetting (the brightness is divided by the falloff). The Amount sliders scale the distortion terms, the TCA difference from 1, and the vignetting gain.
Auto crop: when lens distortion or the Distortion slider is on, RapidRAW traces 512 radii from the center to the corner through the combined distortion and checks 64 points along the frame edge. The smallest zoom that keeps all of them inside the image is used, plus 0.2%. This works for barrel, pincushion and wavy distortion, so no empty corners show and no more of the image is cut than needed.
AI masks and other AI tools work on a geometry-corrected 8-bit copy of the full image, made on the CPU with the same model.
Transform
The Transform sliders (Vertical, Horizontal, Rotate, Aspect, Scale, X/Y Offset) build one 3x3 projective matrix around the image center. Vertical and Horizontal are perspective (keystone) terms, scaled to the image size so they behave the same at any resolution. Lens correction, guided perspective and the Transform sliders are combined and applied in one resampling pass on the GPU, so the image is only interpolated once for them. The crop, fine rotation, 90° turns and flips follow in a second GPU pass; only fine rotation interpolates again.
Auto straighten
- The image (up to 1024 px, with your current geometry) is converted to luminance.
- Line Segment Detector (LSD) finds straight edges. Short lines (under 2% of the long side) and diagonal lines (30° to 60°) are ignored.
- For horizontal and vertical lines separately, RapidRAW looks for a vanishing point that most lines agree on. Line groups that converge strongly (real perspective, such as a tall building shot from below) are ignored, because they would tilt the result.
- The rotation is a length-weighted average of how far the remaining lines are from level or plumb. Results larger than ±10° are rejected.
- The crop is adjusted to the largest rectangle that fits inside the rotated image.
Guided perspective
You draw up to two vertical and two horizontal guides along edges that should be straight. RapidRAW intersects each pair to find its vanishing point, then builds a homography that rotates the vanishing point onto the axis and sends it to infinity, which makes the lines parallel. With one line of each kind, it levels the horizontal and shears the vertical upright.
Results that would flip or fold the image are rejected. The automatic crop is the largest axis-aligned rectangle inside the corrected image, found with a 96x96 search followed by refinement.
Negative conversion
For scanned film negatives:
- Each channel is converted to optical density:
D = −log10(value). - The 0.1% and 99.9% percentiles of each channel set its range, measured with a 12% margin ignored on every side (to skip the film holder and rebate).
- Each channel is normalized to that range and multiplied by its weight (the Red, Green and Blue sliders act as color balance in density space). Normalizing each channel removes the orange mask.
- A logistic S-curve maps density to brightness. Contrast sets its slope and Exposure moves its center.
- Colors are desaturated as they approach clipping, then encoded with a 2.2 gamma.
After conversion, the image is treated like a non-RAW file by the rest of the pipeline.
Auto Adjust
Auto Adjust analyzes the image at 1024 px:
| Setting | Rule |
|---|---|
| Exposure | Moves the median luma toward the middle, but never so far that the 99th percentile clips. |
| Contrast | If the 1% to 99% range is narrow, contrast is raised. |
| Shadows | Lifted if more than 5% of pixels are very dark. |
| Highlights | Lowered if more than 2% of pixels are very bright. |
| Vibrance | Raised for low-saturation images. |
| Clarity, Dehaze | Raised for flat, low-contrast images. |
| Vignette, Centré | Added if the center is brighter than the edges. |
| Blacks, Whites | Set after simulating the above. |
Subtle, Normal and Strong multiply the result by 0.5, 1.0 and 1.5. Auto Adjust does not change white balance.
Culling
Each photo is analyzed at 720 px:
- Sharpness: variance of the Laplacian (edge strength) on the whole image and on the central quarter.
- Exposure: penalty for pixels that are almost black or almost white.
- Score:
0.40 · sharpness + 0.35 · center sharpness + 0.25 · exposure, with sharpness on a log scale. - Similarity: a 16x16 perceptual hash (double gradient). Photos within the similarity threshold (Hamming distance) are grouped, and the highest-scoring photo in each group is suggested as the pick.
Because sharpness is measured on a 720 px version, Auto Cull catches clearly blurred photos well, but can't tell the difference between "tack sharp" and "slightly soft" at 100%.
Panorama
- Features: FAST corners and 256-bit BRIEF descriptors on a copy with a long side of up to 1600 px.
- Matching: nearest neighbour with Lowe's ratio test (0.8).
- Geometry: RANSAC (2500 iterations, 5 px tolerance, at least 15 inliers) estimates a homography for every pair of images.
- Layout: a maximum spanning tree over the pairs (weighted by inliers) connects all images; images that don't connect are left out with a warning.
- Projection: planar (rectilinear). Very wide panoramas get strongly stretched at the sides.
- Seams: for each new image, the best seam through the overlap is found with dynamic programming (the path where the two images differ least), then blended with a 100 px cosine feather. In low-detail areas such as sky, the feather is widened to 500 px to hide differences.
There's no exposure matching between frames, so use manual exposure when shooting. The result is saved as a 32-bit float TIFF named <first photo>_Pano.tiff.
HDR merge
- Frames are aligned to the middle exposure: features are matched as for panoramas, and a rigid transform (rotation and shift) is fitted.
- Each frame is divided by its exposure time and ISO to estimate scene radiance, then the frames are averaged, weighted by their share of the total exposure time (longer exposures have less noise).
- The result is normalized to 0 to 1 and saved as a 32-bit float TIFF named
<first photo>_Hdr.tiff, ready to edit.
Exposure time and ISO must be in the EXIF data. There is no ghost removal for moving objects.
Focus stacking
- Alignment: each frame is aligned to its neighbour with a direct, intensity-based method (Lucas–Kanade with Levenberg–Marquardt), coarse to fine, from translation up to an affine model with radial and polynomial distortion. This handles focus breathing (the magnification change when focusing). Brightness differences are corrected too.
- Focus measure: for each frame, the local energy in each band of a Laplacian pyramid shows how sharp it is.
- Decision: the sharpest frame per pixel is chosen, cleaned up with a guided filter and a weighted median, and penalized where a frame's brightness differs from the others (to avoid halos and ghosting).
- Fusion: frames are blended in a Laplacian pyramid, with sharp selection for fine detail and soft blending for large-scale tones.
- The result is cropped to the area covered by all frames and saved as a 16-bit TIFF named
<first photo>_Stacked.tiff. The dialog also shows a depth map of which frame was used where.
Saving merge results
Panorama, HDR, focus stack and collage results are saved next to the first photo. Collages are saved as <first photo>_Collage.png. If a name is taken, by a file or by a leftover .rrdata sidecar, _1, _2 and so on are added, so an earlier result is never overwritten. The file is written to a temporary name first and then renamed, so a crash never leaves half a file. HDR, panorama and focus stack results get the EXIF data of the first photo, and TIFF results also get an sRGB profile.
Export
- The full-resolution image is prepared on the CPU (AI Denoise, negative conversion, retouch patches) and uploaded to the GPU. Geometry, Relight, Fog, Lens Blur, crop and the adjustments shader run there, with 16-bit output for 16-bit TIFF and 8-bit otherwise. Images larger than the GPU's maximum texture size are scaled down to fit.
- Resize with Lanczos3. There is no extra output sharpening; adjust Sharpness if you downscale a lot.
- Border and watermark are added.
- The file is encoded and metadata is written.
| Format | Notes | sRGB profile | Metadata |
|---|---|---|---|
| JPEG | 8-bit, quality setting | yes | EXIF and XMP |
| PNG | 8-bit | yes | EXIF and XMP |
| TIFF | 8 or 16-bit, uncompressed | yes | EXIF |
| WebP | lossy, quality setting | no | EXIF and XMP |
| JPEG XL | quality setting, 100 = lossless | no | no |
| AVIF | default encoder quality | no | no |
All exports are sRGB. EXIF is copied from the original (GPS can be removed) and gets the export size, the DPI and Software: RapidRAW. XMP holds your rating, color label and tags. TIFF writes the EXIF and GPS data as real TIFF tags and keeps UTF-8 text.
Lossless JPEG XL turns off the encoder's tree learning. In a test with a 36 MP photo, this cut the peak memory from about 10 GB to 2.8 GB and the time from 212 s to 14 s, with files about 50% larger. The memory budget for parallel exports also counts the JPEG XL encoder, so several large JPEG XL exports wait for each other instead of running out of memory.
Also export the original renders a second image from the same base, with default settings except orientation, flips, lens correction and baseline exposure, plus (by option) the crop and Transform settings and the Exposure slider. It goes through the same resize, border, watermark and encoding steps.
LUT export renders a 33x33x33 grid through your edit and saves it as a .cube file. Effects that depend on neighbouring pixels (sharpening, noise reduction, clarity, structure, dehaze, glow, halation, flares, grain, vignette, chromatic aberration) and masks can't be stored in a LUT, so they are left out.
RapidRAW