Skip to content

Commit

Permalink
Histogram example update (kornia#98)
Browse files Browse the repository at this point in the history
* update histogram example and rerun to 0.17.0

* update readme

* add image
  • Loading branch information
edgarriba authored Jul 16, 2024
1 parent 0a48437 commit 06f929b
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use the library to perform image I/O, visualisation and other low level operatio

## Getting Started

`cargo run --example hello_world`
`cargo run --bin hello_world`

```rust
use kornia::image::Image;
Expand All @@ -21,9 +21,9 @@ use kornia::io::functional 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: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

println!("Hello, world!");
println!("Hello, world! 🦀");
println!("Loaded Image size: {:?}", image.size());
println!("\nGoodbyte!");

Expand Down Expand Up @@ -113,7 +113,7 @@ use kornia::io::functional 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: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;
let image_viz = image.clone();

let image_f32: Image<f32, 3> = image.cast_and_scale::<f32>(1.0 / 255.0)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/binarize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ publish = false
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/color_detector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ publish = false
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/histogram/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ publish = false
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
10 changes: 7 additions & 3 deletions examples/histogram/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Image histogram

## Usage

Example showing to compute the histogram of an image using the Kornia Rust image processing library.

```bash
Expand All @@ -8,12 +12,12 @@ Options:
-h, --help Print help
```

Example:
## Example

```bash
cargo run -p histogram -- --image-path path/to/image.jpg
```

Output:
## Output

TODO: add image output
![green_black_histogram](https://github.com/user-attachments/assets/010a15db-3721-4217-bbca-79711011ebb5)
6 changes: 3 additions & 3 deletions examples/histogram/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image: Image<u8, 3> = F::read_image_any(&args.image_path)?;

// create a Rerun recording stream
let rec = rerun::RecordingStreamBuilder::new("Kornia App").spawn()?;

// compute the histogram per channel
let histogram = image
.split_channels()?
.iter()
.map(|ch| imgproc::histogram::compute_histogram(ch, 256))
.collect::<Result<Vec<_>, _>>()?;

// create a Rerun recording stream
let rec = rerun::RecordingStreamBuilder::new("Kornia Histogram App").spawn()?;

// log the image and the histogram
rec.set_time_sequence("step", 0);
rec.log("image", &rerun::Image::try_from(image.clone().data)?)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/imgproc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ version.workspace = true
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ version.workspace = true
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/normalize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ publish = false
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/normalize_ii/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ publish = false
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/rerun_viz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ version.workspace = true
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/rotate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ version.workspace = true
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/undistort_image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ version.workspace = true
[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
kornia.workspace = true
rerun = "0.16.0"
rerun = "0.17.0"
2 changes: 1 addition & 1 deletion examples/webcam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ publish = false
clap = { version = "4.5.4", features = ["derive"] }
ctrlc = "3.4.4"
kornia = { workspace = true, features = ["gstreamer"] }
rerun = "0.16.0"
rerun = "0.17.0"
tokio = { version = "1" }

0 comments on commit 06f929b

Please sign in to comment.