Skip to content

Commit

Permalink
Update palette to 0.7, bump crate to 0.2.0
Browse files Browse the repository at this point in the history
Update palette to 0.7.2
Update image to 0.24.6
Remove palette::Pixel, replace with palette::cast
Remove palette::FloatComponent, replace with num_traits::Float
Fix assorted trait bounds cascading from FloatComponent deletion
Fix doc tests
Fix clippy lints
Annotate loop with clippy::cast_precision_loss attribute in slic
  • Loading branch information
okaneco committed Jul 23, 2023
1 parent b486ab8 commit 8e6a259
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 109 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Improved SLIC calculation speed by ~15-20% after refactoring calculation loop.
## Version 0.1.0 - 2022-04
- Initial Commit

[documentation]: https://docs.rs/simple_clustering
[1]: https://github.com/okaneco/simple_clustering/pull/1
[3]: https://github.com/okaneco/simple_clustering/pull/3
[1]: https://github.com/okaneco/simple_clustering/pull/1
[documentation]: https://docs.rs/simple_clustering
125 changes: 67 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simple_clustering"
version = "0.1.1"
version = "0.2.0"
edition = "2021"
exclude = ["gfx", ".github"]
description = "Implementations of image clustering and segmentation algorithms such as SLIC and SNIC."
Expand Down Expand Up @@ -33,17 +33,18 @@ version = "0.2.1"
default-features = false

[dependencies.image]
version = "0.24.2"
version = "0.24.6"
default-features = false
features = ["jpeg", "png"]
optional = true

[dependencies.num-traits]
version = "0.2.15"
default-features = false
features = ["std"]

[dependencies.palette]
version = "0.6"
version = "0.7.2"
default-features = false
features = ["std"]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ can be found at https://github.com/okaneco/simple_clustering/releases.

```toml
[dependencies.simple_clustering]
version = "0.1"
version = "0.2"
default-features = false
```

Expand Down
8 changes: 4 additions & 4 deletions src/bin/simple_clustering/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::utils::{generate_filename, save_image, Algorithm};

use clap::Parser;

use palette::{FromColor, Lab, Pixel, Srgb};
use palette::{cast, FromColor, Lab, Srgb};
use simple_clustering::image::{count_colors, mean_colors, segment_contours};
use std::fmt::Write;
use std::str::FromStr;
Expand All @@ -29,7 +29,7 @@ fn try_main() -> Result<(), Box<dyn std::error::Error>> {

let input_image = image::open(opt.input)?.into_rgb8();
let (width, height) = input_image.dimensions();
let input_buffer = Srgb::from_raw_slice(input_image.as_raw());
let input_buffer = cast::from_component_slice::<Srgb<u8>>(input_image.as_raw());
let mut input_lab: Vec<Lab<_, f64>> = Vec::new();
input_lab.try_reserve_exact(input_buffer.len())?;
input_lab.extend(
Expand Down Expand Up @@ -78,9 +78,9 @@ fn try_main() -> Result<(), Box<dyn std::error::Error>> {
}
};

let segment_color = *Srgb::from_str(opt.segment_color.as_str())
let segment_color = Srgb::from_str(opt.segment_color.as_str())
.or(Err("Segment color is invalid hex"))?
.as_raw();
.into();

if !opt.no_mean {
let num_segments = mean_colors(
Expand Down
Loading

0 comments on commit 8e6a259

Please sign in to comment.