| Crates.io | inpaint |
| lib.rs | inpaint |
| version | 0.1.7 |
| created_at | 2025-10-25 21:44:18.529503+00 |
| updated_at | 2025-11-13 19:12:10.664075+00 |
| description | Easy to use library for inpainting images. |
| homepage | |
| repository | https://codeberg.org/gillesvink/inpaint |
| max_upload_size | |
| id | 1900692 |
| size | 7,855,757 |
Inpaint crate for image restoration and smooth interpolation of unknown values.
While inpainting is used for Images, this crate exposes its interface with ndarrays. Unlike OpenCV, any channel count and pixel type can be used.
For Rust, when you want to use it on images
cargo add inpaint --features image
Or in Python with uv
uv add inpaint
The Telea algorithm is ported from the Pyheal project, with some optimizations for Rust. With the Python bindings the same result can be achieved with this crate. In testing it is over 30x faster than Pyheal. The sample image takes 0.6 second in Pyheal, while in this crate it takes around 0.02 seconds on my machine.
Lets have this image of the toad I recently photographed. Unfortunately, some text has been burned into the image which I desperately want to remove:
| Damaged image | Mask |
|---|---|
![]() |
![]() |
Running this crate on the image returns this as the result:
| Result |
|---|
![]() |
You can call this code yourself at ./examples/python/ or ./examples/rust/.
cd examples/python && uv run main.py
cd examples/rust && cargo run --release
ndarray format.Image crate as optional feature. Just call .inpaint_telea() method on your image and have it inpainted. Make sure the image feature is enabled in your Cargo.tomlYou can also run the example in examples/simple. This will use the inpaint library and output the inpainted image as output.png.
[!IMPORTANT]
You need to have theimagefeature enabled.
use inpaint::prelude::*;
let mut image = image::open("./test/images/input/toad.png").unwrap().to_rgba32f();
let mask = image::open("./test/images/mask/text.png").unwrap().to_luma32f();
#[cfg(feature = "image")] // feature needs to be enabled for it to work
image.telea_inpaint(&mask, 3);
import inpaint
from PIL import Image
image = Image.open("./test/images/input/toad.png")
mask = Image.open("./test/images/mask/text.png")
output = inpaint.telea(image, mask, 3)
output.save("./output.png")
When not using the Image crate, just use the raw ndarrays.
use inpaint::telea_inpaint;
use ndarray::{Array2, Array3};
use glam::USizeVec2;
let resolution = USizeVec2::new(1920, 1080);
let channels = 4;
// obviously you need to use actual data, this is just an example
let mut input_image = Array3::from_elem((resolution.y, resolution.x, channels), 0.0);
let mask = Array2::from_elem((resolution.y, resolution.x), 0.0);
telea_inpaint(&mut input_image.view_mut(), &mask.view(), 1).unwrap();