Skip to content

Commit 0821307

Browse files
authored
Merge pull request #2600 from LikeLakers2/feature/filter3x3-enforce-array-size-at-compile
Enforce (at compile-time) that `imageops::filter3x3()` is provided an array of length 9
2 parents 22a5f78 + 9b22c77 commit 0821307

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/imageops/sample.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ where
876876
///
877877
/// This method typically assumes that the input is scene-linear light.
878878
/// If it is not, color distortion may occur.
879-
pub fn filter3x3<I, P, S>(image: &I, kernel: &[f32]) -> ImageBuffer<P, Vec<S>>
879+
pub fn filter3x3<I, P, S>(image: &I, kernel: &[f32; 9]) -> ImageBuffer<P, Vec<S>>
880880
where
881881
I: GenericImageView<Pixel = P>,
882882
P: Pixel<Subpixel = S> + 'static,

src/images/dynimage.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,15 +1027,13 @@ impl DynamicImage {
10271027
///
10281028
/// # Arguments
10291029
///
1030-
/// * `kernel` - slice contains filter. Only slice len is 9 length is accepted.
1030+
/// * `kernel` - array contains filter.
10311031
///
10321032
/// This method typically assumes that the input is scene-linear light. It operates on pixel
10331033
/// channel values directly without taking into account color space data. If it is not, color
10341034
/// distortion may occur.
10351035
#[must_use]
1036-
pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage {
1037-
assert_eq!(9, kernel.len(), "filter must be 3 x 3");
1038-
1036+
pub fn filter3x3(&self, kernel: &[f32; 9]) -> DynamicImage {
10391037
dynamic_map!(*self, ref p => imageops::filter3x3(p, kernel))
10401038
}
10411039

0 commit comments

Comments
 (0)