The last time Hackerfall tried to access this page, it returned a not found error. A cached version of the page is below, or clickhereto continue anyway

PyCNN

PyCNN: Image Processing with Cellular Neural Networks in Python

Cellular Neural Networks (CNN) [wikipedia] [paper] are a parallel computing paradigm that was first proposed in 1988. Cellular neural networks are similar to neural networks, with the difference that communication is allowed only between neighboring units. Image Processing is one of its applications. CNN processors were designed to perform image processing; specifically, the original application of CNN processors was to perform real-time ultra-high frame-rate (>10,000 frame/s) processing unachievable by digital processors.

This python library is the implementation of CNN for the application of Image Processing.

Note: The library has been cited in the research published on Using Python and Julia for Efficient Implementation of Natural Computing and Complexity Related Algorithms, look for the reference #19 in the references section. Im glad that this library could be of help to the community.

Note: Cellular neural network (CNN) must not be confused with completely different Convolutional neural network (ConvNet).

As shown in the above diagram, imagine a control system with a feedback loop. f(x) is the sigmoidal kernel function for this system. The control and the feedback templates (coefficients) are configurable and controls the output of the system. Significant research had been done in determining the templates for common image processing techniques, these templates are published in this Template Library.

Motivation

This is an extension of a demo at 14th Cellular Nanoscale Networks and Applications (CNNA) Conference 2014. I have written a blog post, available at Image Processing in CNN with Python on Raspberry Pi.

Dependencies

The library is supported for Python >= 2.7 and Python >= 3.3.

The python modules needed in order to use this library.

Pillow: 3.3.1
Scipy: 0.18.0
Numpy: 1.11.1 + mkl

Note: Scipy and Numpy can be installed on a Windows machines using binaries provided over here.

Example 1

$ python example.py

OR

from pycnn import pycnn

cnn = pycnn()

Input:

Edge Detection:

cnn.edgedetection('images/input1.bmp', 'images/output1.png')

Grayscale Edge Detection

cnn.grayscaleedgedetection('images/input1.bmp', 'images/output2.png')

Corner Detection:

cnn.cornerdetection('images/input1.bmp', 'images/output3.png')

Diagonal line Detection:

cnn.diagonallinedetection('images/input1.bmp', 'images/output4.png')

Inversion (Logic NOT):

cnn.inversion('images/input1.bmp', 'images/output5.png')

Example 2

$ python example_lenna.py

OR

from pycnn import pycnn

cnn = pycnn()

Input:

Edge Detection:

cnn.edgedetection('images/lenna.gif', 'images/lenna_edge.png')

Diagonal line Detection:

cnn.diagonallinedetection('images/lenna.gif', 'images/lenna_diagonal.png')

Usage

Import module

from pycnn import pycnn

Initialize object

cnn = pycnn()
# inputimagelocation: location of the input image; type: String.
# outputimagelocation: location of the output image; type: String.
# tempA_A: control template; type: 3 x 3 list.
# tempB_B: feedback template; type: 3 x 3 list.
# initialcondition: initial condition, type: float.
# Ib_b: bias, type: float.

General image processing

cnn.generaltemplates(inputimagelocation, outputimagelocation, tempA_A, tempB_B, initialcondition, Ib_b)

Edge detection

cnn.edgedetection(inputimagelocation, outputimagelocation)

Grayscale edge detection

cnn.grayscaleedgedetection(inputimagelocation, outputimagelocation)

Corner detection

cnn.cornerdetection(inputimagelocation, outputimagelocation)

Diagonal line detection

cnn.diagonallinedetection(inputimagelocation, outputimagelocation)

Inversion (Login NOT)

cnn.inversion(inputimagelocation, outputimagelocation)

License

MIT License

Contribute

Want to work on the project? Any kind of contribution is welcome!

Follow these steps:

PyCNN is maintained by ankitaggarwal011.

Continue reading on blog.ankitaggarwal.me