Git Product home page Git Product logo

textonsseg's Introduction

TextonsSeg

Repo for PyPi package

Textons - Texture Based Image Segmentation

Textons using LM filters

The code here is an implementation of textons using LM filters.

The image is mapped into a 48 dimensions vector space using the features obtained from the LM filters along with the features obtained it also takes into account the RGB values of the pixels

Three more features are added to the end of each vector. These features are row, col and centroids allocated for each pixel, the resulting vector is of the size (1 X 54)

K-Means using Eculidean distance is used to segment image.

inputs:

  1. image ==> numpy array
  2. number of cluster centers ==> integer
  3. number of iterations ==> integers
  4. type of colors assignment in the final image ==> integer 0 for 'RANDOM' or 1 for'DEFINED'

output:

  • numpy array of image after k means wiht LM filters

Assignment type 'RANDOM' is suited more for higher number of clusters, assignment type 'DEFINED' is better suited when number of clusters is less than 15, however the assignemnt types do not impact the performance of the code in any significant way

Executing the script

Install the TextonsSeg module from PyPi

pip install TextonsSeg==0.0.2

After the install is complete. You can call the module in your python file as shown below:

from TextonsSeg import Textons
import cv2
img = cv2.imread('path to image')
tex = Textons(img, number of centroids, number of iterations, assignment mode)
img = tex.textons()
cv2.imshow('window name', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Example

from TextonsSeg import Textons
import cv2
im = cv2.imread('image.jpg')
tex = Textons(im, 3, 25, 1)
img = tex.textons()
cv2.imshow('check', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
  • Advisable to keep number of iterations high (recommended >= 100) for reproducibility of result

Improved Reproducibility of Result

  • Added feature to make the results reproducible

Result with 10 iterations and K value as 3

original image segmented image

To-Do

  • Add feature to stop k means on the basis of accuracy
  • Add minkowski and mahalanobis distance as distance measure

textonsseg's People

Contributors

abhishekkrishna123 avatar batspock avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

textonsseg's Issues

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.