Converts images into corresponding Region Adjacency Graphs
Project description
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.
Installation
Simply run pip install img2rag
What is does
Given an image, we segement it into morphological regions using first Felzenszwalb segmentation followed by a threshold-cut. We then use the segmeneted regions to construct the following graph:
- Each node corresponds to a segmented region.
- 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:
- Location of the region centeriod
- Orientation of the region
- Mean and total color of the region
- 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 RAGiamge 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file img2rag-1.0.0.tar.gz
.
File metadata
- Download URL: img2rag-1.0.0.tar.gz
- Upload date:
- Size: 250.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d4c35e899e081af00a1266be53f1a80e176b4273c2edb97235d76855fe8a89c |
|
MD5 | 5c7352d3fa8256f0f3d1b7e273cda010 |
|
BLAKE2b-256 | 6d250f0ff41256b567cdbf7da387f9b82f63854abc245eef132536486fe226e7 |