pub trait ImageOps {
// Required methods
fn apply_conv2d(
&self,
kernel: &[f32],
kw: usize,
kh: usize,
border: BorderMode,
) -> Result<ImageBuf, ImageError>;
fn blur(&self, sigma: f32) -> Result<ImageBuf, ImageError>;
fn sobel_gradients(&self) -> Result<(ImageBuf, ImageBuf), ImageError>;
fn canny_edges(
&self,
sigma: f32,
low: f32,
high: f32,
) -> Result<ImageBuf, ImageError>;
fn apply_dilate(
&self,
se: &[f32],
sw: usize,
sh: usize,
) -> Result<ImageBuf, ImageError>;
fn apply_erode(
&self,
se: &[f32],
sw: usize,
sh: usize,
) -> Result<ImageBuf, ImageError>;
fn apply_resize(
&self,
new_w: usize,
new_h: usize,
interp: Interpolation,
) -> Result<ImageBuf, ImageError>;
fn to_gray(&self) -> Result<ImageBuf, ImageError>;
fn to_hsv(&self) -> Result<ImageBuf, ImageError>;
fn compute_histogram(&self, bins: usize) -> Result<Vec<u32>, ImageError>;
fn label_components(&self) -> Result<(Vec<u32>, u32), ImageError>;
}Expand description
Image operations trait for ImageBuf method dispatch.
Provides a unified interface for applying image processing operations
to structured ImageBuf instances with automatic dimension handling.
Required Methods§
Sourcefn apply_conv2d(
&self,
kernel: &[f32],
kw: usize,
kh: usize,
border: BorderMode,
) -> Result<ImageBuf, ImageError>
fn apply_conv2d( &self, kernel: &[f32], kw: usize, kh: usize, border: BorderMode, ) -> Result<ImageBuf, ImageError>
Apply 2D convolution with given kernel and border mode.
Sourcefn blur(&self, sigma: f32) -> Result<ImageBuf, ImageError>
fn blur(&self, sigma: f32) -> Result<ImageBuf, ImageError>
Apply Gaussian blur with given sigma.
Sourcefn sobel_gradients(&self) -> Result<(ImageBuf, ImageBuf), ImageError>
fn sobel_gradients(&self) -> Result<(ImageBuf, ImageBuf), ImageError>
Compute Sobel gradients (gx, gy).
Sourcefn canny_edges(
&self,
sigma: f32,
low: f32,
high: f32,
) -> Result<ImageBuf, ImageError>
fn canny_edges( &self, sigma: f32, low: f32, high: f32, ) -> Result<ImageBuf, ImageError>
Apply Canny edge detection (converts multi-channel to grayscale).
Sourcefn apply_dilate(
&self,
se: &[f32],
sw: usize,
sh: usize,
) -> Result<ImageBuf, ImageError>
fn apply_dilate( &self, se: &[f32], sw: usize, sh: usize, ) -> Result<ImageBuf, ImageError>
Morphological dilation with structuring element.
Sourcefn apply_erode(
&self,
se: &[f32],
sw: usize,
sh: usize,
) -> Result<ImageBuf, ImageError>
fn apply_erode( &self, se: &[f32], sw: usize, sh: usize, ) -> Result<ImageBuf, ImageError>
Morphological erosion with structuring element.
Sourcefn apply_resize(
&self,
new_w: usize,
new_h: usize,
interp: Interpolation,
) -> Result<ImageBuf, ImageError>
fn apply_resize( &self, new_w: usize, new_h: usize, interp: Interpolation, ) -> Result<ImageBuf, ImageError>
Resize image to new dimensions.
Sourcefn to_gray(&self) -> Result<ImageBuf, ImageError>
fn to_gray(&self) -> Result<ImageBuf, ImageError>
Convert to grayscale.
Sourcefn to_hsv(&self) -> Result<ImageBuf, ImageError>
fn to_hsv(&self) -> Result<ImageBuf, ImageError>
Convert RGB to HSV color space.
Sourcefn compute_histogram(&self, bins: usize) -> Result<Vec<u32>, ImageError>
fn compute_histogram(&self, bins: usize) -> Result<Vec<u32>, ImageError>
Compute histogram with given number of bins.
Sourcefn label_components(&self) -> Result<(Vec<u32>, u32), ImageError>
fn label_components(&self) -> Result<(Vec<u32>, u32), ImageError>
Label connected components in binary image.