TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

What is it?


Ever wanted to convert a picture into an spreadheet?  Pictures are made up of pixels, millions of tiny dots that when combined create an imagine.  This program takes each pixel and identifies it's colour, then loads the spreadsheet program and plots out each pixel as a coloured cell.  All the combined cells create the original image as a cool spreadsheet version. 

1. Getting Started 


This project uses Raspberry Pi 2 and the latest version of Raspbian, (21.5.2015) Python 2.79 was used, although it will work on previous and future versions.  Firstly update your Raspberry Pi:  

In the LX Terminal type:
sudo apt-get update
sudo apt-get upgrade

Next up install the software:
sudo install –-upgrade pip
sudo pip install -U pip
pip install Pillow
pip install xlwt


Next you will need a spreadsheet program to create the coloured cells.  Libre office comes with a suitable spreadsheet package that can be used to for this purpose and can be easily installed, type: sudo apt-get install libreoffice-calc  Once installed you are now ready to download the conversion program.


2. Covert Pixels to Cells


Now all the modules are installed the next stage is to download the Image to Spreadsheet software, PNG to XLS.  Click the link below and download the file, save it to the pi/home folder.  You can run the program from any folder as long as this program png2xls.py and the PNG image to covert are in the same folder.

Return back to the LX Terminal and type, 
sudo python png2xls.py libre name_of_image.png 

where name_of_image.png is the name of the picture that you are going to convert, for example, sudo python png2xls.py libre Raspberry_Pi.png.  Once the program has finished it will have created a spreadsheet of the PNG image.
img2xls.py
File Size: 4 kb
File Type: py
Download File

Example
File Size: 514 kb
File Type: xls
Download File

You can use WinSCP or a similar program to transfer the spreadheet from the Pi to your computer,it is an open source free SFTP client and FTP client for Windows the main function is the secure file transfer between local and remote computer. 

Raspberry Pi to Excel



3. Live Conversion


A good extension to the hack is to add a USB Webcam, take a picture of yourself and then have the code convert it into your own self spreadsheet portrait.  This uses the PyGame camera module to assess the web camera and save the photo.  This already installed on the Raspberry Pi and can controlled with the code below.

import pygame.camera
pygame.camera.init()
cam = pygame.camera.Camera(pygame.camera.list_cameras()[0])
cam.start()
img = cam.get_image()
import pygame.image
pygame.image.save(img, "photo.png")
pygame.camera.quit()


Download the code below and run the program from the LX Terminal typing:
sudo python camera2xls.py libre photo.png  Note that the image file is called photo.png and is the default name that the image file is saved as.
camera2xls.py
File Size: 5 kb
File Type: py
Download File

Webcam Pic to Spreadsheet
File Size: 724 kb
File Type: xls
Download File

Copyright 2021 TeCoEd @dan_aldred