From 69ad2cafc48eaaad12942e51b603f7d743c8bcdb Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 08:22:25 -0500 Subject: [PATCH] raw,camera_raw: guard <0.3px texture/clarity blur and route fused band demosaic through craft_develop --- crates/algo/src/camera_raw.rs | 9 ++++++++- crates/raw/src/develop.rs | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/algo/src/camera_raw.rs b/crates/algo/src/camera_raw.rs index 5ce531db5c..7b41fdf955 100644 --- a/crates/algo/src/camera_raw.rs +++ b/crates/algo/src/camera_raw.rs @@ -565,8 +565,15 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, inputs: & let clar = (ds.effects.clarity != 0.0) .then_some(sigmas.clarity) .flatten() + .map(|s| s * ps) + .filter(|&s| s >= 0.3) .map(|s| craft_develop::local::guided_fast(&log_l, s, craft_develop::local::CLARITY_EPS)); - let tex = (ds.effects.texture != 0.0).then_some(sigmas.texture).flatten().map(|s| craft_develop::raster::blur::gaussian(&log_l, s)); + let tex = (ds.effects.texture != 0.0) + .then_some(sigmas.texture) + .flatten() + .map(|s| s * ps) + .filter(|&s| s >= 0.3) + .map(|s| craft_develop::raster::blur::gaussian(&log_l, s)); let dark = (ds.effects.dehaze != 0.0).then(|| { let d = craft_develop::raster::Plane { width: w, height: h, data: img.data.iter().map(|c| craft_develop::local::dark_of(*c)).collect() }; let air = craft_develop::local::airlight(&d); diff --git a/crates/raw/src/develop.rs b/crates/raw/src/develop.rs index 4c3ed09f71..8693584fec 100644 --- a/crates/raw/src/develop.rs +++ b/crates/raw/src/develop.rs @@ -467,7 +467,38 @@ fn develop(s: &Sensor, opts: &DevelopOptions, allow_fused: bool) -> Result(); - if bayer && fused { + if bayer && fused && matches!(opts.demosaic, Demosaic::Bilinear | Demosaic::Ahd) { + let p = cfa.phase(c.x, c.y); + pattern = Some(names(&p)); + let method = match opts.demosaic { + Demosaic::Bilinear => craft_develop::sensor::Method::Bilinear, + Demosaic::Ahd | Demosaic::Mhc => craft_develop::sensor::Method::Ahd, + }; + let mut o = vec![0u16; w * h * 3]; + par::chunks_mut(&mut o, band * w * 3, |b, chunk| { + let y0 = b * band; + let rows = chunk.len() / (w * 3); + let y_start = y0.saturating_sub(PAD); + let y_end = (y0 + rows + PAD).min(h); + let sh = y_end - y_start; + let mut strip = vec![0.0f32; w * sh]; + for (r, row) in strip.chunks_exact_mut(w).enumerate() { + fill_row(y_start + r, row); + } + let norm = craft_develop::sensor::Normalized { + width: w, + height: sh, + cpp: 1, + data: strip, + cfa: Some(craft_develop::sensor::Cfa { width: 2, height: 2, pattern: p.to_vec(), origin_x: 0, origin_y: y_start % 2 }), + }; + let dem = craft_develop::sensor::demosaic(&norm, method); + let top_pad = y0 - y_start; + let dem_f32: Vec = dem.data[top_pad * w..(top_pad + rows) * w].iter().flat_map(|px| *px).collect(); + encode_plain(&dem_f32, chunk); + }); + fused_out = Some(o); + } else if bayer && fused { // No padded plane either: every band normalizes its own rows. let p = cfa.phase(c.x, c.y); pattern = Some(names(&p));