Giter Site home page Giter Site logo

permfl / dictlearn Goto Github PK

View Code? Open in Web Editor NEW
33.0 4.0 11.0 2.1 MB

Dictionary Learning for image processing

Home Page: http://dictlearn.readthedocs.io/

Python 90.21% C 9.79%
sparse-coding dictionary-learning machine-learning image-processing signal-processing segmentation denoising inpainting

dictlearn's Introduction

Build Status Documentation Status

Supported Python Versions

Supported python versions are: 2.7, 3.5 and 3.6. It should also work with python 3.7, however that is not tested

Install Linux

$ pip install -r requirements.txt
$ python setup.py install

Install Mac

This package depends in libomp which is not installed by default. If you see the following error, libomp has to be installed.

$ python setup.py install
Installing dictlearn...
running develop
running egg_info
writing dictlearn.egg-info/PKG-INFO
writing dependency_links to dictlearn.egg-info/dependency_links.txt
writing requirements to dictlearn.egg-info/requires.txt
writing top-level names to dictlearn.egg-info/top_level.txt
reading manifest file 'dictlearn.egg-info/SOURCES.txt'
writing manifest file 'dictlearn.egg-info/SOURCES.txt'
running build_ext
building 'dictlearn._dictlearn._dictlearn' extension
.
.
.
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1

Install libomp with homebrew:

$ brew install libomp

and run python setup.py install again.

Install Windows

Using anaconda: $ conda install --file requirements.txt

Building the cython extensions are probably easier using anaconda.

If cython build crashes, install Visual Studio Build Tools. For python 3 you need:

http://landinghub.visualstudio.com/visual-cpp-build-tools

and for python 2

https://www.microsoft.com/en-us/download/details.aspx?id=44266

VTK and ITK

If you need to read/write VTK files you have to install VTK. Everything that requires VTK or ITK are located in dictlearn/vtk.py and scripts/. The rest of the code can run without having VTK or ITK installed.

Denoise (Gray scale images only)

Simple denoising using 20 training iterations with 8x8 image patches.

import matplotlib.pyplot as plt
import dictlearn as dl

denoise = dl.Denoise('noisy_image.png')
denoised_image = denoise.train().denoise()
plt.imshow(denoised_image)
plt.show()

Inpainting

import matplotlib.pyplot as plt
import dictlearn as dl

inpainter = dl.Inpaint('image.png', 'mask.png')
inpainted_image = inpainter.train().inpaint()

plt.subplot(121)
plt.imshow(inpainter.patches.image)
plt.title('Original')

plt.subplot(122)
plt.imshow(inpainted_image)
plt.title('Inpainted')

plt.show()

Tests

Run tests with

$ pytest tests

from root directory

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.