Skip to content

The segraph library creates graphs from SLIC superpixels. It can be used for using CRF for image segmentation https://pypi.python.org/pypi/segraph/0.5

License

Notifications You must be signed in to change notification settings

alivcor/segraph

Repository files navigation

DOI License: GPL v3 Open Source Love dependencies Status Build Status

The segraph library provides modules for creating graphs from SLIC segments. This can be used with PyStruct library for image segmentation using CRF.

:octocat: Link to GitHub Repo

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See examples to see a quick example.

Prerequisites

You will need to have NumPY installed on your system. The segraph library was built with Python 2.7, keeping in mind the stability with Python 3+, but it is not guranteed.

pip install numpy

Installation

There are multiple ways to install segraph on your system:

Python Package Index

segraph is now available at https://pypi.python.org/pypi/segraph/0.5

1. Download the tar/zip from https://pypi.python.org/pypi/segraph/0.5
2. Move the package to your desired location / python version, and unzip the archive. 
Optionally, if you have a linux-based machine (Ubuntu/OSX):
      tar xvzf segraph-0.x.tar.gz -C /path/to/desireddirectory
3. Migrate to the segraph folder, and run
      python setup.py install

Using pip

pip install segraph

To upgrade,

pip install --upgrade segraph

Using segraph

segraph can be very helpful for creating graphs from SLIC segmented images (superpixels). Here is an example usage:

from skimage.segmentation import slic
from skimage.util import img_as_float
from skimage import io as skimageIO
from segraph import create_graph
import numpy as np

image = img_as_float(skimageIO.imread("segraph/data/flowers.png"))
segments = slic(image, n_segments=500, sigma=1.0)
# Create graph of superpixels 
vertices, edges = create_graph(segments)

# Compute centers:
gridx, gridy = np.mgrid[:segments.shape[0], :segments.shape[1]]
centers = dict()
for v in vertices:
    centers[v] = [gridy[segments == v].mean(), gridx[segments == v].mean()]

segraph can be used with PyStruct library for image segmentation using CRF.

Contributing

You are welcome to send a pull-request.

Contributors

Thanks to all the contributors for making it even more awesome !

  • @pinkfloyd06

Authors

License

This project is licensed under the GNU General Public License v3 - see the LICENSE.md file for details

forthebadge

Buy Me A Coffee

About

The segraph library creates graphs from SLIC superpixels. It can be used for using CRF for image segmentation https://pypi.python.org/pypi/segraph/0.5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages