Skip to content

This python script turns images into an array consisting of bytes where each bit determines whether an OLED pixel for instance is turned on or off. A greyscale threshold value is passed as terminal parameter.

License

Notifications You must be signed in to change notification settings

postfixNotation/ImageToArrayHeader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Script: Convert an Image to an Array of Bytes

Objective

This script has been written to display an arbitrary image on an OLED display I've programmed a library for: Arduino OLED Library. Therefore you need the image data being reduced to pixel ON/OFF values.

Usage

A C-Header file is created containing a uint8_t array called "image". Each byte basically contains information about whether a pixel of a page is set or not. Be aware that an image has to be scaled to 128x64 (upright) pixels to be used with the above mentioned OLED display. At first the script transforms the image into greyscale values. Afterwards these values need to be reduced to simple ON/OFF (1/0) values. Therefore an RGB threshold is passed as terminal parameter. Also see image.h.example to understand how a result file looks like (".example" has just been added for this repository). After cropped and scaled the image below has been used for this example.


alt text

Exemplary Script Usage

./image_to_header.py china.png 128

OLED Application

alt text

About

This python script turns images into an array consisting of bytes where each bit determines whether an OLED pixel for instance is turned on or off. A greyscale threshold value is passed as terminal parameter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages