Skip to content

Commit

Permalink
Refactor, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jun 20, 2024
1 parent fc3ca2f commit 0f7382e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ let resized = scaler.resize_rgba(

### Performance

Faster or comparable to `fast-image-resize`, when implemented equal SIMD and pixel type.

Example comparison time for downscale RGB 4928x3279 image in two times for x86_64 SSE.
Example comparison with `fast-image-resize` time for downscale RGB 4928x3279 image in two times for x86_64 SSE.

| | Lanczos3 |
|-----------|:--------:|
Expand Down
22 changes: 11 additions & 11 deletions app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ fn main() {
// false,
// );

let mut f_store: Vec<f32> = bytes.iter().map(|&x| x as f32 * (1f32 / 255f32)).collect();

// let mut f_store: Vec<f32> = bytes.iter().map(|&x| x as f32 * (1f32 / 255f32)).collect();
//
let start_time = Instant::now();

let store = ImageStore::<f32, 3>::from_slice(
&mut f_store,
let store = ImageStore::<u8, 3>::from_slice(
&mut bytes,
dimensions.0 as usize,
dimensions.1 as usize,
);
let resized = scaler.resize_rgb_f32(
let resized = scaler.resize_rgb(
ImageSize::new(dimensions.0 as usize / 2, dimensions.1 as usize / 2),
store,
);
Expand All @@ -50,12 +50,12 @@ fn main() {
// Print the elapsed time in milliseconds
println!("Scaler: {:.2?}", elapsed_time);

let j_store: Vec<u8> = resized
.as_bytes()
.iter()
.map(|&x| (x * 255f32) as u8)
.collect();
let dst = j_store;
// let j_store: Vec<u8> = resized
// .as_bytes()
// .iter()
// .map(|&x| (x * 255f32) as u8)
// .collect();
let dst = resized.as_bytes();

if resized.channels == 4 {
image::save_buffer(
Expand Down

0 comments on commit 0f7382e

Please sign in to comment.