Coder Social home page Coder Social logo

martinferianc / relax Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 404 KB

๐Ÿ’ค Relaxation labelling to refine edge detection ๐Ÿ’ค

License: MIT License

Python 100.00%
computer-vision relaxation-labelling edge-detection image-processing iterative-relaxation

relax's Introduction

relax: ๐Ÿ’ค relaxation Labelling to refine edge detection ๐Ÿ’ค.

This is an application of a niche algorithm named relaxation labeling to refine edge detection probabilities.

In the normal formulation relaxation is stated as a labelling problem. For an image we may wish to label each pixel as belonging to an edge, or being part of a region.

For example, we would normally have pixels as the objects, and the labels could be 'edge' or 'not edge'. Associated with each a_i is a set of measurements X_i, and also associated with each a_i is the contextual information of the other objects, which will depend on the current labels. Ideally, we would like to assign each object one label, but this will not in general be possible, and so we will have, for each object a set of probabilities of each label that logically sum to 1.

The contextual information is expressed by compatibility coefficients:

r([a_i:l_j], [a_k:l_l])

The value of r is a measure of how compatible it would be to label a_i with l_j and a_k with l_l. There will be one compatibility coefficient for each possible labelling of each pair of objects in the set.

It is an iterative process by defining compatibility coefficients and the region it is possible to refine the edge probabilities converted from intensities.

If you want to read more about it, here is a source better describing what is going on: Link

Building and Running

To install all the dependencies run:

pip install -r requirements.txt

Then you can just do e.g.:

python3 relax.py -d imgs/test.png -o test1.png -i 3 -c 2 0.5 0.5 2 -s 3 -v 1
-d Data input
-o Data output
-i Number of iterations
-c Compatibility matrix
-s Shape of the region matrix
-v Visualize the result

and voila!

Sharpening

Or a different compatibility matrix and a shape produces:

python3 relax.py -d imgs/test.png -o test2.png -i 3 -c 2 0.5 0.5 0.5 -s 5 -v 1

Pure edge detection

Credits

  • All code was written by Martin Ferianc in 2017.

relax's People

Contributors

martinferianc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wonlee2019

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.