PyCNN: Cellular Neural Networks Image Processing Python Library

Datetime:2016-08-22 22:26:26          Topic: Python  Neural Networks           Share

PyCNN: Cellular Neural Networks Image Processing Python Library

Cellular Neural Networks (CNN)are a parallel computing paradigm similar to neural networks, with the difference that communication is allowed between neighboring units only. 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. I'm glad that this library could be of help to the community.


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 .


The python (2.7.6) modules are needed in order to use this library.

PIL (Image): 1.1.7
Scipy: 0.14.1rc1
Numpy: 1.8.1

Note: The module versions mentioned are tested and expected to work. The library might work on later versions, but that hasn't been tested. If you have information regarding this, please consider adding the same here. Thanks.


Image Processing using CNN is simple using this library, just clone the repository and use the following code.

from cnnimg import cnnimg

cnn = cnnimg()

cnn.edgedetection('input.bmp', 'output1.png')
cnn.grayscaleedgedetection('input.bmp', 'output2.png')
cnn.cornerdetection('input.bmp', 'output3.png')
cnn.diagonallinedetection('input.bmp', 'output4.png')
cnn.inversion('input.bmp', 'output5.png')
cnn.generaltemplates('input.bmp', 'output6.png')


Use available with the repository.

$ python

Example results

Input: input.bmp

Edge Detection:

Output: output1.png

Corner Detection:

Output: output3.png

Diagonal line Detection:

Output: output4.png

Inversion (Logic NOT):

Output: output5.png

Another example (Lenna)

Here, the input is the popular face in image processing field, Lenna.

Input: lenna.gif

Edge Detection:

Output: lenna_edge.png

Diagonal line Detection:

Output: lenna_diagonal.png


from cnnimg import cnnimg

Import the module in your main file.

cnn = cnnimg()

Initialize the cnn class

cnn.edgedetection(inputimagelocation, outputimagelocation)

Function for edge detection using CNN on a given image.

cnn.grayscaleedgedetection(inputimagelocation, outputimagelocation)

Function for grayscale edge detection using CNN on a given image.

cnn.cornerdetection(inputimagelocation, outputimagelocation)

Function for corner detection using CNN on a given image.

cnn.diagonallinedetection(inputimagelocation, outputimagelocation)

Function for diagonal line detection using CNN on a given image.

cnn.inversion(inputimagelocation, outputimagelocation)

Function for invert an image using CNN.

cnn.generaltemplates(inputimagelocation, outputimagelocation)

Function for applying general CNN templates on a given image.

inputimagelocation is the location of the input image, Type: String.

outputimagelocation is the location of the output image, Type: String.


Author: Ankit Aggarwal

If anybody is interested in working on developing this library, fork and feel free to get in touch with me.


MIT License

About List