image
image copied to clipboard
Feature: methods for getting a pixel using signed coordinates
This PR adds two methods, each with default implementation to GenericImageView trait: checked_get_pixel and saturating_get_pixel. Both allow to get a pixel from an image view using signed coordinates. That can be convenient for different computer vision algorithms like object detection or tracking.
I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to choose either at their option.
This could be simplified using the max() and min() methods. For instance, x.max(0).min(width - 1) as u32
Also worth double checking that zero-sized images are either prohibited by GenericImage or properly handled by this patch
When designing image types (e.g. https://github.com/strasdat/Sophus/blob/23.04-beta/cpp/sophus/image/image_view.h#L125), I came to the same conclusion that signed integer pixel coordinates are beneficial. For instance, it is quite useful/common to ask whether a 3d point almost projects into a camera's field of view - hence talking about a pixel coordinate of e.g. (-5, -10) can indeed by meaningful.