Code Monkey home page Code Monkey logo

img2rag's Introduction

img2rag

Convert any image into its Region Adjacency Graph which can be used for either image segmentation or to create a graph embedding of the image. scheme


Installation

Simply run pip install img2rag

What is does

Given an image, we segement it into perceptually significant regions using first Felzenszwalb segmentation followed by a threshold-cut. We then use the segmented regions to construct the following graph:

  1. Each node corresponds to a segmented region.
  2. We connect two regions if they are adjacent.

This is the so-called region adjacency graph. Furthermore, we add the following node-attributes to each region:

  1. Location of the region centeriod
  2. Orientation of the region
  3. Mean and total color of the region
  4. Size in px

The edges contain the mean-color difference between the two regions

How to use

Simply import the RAGimage class and initiate with any image. Then use the build in methods to access various properties.

from img2rag import RAGimage

# We assume the image is given as a numpy array or tf.Tensor with either 2 or 3 dimensions
# where the third dimension is the optional channel dimension.
img_tensor = [...]

# initiate RAGimage instance
image_rag = RAGimage(img_tensor)

# RAG as a networkx attributed DiGraph
image_rag.rag

# Scikit style labels of the image segementation
image_rag.labels

# Adjacency matric of the RAG
image_rag.adjacency

# Graph feature matrix of the RAG
# (Nodes x Node-Features)
image_rag.signal

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.