kabasset / Linx

Extensible ND image laboratory
Apache License 2.0
3 stars 0 forks source link

Add pixelwise operator to FilterMixin #19

Closed kabasset closed 8 months ago

kabasset commented 8 months ago

Sometimes, a filter has to be evaluated over few positions, such that operator* could be specialized for raster.patch(Position) or a new operator, e.g. (), could be introduced. No split is needed in this case.

Example, for flagging cosmics:

for (const auto& p : in.domain()) {
  mask[p] = (laplacian[p] > tl) && (quotient(in, p) > tq);
}
kabasset commented 8 months ago

Done as apply() for now, to be confirmed:

for (const auto& p : in.domain()) {
  mask[p] = (laplacian[p] > tl) && (quotient.apply(in, p) > tq);
}
kabasset commented 8 months ago

Now that patch() has been replaced with operator|, it would be nice to have a uniform syntax, e.g. filter.transform(in | p, out) and out = filter * (in | p). Yet, out would be a single value. Could also be an array, to allow for several pixelwise evaluations, e.g.:

auto out_box = filter * (in | box);
auto out_p = filter * (in | p);
auto out_pqr = filter * (in | {p, q, r});

Or maybe operator| is not the best choice, and operator() would be better for isolated transforms:

auto out_box = filter * in(box);
auto out_p = filter * in(p);
auto out_pqr = filter * in(p, q, r);

To be verified that Interpolation::operator() would not conflict anywhere.

It is also possible to go back to a named function, like pixels():

auto out_box = filter * (in | box);
auto out_p = filter * in.pixel(p);
auto out_pqr = filter * in.pixels(p, q, r);
kabasset commented 8 months ago

Feature implemented with operator() as the patch maker.

auto out_box = filter * in(box);
auto out_p = filter * in(p);
auto out_pqr = filter * in(p, q, r);