SLIC – simple lossless imaging codec
Copyright (c) 2022 BitBank Software, Inc.
Written by Larry Bank
What is it?
An ’embedded-friendly’ (aka Arduino) image compression format/codec that supports most common pixel types, is fast to compress, fast to decompress and easily adds useful compression to many projects that would otherwise be unable to use popular formats like JPEG/PNG/TIFF/WebP/etc
What isn’t it?
A perfect image codec that solves every problem and fills every need. As the name implies, it’s a simple yet effective format that opens a few new doors.
Why did you write it?
I think there is a need to fill a gap in the current image compression standards – a fast+simple lossless codec that can run well on resource constrained (e.g. embedded) systems. Written in C99, it doesn’t require a file system nor the C-runtime library to function, so it’s perfectly suited to run on small microcontrollers with limited memory. It also directly supports RGB565 pixels, which seems to be pretty rare in the image file format world. It’s extremely fast (of course) and has a good worst-case behavior. The compression scheme uses run-length, palette/cache and difference coding. It works well on many types of images, except for photos with many unique colors. I specifically tailored the compression to work best on screenshots, charts, and ‘computerish’ images.
Why does it look so similar to QOI?
I started working with the QOI format and it gave me some good ideas as a starting point, but the stated goals and limitations of the format were preventing me from supporting that project.
What’s special about it?
As with all of my recent projects, my aim is to make it fast, simple and easy to integrate. What’s special is that it works so effectively on a wide range of images, doesn’t require much RAM nor a file system and has a simple API accessible as C or C++. It’s extremely easy to integrate into any project and doesn’t take up much code space nor RAM.
– Runs on any CPU/MCU with at least 1K of free RAM
– No external dependencies (including malloc/free)
– Allows memory to memory encode and decode
– Can work with files through callback functions you provide
– Extremely fast yet extremely effective at compressing many types of images
– Encode and decode an image by as few or as many pixels at a time as you like
– Supported Pixel types: 8-bit grayscale, 8-bit palette, 24/32-bit truecolor, and RGB565
– Arduino-style C++ library class with simple API
– Can by built as a straight C project as well
Q0: Does it run on the Arduino Uno?
A0: Yes! You can both encode and decode images on the Uno. 8-bit Palette images are more difficult because you need a 768-byte palette.
Q1: How does it perform compared to PNG and GIF?
A1: It’s faster than both, but usually underperforms both in terms of compression. SLIC can sometimes compress better than PNG for 24 or 32-bpp images.
Q2: What type of images does SLIC compress well?
A2: SLIC does well with smooth gradients and areas of common colors.
Q3: What type of images does SLIC compress poorly?
A3: Images with shot noise or lots of unique colors (e.g. photos of people/places) don’t compress well.
Q4: What’s the easiest way to start using SLIC images in my project?
A4: Peruse the Wiki for info about the API, create some “.slc” files with the command line tool in the linux directory and start your code from one of the examples.
Q5: How can I easily create SLIC-compressed images from existing image files?
A5: The command line tool in the linux directory should build correctly on MacOS+Windows as well. Use it to convert Windows BMP files into .slc files.