GithubHelp home page GithubHelp logo

hhy5277 / pycnn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ankitaggarwal011/pycnn

0.0 2.0 0.0 175 KB

Image Processing with Cellular Neural Networks in Python

Home Page: http://blog.ankitaggarwal.me/PyCNN/

License: MIT License

Python 100.00%

pycnn's Introduction

PyCNN: Cellular Neural Networks Image Processing Python Library

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. I'm 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).

alt text

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 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.

Usage

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')

OR

Use example.py available with the repository.

$ python example.py

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

API

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.

Contributors

Author: Ankit Aggarwal

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

License

MIT License

pycnn's People

Contributors

ankitaggarwal011 avatar johnallen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.