use crate::Real;
#[derive(Debug, Clone)]
pub struct ImageField {
pub data: Vec<Real>,
pub width: usize,
pub height: usize,
}
impl ImageField {
pub fn new(data: Vec<Real>, width: usize, height: usize) -> Self {
assert_eq!(
data.len(),
width * height,
"data length must equal width * height"
);
Self {
data,
width,
height,
}
}
pub fn zeros(width: usize, height: usize) -> Self {
Self {
data: vec![0.0; width * height],
width,
height,
}
}
#[inline]
pub fn get(&self, row: usize, col: usize) -> Real {
self.data[row * self.width + col]
}
#[inline]
pub fn get_mut(&mut self, row: usize, col: usize) -> &mut Real {
&mut self.data[row * self.width + col]
}
}