kornia_image/
error.rs

1/// An error type for the image module.
2#[derive(thiserror::Error, Debug)]
3pub enum ImageError {
4    /// Error when the pixels type are not compatible.
5    #[error("Incompatible pixel types")]
6    IncompatiblePixelTypes,
7
8    /// Error when the image size is not initialized.
9    #[error("Image data is not initialized")]
10    ImageDataNotInitialized,
11
12    /// Error when the image data is not contiguous.
13    #[error("Image data is not contiguous")]
14    ImageDataNotContiguous,
15
16    /// Error when the image shape is not valid.
17    #[error(transparent)]
18    InvalidImageShape(#[from] kornia_tensor::TensorError),
19
20    /// Error when the image size is not valid.
21    #[error("Invalid image size ({0}, {1}) mismatch ({2}, {3})")]
22    InvalidImageSize(usize, usize, usize, usize),
23
24    /// Error when channel and shape are not valid.
25    #[error("Data length ({0}) does not match the image size ({1})")]
26    InvalidChannelShape(usize, usize),
27
28    /// Error when the cast operation fails.
29    #[error("Failed to cast image data")]
30    CastError,
31
32    /// Error when the channel index is out of bounds.
33    #[error("Channel index {0} is out of bounds {1}")]
34    ChannelIndexOutOfBounds(usize, usize),
35
36    /// Error when pixel index is out of bounds.
37    #[error("Pixel coordinate ({0}, {1}) is out of bounds ({2}, {3})")]
38    PixelIndexOutOfBounds(usize, usize, usize, usize),
39
40    /// Error when the number of bins is invalid.
41    #[error("Invalid number of bins {0}")]
42    InvalidHistogramBins(usize),
43
44    /// Error when the cannot compute the determinant.
45    #[error("Cannot compute the determinant: matrix is singular")]
46    CannotComputeDeterminant,
47
48    /// Error when the kernel length is invalid.
49    #[error("Invalid kernel length {0} and {1}")]
50    InvalidKernelLength(usize, usize),
51
52    /// Error when the sigma value is invalid.
53    #[error("Invalid sigma values {0} and {1}")]
54    InvalidSigmaValue(f32, f32),
55
56    /// Error when the channel count is unsupported.
57    #[error("Unsupported channel count {0}")]
58    UnsupportedChannelCount(usize),
59}