#color-palette #color-space #image #palette #statistical #different #another

palette-transfer

Statistical copy palette from one image to another

6 releases

0.2.0 Oct 13, 2024
0.1.4 Oct 9, 2024
0.1.2 Aug 4, 2024

#914 in Images

Download history 36/week @ 2024-09-13 12/week @ 2024-09-20 6/week @ 2024-09-27 301/week @ 2024-10-04 229/week @ 2024-10-11 18/week @ 2024-10-18 32/week @ 2024-11-29 166/week @ 2024-12-06

198 downloads per month

BSD-3-Clause OR Apache-2.0

1MB
736 lines

Copy palette of one image to another

Copies palette from source image to destination using different color spaces and statistics approach.

Example

let source = ImageReader::open("./assets/dwl.jpeg")
        .unwrap()
        .decode()
        .unwrap();
let source_dimensions = source.dimensions();
let destination = ImageReader::open("./assets/twl.jpeg")
    .unwrap()
    .decode()
    .unwrap();
let destination = destination.to_rgb8();
let destination_dimension = destination.dimensions();
let src = source.as_bytes();
let target = destination.as_bytes();
let mut dst = Vec::from(target);
copy_palette_rgb(
    src,
    source_dimensions.0,
    source_dimensions.1,
    & mut dst,
    destination_dimension.0,
    destination_dimension.1,
    1.,
    TransferColorspace::OKLAB,
)
.unwrap();

image::save_buffer(
    "converted_oklab.jpg",
    & dst,
    destination_dimension.0,
    destination_dimension.1,
    image::ExtendedColorType::Rgb8,
)
.unwrap();

Results example

Dependencies

~3MB
~64K SLoC