-
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
16 changed files
with
442 additions
and
399 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,37 @@ | ||
use kornia_rs::io::functions as F; | ||
use rerun; | ||
|
||
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)?; | ||
|
||
// convert the image to grayscale | ||
let gray = kornia_rs::color::gray_from_rgb(&image)?; | ||
let gray_viz = gray.clone(); | ||
|
||
// binarize the image | ||
let gray_bin = kornia_rs::threshold::threshold_binary(&gray, 127, 255)?; | ||
|
||
// Option1: convert the grayscale image to floating point | ||
let gray_f32 = gray.cast::<f32>()?; | ||
|
||
// Option 2: onvert and normalize the grayscale image to floating point | ||
// let gray_f32 = gray.cast_and_scale::<f32>(1.0 / 255, 0.0)?; | ||
|
||
// normalize the image between 0 and 1 | ||
let gray_f32 = kornia_rs::normalize::normalize_mean_std(&gray_f32, &[0.0], &[255.0])?; | ||
|
||
// binarize the image as floating point | ||
let gray_f32 = kornia_rs::threshold::threshold_binary(&gray_f32, 0.5, 1.0)?; | ||
|
||
// create a Rerun recording stream | ||
let rec = rerun::RecordingStreamBuilder::new("Kornia App").connect()?; | ||
|
||
let _ = rec.log("image", &rerun::Image::try_from(image.data())?); | ||
let _ = rec.log("gray", &rerun::Image::try_from(gray_viz.data())?); | ||
let _ = rec.log("gray_bin", &rerun::Image::try_from(gray_bin.data())?); | ||
let _ = rec.log("gray_f32", &rerun::Image::try_from(gray_f32.data())?); | ||
|
||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.