-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add predictor for fp16 - add support for reading half (fp16) images - add a pure white test image (generated with gimp)
- Loading branch information
Micah Chambers (eos)
committed
Jan 28, 2025
1 parent
a19cf37
commit 77a22d6
Showing
6 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extern crate tiff; | ||
|
||
use tiff::decoder::{Decoder, DecodingResult}; | ||
use tiff::ColorType; | ||
|
||
use std::fs::File; | ||
use std::path::PathBuf; | ||
|
||
const TEST_IMAGE_DIR: &str = "./tests/images/"; | ||
|
||
#[test] | ||
fn test_ieee_fp16() { | ||
let filenames = ["white-fp16.tiff"]; | ||
|
||
for filename in filenames.iter() { | ||
let path = PathBuf::from(TEST_IMAGE_DIR).join(filename); | ||
let img_file = File::open(path).expect("Cannot find test image!"); | ||
let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); | ||
assert_eq!( | ||
decoder.dimensions().expect("Cannot get dimensions"), | ||
(256, 256) | ||
); | ||
assert_eq!( | ||
decoder.colortype().expect("Cannot get colortype"), | ||
ColorType::Gray(16) | ||
); | ||
if let DecodingResult::F16(img) = decoder.read_image().unwrap() { | ||
for p in img { | ||
assert!(p == half::f16::from_f32_const(1.0)); | ||
} | ||
} else { | ||
panic!("Wrong data type"); | ||
} | ||
} | ||
} |
Binary file not shown.