- Image Compression w/Discrete Cosine Transform (like JPEG)
- 20 Dec 2014 01:39:12 am
- Last edited by Unknownloner on 05 Jan 2015 02:27:01 am; edited 1 time in total
People have mentioned here and there that it'd be neat to display jpegs on the TI84+CSE. Honestly I think trying to support the whole jpeg format, or even a subset, is too much effort, so I've been looking into making my own image encoder and a decoder to go with it.
I've got an encoder and decoder working on computer. Right now I haven't really optimized it for decoding on calc yet, just working on getting it to work properly. It encodes images in the RGB color space, rather than the YCrCb (which is apparently optimal for this kind of thing, I might look into that later), and it stores 8-8-8 color values.
The encoder follows the basic process of jpeg:
Input data -> Discrete Cosine Transform -> Quantization -> RLE encoding -> Huffman encoding.
I'll post some more info, maybe an executable, once I've done some more work on it. I'm going to see if I can improve the quality to file size ratio tomorrow I think.
Here's a few pictures w/file sizes, all 320x240 pixels. Q goes from 0 to 100 and controls quality. Aside from the few sample images below, a full album with a few higher quality encodings (up to 100) can be found here as well http://imgur.com/a/B4zQA
EDIT:
Right now I'm using the exact same quantization tables as libjpeg. If anyone knows of some better tables / better scaling techniques for them, let me know
EDIT2: New code is now on GitHub
https://github.com/unknownloner/ImageCompress
Source
Q = 0, 11065 bytes
Q = 10, 24227 bytes
Q = 15, 30674 bytes
Q = 25, 40560 bytes
I've got an encoder and decoder working on computer. Right now I haven't really optimized it for decoding on calc yet, just working on getting it to work properly. It encodes images in the RGB color space, rather than the YCrCb (which is apparently optimal for this kind of thing, I might look into that later), and it stores 8-8-8 color values.
The encoder follows the basic process of jpeg:
Input data -> Discrete Cosine Transform -> Quantization -> RLE encoding -> Huffman encoding.
I'll post some more info, maybe an executable, once I've done some more work on it. I'm going to see if I can improve the quality to file size ratio tomorrow I think.
Here's a few pictures w/file sizes, all 320x240 pixels. Q goes from 0 to 100 and controls quality. Aside from the few sample images below, a full album with a few higher quality encodings (up to 100) can be found here as well http://imgur.com/a/B4zQA
EDIT:
Right now I'm using the exact same quantization tables as libjpeg. If anyone knows of some better tables / better scaling techniques for them, let me know

EDIT2: New code is now on GitHub
https://github.com/unknownloner/ImageCompress
Source

Q = 0, 11065 bytes

Q = 10, 24227 bytes

Q = 15, 30674 bytes

Q = 25, 40560 bytes
