imgal 0.3.0

A fast and open-source scientific image processing and algorithm library.
Documentation
use ndarray::ArrayViewMut2;

use crate::prelude::*;

/// Apply a grid over a 2D image.
///
/// # Description
///
/// Applies an adjustable regular grid on an input 2D image.
///
/// # Arguments
///
/// * `data`: The input 2D image.
/// * `spacing`: The distance in pixels between grid lines.
#[inline]
pub fn grid_2d_mut<T>(data: &mut ArrayViewMut2<T>, spacing: usize)
where
    T: AsNumeric,
{
    data.indexed_iter_mut().for_each(|((r, c), v)| {
        if r % spacing == 0 || c % spacing == 0 {
            *v = T::MAX;
        }
    });
}