Git Product home page Git Product logo

cellcompression's Introduction

CellCompression

Demo

Image / video compression technique using 1bpp 4x4 cells, see https://en.wikipedia.org/wiki/Color_Cell_Compression

Compresses any 4x4 pixel block in 20 bits, with an additional 128 colour table per image

Quality is video-gamish at best... but that's to be expected. At least it can be decoded on minimal hardware, and is seriously compact!

Proposed block format:

  • 6 bits: the tile
  • 7 bits: the foreground colour for the tile
  • 7 bits: the background colour for the tile

Proposed palette format:

  • 124 colours: the colours for the image
  • 4 colours: reserved for the UI and stuff

The tiles:

Tilemap

The current implementation of the encoder does take into account surrounding pixels around the block for cleaner results, hence the 6x6 tiles in the input.

Inside the blockmap, black pixels get mapped to colour 1, white pixels to colour 2, and grey pixels are ignored during generation of the tile

How to use

Requirements

  • python and pygame for generate_tiler.py and demo.py
  • C compiler for the encoder

To compile the encoder

  • first generate the tiler.c file using generate_tiler.py
  • then compile main.c using your favourite compiler

To run

  • convert your image to P6 PPM
  • run the encoder on your image

To see the result

  • convert the resulting out.pnm to a format supported by pygame (e.g. PNG)
  • run demo.py, then check the resulting demo.png

Inspiration

This technique was partially inspired by the way the ZX spectrum encodes it's colour on it's 8x8 blocks, and by classic video game tile mapping.

cellcompression's People

Contributors

carolinehusky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.