Skip to content

Commit 5c6f9cb

Browse files
committed
Add basic scale test
JUst checks the image dimensions
1 parent 18c43f6 commit 5c6f9cb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/transform/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ pub trait TransformExt
1818
where
1919
Self: Sized,
2020
{
21+
/// Output type for the operation
2122
type Output;
2223

24+
/// Transforms an image given the transformation matrix and output size.
25+
/// Assume nearest-neighbour interpolation
2326
fn transform(
2427
&self,
2528
transform: ArrayView2<f64>,
@@ -200,4 +203,14 @@ mod tests {
200203

201204
assert_eq!(upside_down_sideways, src_sideways);
202205
}
206+
207+
#[test]
208+
fn scale() {
209+
let src = Image::<u8, Gray>::from_shape_data(4, 4, (0..16).collect());
210+
let trans = affine::scale(0.5, 2.0);
211+
let res = src.transform(trans.view(), None).unwrap();
212+
213+
assert_eq!(res.rows(), 8);
214+
assert_eq!(res.cols(), 2);
215+
}
203216
}

0 commit comments

Comments
 (0)