Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantsz committed May 22, 2024
1 parent 07bec21 commit 3217c5e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/contrast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,23 @@ mod tests {
}
}

#[test]
fn test_adaptive_thesholding_with_delta() {
let mut image = GrayImage::from_pixel(3, 3, Luma([100u8]));
image.put_pixel(2, 2, Luma::black());

//big delta should make the theshold for the black pixel small enough to be white
let binary = adaptive_threshold_with_delta(&image, 1, 100);
let expected = GrayImage::from_pixel(3, 3, Luma::white());
assert_pixels_eq!(binary, expected);

//smaller delta should make the theshold the pixel to be black
let binary = adaptive_threshold_with_delta(&image, 1, 50);
let mut expected = GrayImage::from_pixel(3, 3, Luma::white());
expected.put_pixel(2, 2, Luma::black());
assert_pixels_eq!(binary, expected);
}

#[test]
fn test_histogram_lut_source_and_target_equal() {
let mut histc = [0u32; 256];
Expand Down

0 comments on commit 3217c5e

Please sign in to comment.