{"id":13937193,"url":"https://github.com/ankitaggarwal011/PyCNN","last_synced_at":"2025-07-19T23:31:06.272Z","repository":{"id":24215140,"uuid":"27607035","full_name":"ankitaggarwal011/PyCNN","owner":"ankitaggarwal011","description":"Image Processing with Cellular Neural Networks in Python","archived":false,"fork":false,"pushed_at":"2018-11-01T23:14:38.000Z","size":499,"stargazers_count":536,"open_issues_count":5,"forks_count":86,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-11-27T05:32:26.814Z","etag":null,"topics":["cellular","cnn","cnn-processors","computer-science","computer-vision","control","corner-detection","cross-platform","edge-detection","feedback","image-processing","library","neural-network","paper","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankitaggarwal011.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-05T19:38:52.000Z","updated_at":"2024-09-21T12:30:38.000Z","dependencies_parsed_at":"2022-08-07T11:00:57.236Z","dependency_job_id":null,"html_url":"https://github.com/ankitaggarwal011/PyCNN","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ankitaggarwal011/PyCNN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitaggarwal011%2FPyCNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitaggarwal011%2FPyCNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitaggarwal011%2FPyCNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitaggarwal011%2FPyCNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankitaggarwal011","download_url":"https://codeload.github.com/ankitaggarwal011/PyCNN/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitaggarwal011%2FPyCNN/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266041688,"owners_count":23867944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cellular","cnn","cnn-processors","computer-science","computer-vision","control","corner-detection","cross-platform","edge-detection","feedback","image-processing","library","neural-network","paper","python"],"created_at":"2024-08-07T23:03:22.342Z","updated_at":"2025-07-19T23:31:05.989Z","avatar_url":"https://github.com/ankitaggarwal011.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# PyCNN: Image Processing with Cellular Neural Networks in Python\n\n[![Build Status](https://travis-ci.org/ankitaggarwal011/PyCNN.svg?branch=master)](https://travis-ci.org/ankitaggarwal011/PyCNN)\n[![Coverage Status](https://codecov.io/gh/ankitaggarwal011/PyCNN/coverage.svg?branch=master)](https://codecov.io/gh/ankitaggarwal011/PyCNN)\n\n**Cellular Neural Networks (CNN)** [[wikipedia]](https://en.wikipedia.org/wiki/Cellular_neural_network) [[paper]](http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=7600) 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](https://en.wikipedia.org/wiki/Cellular_neural_network#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 (\u003e10,000 frame/s) processing unachievable by digital processors.\n\nThis python library is the implementation of CNN for the application of **Image Processing**.\n\n**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](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=7168488), look for the reference #19 in the references section. I'm glad that this library could be of help to the community.\n\n**Note**: Cellular neural network (CNN) must not be confused with completely different convolutional neural network (ConvNet).\n\n![alt text](images/blockdiagram.png \"CNN Architecture\")\n\nAs shown in the above diagram, imagine a control system with a feedback loop. f(x) is the piece-wise linear sigmoid function. The control (template B) and the feedback (template A) 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](http://cnn-technology.itk.ppke.hu/Template_library_v4.0alpha1.pdf).\n\n### Further reading:\n- [Methods for image processing and pattern formation in Cellular Neural Networks: A Tutorial](http://ai.pku.edu.cn/aiwebsite/research.files/collected%20papers%20-%20others/Methods%20for%20image%20processing%20and%20pattern%20formation%20in%20Cellular%20Neural%20Networks%20-%20a%20tutorial.pdf)\n\n## Motivation\n\nThis 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](http://blog.ankitaggarwal.me/technology/image-processing-with-cellular-neural-networks-in-python-on-raspberry-pi).\nThe library was used in my paper [B3: A plug-n-play internet enabled platform for real time image processing](http://ieeexplore.ieee.org/document/6888614/) published in IEEE Xplore.\n\n## Dependencies\n\nThe library is supported for Python \u003e= 2.7 and Python \u003e= 3.3.\n\nThe python modules needed in order to use this library.\n```\nPillow: 3.3.1\nScipy: 0.18.0\nNumpy: 1.11.1 + mkl\n```\nNote: Scipy and Numpy can be installed on a Windows machines using binaries provided over [here](http://www.lfd.uci.edu/%7Egohlke/pythonlibs).\n\n## Example 1\n\n```sh\n$ python example.py\n```\n\n#### OR\n\n```python\nfrom pycnn import PyCNN\n\ncnn = PyCNN()\n```\n\n**Input:**\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/input1.bmp)\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/input3.bmp)\n\n**Edge Detection:**\n\n```python\ncnn.edgeDetection('images/input1.bmp', 'images/output1.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output1.png)\n\n**Grayscale Edge Detection**\n\n```python\ncnn.grayScaleEdgeDetection('images/input1.bmp', 'images/output2.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output2.png)\n\n**Corner Detection:**\n\n```python\ncnn.cornerDetection('images/input1.bmp', 'images/output3.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output3.png)\n\n**Diagonal line Detection:**\n\n```python\ncnn.diagonalLineDetection('images/input1.bmp', 'images/output4.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output4.png)\n\n**Inversion (Logic NOT):**\n\n```python\ncnn.inversion('images/input1.bmp', 'images/output5.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output5.png)\n\n**Optimal Edge Detection:**\n\n```python\ncnn.optimalEdgeDetection('images/input3.bmp', 'images/output6.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/output6.png)\n\n## Example 2\n\n```sh\n$ python example_lenna.py\n```\n\n#### OR\n\n```python\nfrom pycnn import PyCNN\n\ncnn = PyCNN()\n```\n\n**Input:**\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/lenna.gif)\n\n**Edge Detection:**\n\n```python\ncnn.edgeDetection('images/lenna.gif', 'images/lenna_edge.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/lenna_edge.png)\n\n**Diagonal line Detection:**\n\n```python\ncnn.diagonalLineDetection('images/lenna.gif', 'images/lenna_diagonal.png')\n```\n\n![](https://raw.githubusercontent.com/ankitaggarwal011/PyCNN/master/images/lenna_diagonal.png)\n\n## Usage\n\nImport module\n\n```python\nfrom pycnn import PyCNN\n```\n\nInitialize object\n\n```python\ncnn = PyCNN()\n\n# object variables: \n# m: width of the image (number of columns)\n# n: height of image (number of rows)\n```\n\n```python\n# name: name of image processing method (say, Edge detection); type: string\n# inputImageLocation: location of the input image; type: string.\n# outputImageLocation: location of the output image; type: string.\n# tempA_A: feedback template; type: n x n list, e.g. 3 x 3, 5 x 5.\n# tempB_B: control template; type: n x n list, e.g. 3 x 3, 5 x 5.\n# initialCondition: initial condition, type: float.\n# Ib_b: bias, type: float.\n# t: time points for integration, type: ndarray. \n  # Note: Some image processing methods might need more time point samples than default.\n  #       Display the output with each time point to see the evolution until the final convergence \n  #       to the output, looks pretty cool.\n```\n\nGeneral image processing\n\n```python\ncnn.generalTemplates(name, inputImageLocation, outputImageLocation, tempA_A, tempB_B, \n                      initialCondition, Ib_b, t)\n```\n\nEdge detection\n\n```python\ncnn.edgeDetection(inputImageLocation, outputImageLocation)\n```\n\nGrayscale edge detection\n\n```python\ncnn.grayScaleEdgeDetection(inputImageLocation, outputImageLocation)\n```\n\nCorner detection\n\n```python\ncnn.cornerDetection(inputImageLocation, outputImageLocation)\n```\n\nDiagonal line detection\n\n```python\ncnn.diagonalLineDetection(inputImageLocation, outputImageLocation)\n```\n\nInversion (Login NOT)\n\n```python\ncnn.inversion(inputImageLocation, outputImageLocation)\n```\n\nOptimal Edge Detection\n\n```python\ncnn.optimalEdgeDetection(inputImageLocation, outputImageLocation)\n```\n\n## License\n\n[MIT License](https://github.com/ankitaggarwal011/PyCNN/blob/master/LICENSE)\n\n## Contribute\n\nWant to work on the project? Any kind of contribution is welcome!\n\nFollow these steps:\n- Fork the project.\n- Create a new branch.\n- Make your changes and write tests when practical.\n- Commit your changes to the new branch.\n- Send a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankitaggarwal011%2FPyCNN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankitaggarwal011%2FPyCNN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankitaggarwal011%2FPyCNN/lists"}