pub struct Crop { /* private fields */ }Expand description
Extract a rectangular window of an image.
Crop is a coordinate remap, not a copy: it shifts the origin of the region its input is asked for, so under the M2 scheduler no pixel outside the window is ever decoded or computed. Cropping the corner off a huge image costs the corner, not the image.
Implementations§
Source§impl Crop
impl Crop
Sourcepub fn new(window: Region) -> Result<Crop, PixelsError>
pub fn new(window: Region) -> Result<Crop, PixelsError>
Crop to window, in input image coordinates.
The window is validated against the actual input when the op is chained onto an image, not here, since the input shape is not yet known.
§Errors
Returns PixelsError::InvalidArgument if the window is empty.
Trait Implementations§
impl Copy for Crop
impl Eq for Crop
Source§impl Op for Crop
impl Op for Crop
Source§fn rescaled(&self) -> Option<Arc<dyn Op>>
fn rescaled(&self) -> Option<Arc<dyn Op>>
Never rescaled, and the most important of the exclusions: a crop
window is given in input pixels. crop(1000, 1000, 100, 100) against a
source decoded eight times smaller would return a different part of the
picture — correctly shaped, and the wrong content.
Source§fn output_descriptor(
&self,
inputs: &[ImageDescriptor],
) -> Result<ImageDescriptor, PixelsError>
fn output_descriptor( &self, inputs: &[ImageDescriptor], ) -> Result<ImageDescriptor, PixelsError>
Source§fn input_regions(
&self,
output: Region,
_: &[ImageDescriptor],
) -> Result<Vec<Region>, PixelsError>
fn input_regions( &self, output: Region, _: &[ImageDescriptor], ) -> Result<Vec<Region>, PixelsError>
output. Read more