image_dct

Crates.ioimage_dct
lib.rsimage_dct
version0.1.1
sourcesrc
created_at2023-05-04 03:13:46.010685
updated_at2023-05-04 03:33:50.507143
descriptionSimple Rust implementation for getting the DCT coefficients of an image
homepage
repositoryhttps://github.com/Ty1an/image_dct
max_upload_size
id856174
size34,544
Tylan Smith (Ty1an)

documentation

README

Image DCT

Simple Rust implementation for getting the DCT coefficients of an image.

Dependent on image, rustdct crates.

Install

cargo add image_dct

Usage

use image_dct::image_to_dct::ImageDct;

fn main() {
    // load image as a RGB ImageBuffer
    let img = image::open("image.png").unwrap().to_rgb8();

    // Create the ImageDct object from ImageBuffer
    let mut image_dct = ImageDct::new(img);

    // Compute the DCT of the image then compute the inverse DCT on the coefficients
    image_dct.compute_dct();
    image_dct.compute_idct();

    // Reconstruct it back into an RGB ImageBuffer
    let reconstructed_image = image_dct.reconstructe_image();

    // Save the reconstructed image into a PNG
    image::save_buffer(
        "./output.png",
        &reconstructed_image,
        image_dct.width() as u32,
        image_dct.height(),
        image::ColorType::Rgb8,
    )
    .unwrap();
}
Commit count: 8

cargo fmt