Skip to content

Commit

Permalink
docs: update rbf doccomments and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ozwaldorf committed Sep 16, 2023
1 parent befdbd2 commit f717541
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ struct LutArgs {
/// provide a more colorful hald clut.
#[arg(long = "lum", default_value_t = 1.0)]
luminosity: f64,
/// Preserve the original luminosity values for the output colors for RBF based algorithms. The luminosity factor is
/// still used for distance computations.
/// Preserve the original luminosity values for the output colors for RBF based algorithms. The
/// luminosity factor is still used for distance computations.
#[arg(long, default_value_t = false)]
preserve: bool,
/// Number of nearest palette colors to consider at any given time for RBF based algorithms.
Expand Down
5 changes: 3 additions & 2 deletions src/interpolation/gaussian_sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use crate::GenerateLut;
/// Interpolated remapper using a gaussian distribution set to sample and mix colors.
/// Slow, compared to the RBF algorithms.
///
/// For N iterations, a variation of the pixel channels are computed using additive Gaussian noise (up to sample_count^3),
/// remapped to the nearest neighbor, and averaged together to get an interpolated color.
/// For N iterations, a variation of the pixel channels are computed using additive Gaussian noise
/// (up to sample_count^3), remapped to the nearest neighbor, and averaged together to get an
/// interpolated color.
pub struct GaussianSamplingRemapper<'a> {
iterations: usize,
seed: u64,
Expand Down
15 changes: 12 additions & 3 deletions src/interpolation/rbf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,29 @@ macro_rules! impl_rbf {
}

impl_rbf!(
"RBF remapper using a linear function on N nearest neighbors.",
"RBF remapper using a linear function on N nearest neighbors.
It's recommended to use a low number of neighbors for this method, otherwise the results will be extremely washed out.",
LinearRemapper<LinearFn>,
|_, d| d
);

impl_rbf!(
"Shepards Method, aka an RBF remapper using the inverse distance function on N nearest neighbors.",
"Shepards Method, aka an RBF remapper using the inverse distance function on N nearest neighbors.
Lower power values will result in a longer gradient between the colors, but with more washed out results.
Lowering the number of nearest colors can also mitigate washout, but may increase banding when using the LUT for corrections.",
ShepardRemapper<InverseDistanceFn>,
|s, d| { 1.0 / d.sqrt().powf(s.power) },
{ power: f64 }
);

impl_rbf!(
"RBF remapper using the Gaussian function on N nearest neighbors.",
"RBF remapper using the Gaussian function on N nearest neighbors.
Lower shape values will have more of a gradient between colors, but with more washed out results.
Higher shape values will keep the colors more true, but with less gradient between them.
Lowering the number of nearest neighbors can also mitigate washout, but may increase banding when using the LUT for corrections.",
GaussianRemapper<GaussianFn>,
|s, d| (-s.shape * d).exp(),
{ shape: f64 }
Expand Down

0 comments on commit f717541

Please sign in to comment.