mod algebra;
mod spatial;
mod temporal;
use crate::{EventStream, EventStreamBuilder};
impl EventStream {
pub(crate) fn remap(
&self,
width: usize,
height: usize,
f: impl Fn(i64, i64, i64, bool) -> Option<(i64, i64, i64, bool)>,
) -> EventStream {
let mut builder =
EventStreamBuilder::with_capacity(width, height, self.timestamp_scale_ms(), self.len());
let (xs, ys, ts, ps) = (self.xs(), self.ys(), self.ts(), self.ps());
for index in 0..self.len() {
let Some((x, y, t, p)) = f(
i64::from(xs[index]),
i64::from(ys[index]),
ts[index],
ps[index],
) else {
continue;
};
if (0..width as i64).contains(&x) && (0..height as i64).contains(&y) {
builder.push(x as u16, y as u16, t, p);
}
}
builder.build()
}
}