-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
346 additions
and
258 deletions.
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
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,30 @@ | ||
use kornia_rs::io::functions as F; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// read the image | ||
let image_path = std::path::Path::new("tests/data/dog.jpeg"); | ||
let image = F::read_image_jpeg(image_path)?; | ||
|
||
// cast the image to floating point | ||
let image_f32 = image.clone().cast::<f32>()?; | ||
|
||
// normalize the image between 0 and 255 | ||
let _image_f32_norm = kornia_rs::normalize::normalize_mean_std( | ||
&image_f32, | ||
&[127.5, 127.5, 127.5], | ||
&[127.5, 127.5, 127.5], | ||
)?; | ||
|
||
// alternative way to normalize the image between 0 and 255 | ||
let _image_f32_norm = image.clone().cast_and_scale::<f32>(1.0 / 255.0)?; | ||
// Or: image.cast_and_scale::<f64>(1.0 / 255.0)?; | ||
|
||
// alternative way to normalize the image between 0 and 1 | ||
let _image_f32_norm = image_f32.mul(1.0 / 255.0); | ||
// Or: let image_f32_norm = image_f32.div(255.0); | ||
|
||
let (min, max) = kornia_rs::normalize::find_min_max(&image_f32)?; | ||
println!("min: {:?}, max: {:?}", min, max); | ||
|
||
Ok(()) | ||
} |
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,29 @@ | ||
use kornia_rs::io::functions as F; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// read the image | ||
let image_path = std::path::Path::new("tests/data/dog.jpeg"); | ||
let image = F::read_image_jpeg(image_path)?; | ||
|
||
// cast the image to floating point | ||
let image_f32 = image.clone().cast_and_scale::<f32>(1.0 / 255.0)?; | ||
|
||
// convert to grayscale | ||
let gray_f32 = kornia_rs::color::gray_from_rgb(&image_f32)?; | ||
|
||
// normalize the image each channel | ||
let _image_norm = | ||
kornia_rs::normalize::normalize_mean_std(&image_f32, &[0.5, 0.5, 0.5], &[0.5, 0.5, 0.5])?; | ||
|
||
// normalize the grayscale image | ||
let _gray_norm = kornia_rs::normalize::normalize_mean_std(&gray_f32, &[0.5], &[0.5])?; | ||
|
||
// alternative way to normalize the image between 0 and 255 | ||
// let _gray_norm_min_max = kornia_rs::normalize::normalize_min_max( | ||
// &gray, 0.0, 255.0)?; | ||
|
||
let (min, max) = kornia_rs::normalize::find_min_max(&gray_f32)?; | ||
println!("min: {:?}, max: {:?}", min, max); | ||
|
||
Ok(()) | ||
} |
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
Oops, something went wrong.