diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..56335f1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +## [v0.2.0](https://github.com/lily-mosquitoes/image-recovery/compare/v0.1.0...v0.2.0) (2023-08-07) + +### ⚠ BREAKING CHANGE + +* new api for library use + + +### Features + +* implemented new imagearray struct with associated traits as main library +object, changes denoise solver to use the new struct and operations +([4c11776](https://github.com/lily-mosquitoes/image-recovery/commit/4c117762cdd187f581f1f9da2d0100cefb083327)) +* **image_array:** implement ImageArray as concrete type over trait +DifferentiableArray +([db8462e](https://github.com/lily-mosquitoes/image-recovery/commit/db8462e3b25a0ee30be152658fd84b714ae29caa)) +* **differentiable_array:** create new trait DifferentiableArray and implement +for Array generically +([46775c8](https://github.com/lily-mosquitoes/image-recovery/commit/46775c8a836273110e0807826b7a2f78744dfe7f)) +* add log crate; make print statement a debug log +([2071911](https://github.com/lily-mosquitoes/image-recovery/commit/2071911328cfc10c01b88cab7330a5935cefcb4c)) + +## v0.1.0 (2022-04-18) diff --git a/Cargo.toml b/Cargo.toml index 21cbdd8..70eba21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "image-recovery" -version = "0.1.1" +version = "0.2.10" edition = "2021" authors = ["Lílian Ferreira de Freitas ", "Emilia L. K. Blåsten "] description = "Image recovery algorithms, implemented in Rust." diff --git a/README.md b/README.md index 36b7215..c71cd0f 100644 --- a/README.md +++ b/README.md @@ -18,31 +18,30 @@ Declare the dependency in you Cargo.toml ```toml [dependencies] -image-recovery = "0.1" +image-recovery = "0.2" ``` ## Examples: -Examples for each solver can be found in the [`examples` folder](https://github.com/lily-mosquitoes/image-recovery/tree/main/examples), and those can be run with `cargo run --example example_name`. However, a quick example usage is shown below: +Only the `denoise` solver is currently implemented. The examples for it can be found in the [`examples` folder](https://github.com/lily-mosquitoes/image-recovery/tree/main/examples), and can be run with `cargo run --example denoise`. Furthermore, a quick example usage is shown below: ### Image denoising (multichannel) ```rust use image_recovery::{ image, // re-exported `image` crate - img::Manipulation, // trait for image::RgbImage manipulation - solvers, // module with image recovery algorithms + ImageArray, // struct for holding images }; fn main() { // the `image` crate provides functionality to decode images let img = image::open("examples/source_images/angry_birb_noisy.png") .expect("image could not be open") - .into_rgb8(); // the algorithms in this library are implemented for RGB images + .into_rgb8(); // the algorithms in this library are implemented for the Luma and Rgb types // load the RGB image into an object which is composed // of 3 matrices, one for each channel - let img_matrices = img.to_matrices(); + let img_array = ImageArray::from(&img); // choose inputs for the denoising solver: // according to Chambolle, A. and Pock, T. (2011), @@ -68,6 +67,7 @@ fn main() { // choose bounds for denoising solver // the algorithm will run for at most `max_iter` iterations let max_iter: u32 = 500; + // the algorithm will stop running if: // `convergence_threshold < norm(current - previous) / norm(previous)` // where `current` is the output candidate for the current iteration, @@ -75,13 +75,15 @@ fn main() { let convergence_threshold = 10_f64.powi(-10); // now we can call the denoising solver with the chosen variables - let denoised = solvers::denoise_multichannel(&img_matrices, lambda, tau, sigma, gamma, max_iter, convergence_threshold); + let denoised_array = image_array + .denoise(lambda, tau, sigma, gamma, max_iter, convergence_threshold) + .unwrap(); // will fail if image is 1 pixel in either x or y // we convert the solution into an RGB image format - let new_img = image::RgbImage::from_matrices(&denoised); + let denoised_img = denoised_array.into_rgb(); // encode it and save it to a file - new_img.save("examples/result_images/angry_birb_denoised_multichannel.png") + new_img.save("examples/result_images/angry_birb_denoised.png") .expect("image could not be saved"); } ``` @@ -90,7 +92,7 @@ This should provide the following result: Source image: | Output image: ---|--- -![source image, noisy](examples/source_images/angry_birb_noisy.png) | ![output image, denoised](examples/result_images/angry_birb_denoised_multichannel.png) +![source image, noisy](examples/source_images/angry_birb_noisy.png) | ![output image, denoised](examples/result_images/angry_birb_denoised.png) ## Testing @@ -106,7 +108,7 @@ Benchmarking can be run with `cargo bench`. Image recovery algorithms to implement: -- [x] Denoising (single and multichannel variants) +- [x] Denoising - [ ] Zooming - [ ] Deblurring - [ ] Dequantization @@ -115,7 +117,7 @@ Image recovery algorithms to implement: ## Copyright -This code is licensed under the GNU Affero General Public License version 3 or later. See [LICENSE](https://github.com/lily-mosquitoes/image-recovery/blob/main/LICENSE) or https://www.gnu.org/licenses/agpl-3.0.en.html. +This code is licensed under the GNU Affero General Public License version 3 or later. See [LICENSE](https://github.com/lily-mosquitoes/image-recovery/blob/main/LICENSE) or [gnu.org/licenses/agpl-3.0.en.html](https://gnu.org/licenses/agpl-3.0.en.html). ## Acknowledgements