Skip to content

Convert your image data to a Poisson spike source.

Notifications You must be signed in to change notification settings

mervess/images-to-spikes

 
 

Repository files navigation

Convert Images to Poissonian Spikes

Convert your image data to a Poisson spike source to be able to use with Spiking Neural Networks.

Pumpkins-RGB Pumpkins-GrayScale Pumpkins-SpikesPlot
The parameters below are used when running convert_image_to_spike_array.py in order to turn pumpkins above into a spike array.
max_freq = 60000 (Hz)
on_duration = 10000 (ms)
off_duration = 5000 (ms)

Requirements

I use Python 3.5.2 on Linux, necessary packages are listed below along with their versions for reference.

  • matplotlib (3.0.3)
  • numpy (1.17.3)
  • opencv-python (4.1.1.26)

Run pip install -r requirements.txt to install them all.

Project Files and Their Usage

images-to-spikes/
├── convert_image_to_spike_array.py
├── draw_image.py
├── images
│   ├── cross.png
│   ├── horizontal_line_10x.png
│   ├── horizontal_lines.png
│   └── t10k-images-idx3-ubyte__idx_000__lbl_7_.png
├── poisson_tools.py
└── util_functions.py

convert_image_to_spike_array.py is the main file.

  • Please see its usage by running it: python convert_image_to_spike_array.py
  • The program will store the output spike array as a pickle under pickles/ folder in the same directory after the run.
  • If you do not want a pickle at the end, change the parameter inside the file, i.e. save_as_pickle=False.
  • You may use a single image file (extension could be anything OpenCV accepts) or a folder which contains multiple images (extensions need to be .png) as input.

draw_image.py enables you to draw your own images by adding simple shapes into it via OpenCV. For more information please see the file.

images folder contains three of the images that I generated by using draw_image.py, and one example from MNIST dataset (t10k-images-idx3-ubyte__idx_000__lbl_7_.png).

poisson_tools.py is where the Poisson distribution modelling takes place.

util_functions.py includes utility functions of files and images.

References and Citation

I only used the Poissonian spikes approach to obtain spike arrays from images in this project. The original project also contains Focal Rank Code Order approach in this sense.

Please refer to the original project's Wiki page for further information.

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%