Files
luminary/src/lib/noiseProfile.ts
T
bhursey cd52a2f82f Initial commit: Luminary photo catalog and RAW editor
Browser-based photo catalog with an optional team server (SQLite + LibRaw).
Local database, uploaded photos, build output and dependencies are gitignored.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-23 15:19:25 +00:00

28 lines
1.2 KiB
TypeScript

import type { Edits, PhotoMeta } from '../types';
/**
* A camera/ISO-aware starting point for the existing denoise sliders.
*
* This is a deterministic profile curve, not a learned denoiser: it scales the
* luminance and chroma smoothing with the ISO the file was shot at and keeps
* more detail at low ISOs. The user can still tune every value afterwards.
*/
export function autoNoiseFor(meta: PhotoMeta): Edits['noise'] {
const iso = Math.max(50, Number(meta.iso) || 100);
const stops = Math.max(0, Math.log2(iso / 100));
const luminance = Math.round(Math.min(78, stops * 11));
const chroma = Math.round(Math.min(88, 6 + stops * 12));
const detail = Math.round(Math.max(18, 52 - stops * 3));
const chromaDetail = Math.round(Math.max(22, 54 - stops * 4));
// Cameras with a known strong high-ISO reputation get a small nudge; the
// number is deliberately modest so this never becomes a hidden "look".
const camera = (meta.camera ?? '').toLowerCase();
const nudge = /a7s|a7s ii|a7s iii|fx3|r6|r5|z6|z7|d5|d6/.test(camera) ? -4 : 0;
return {
luminance: Math.max(0, luminance + nudge),
detail,
chroma: Math.max(0, chroma + nudge),
chromaDetail,
};
}