Code Monkey home page Code Monkey logo

leafsnake's Introduction

Leafsnake

Leafsnake is a leaf and thallus morphometry program written in Python.

Authors: Fredrik Jansson (fjansson at abo dot fi), Pirom Konglerd, Catherine Reeb

Installation

Ubuntu and Debian-like Linux distributions

sudo apt-get install git python3-numpy python3-scipy python3-matplotlib python3-pip python3-networkx \
libjpeg-dev libpng-dev libpng12-dev libtiff4-dev libwebp-dev xcftools 

sudo pip3 install mahotas imread scikit-image

Arch Linux

sudo pacman -S python-pip python-numpy python-scipy python-matplotlib python-networkx
sudo pip install mahotas imread scikit-image

Usage and Measurements

Leafsnake operates on images of leaves or other branched structures, and is used to extract features from the structure.

The image is skeletonized using the Zhang-Suen skeletonization method, as implemented in scikit image

From the skeleton, a graph is constructed. The graph has vertices at the branching points of the skeleton. Since the image skeleonization method is not perfect, some spurious branches may appear. Also, if different branches overlap, the generated skeleton can contain loops. The loops and the spurious branches can be removed manually, by deleting nodes or vertices from the graph.

Each edge and node is in the graph assigned an index according to the Strahler hierarchy: terminal branches ("tips") are assigned number 1. The parent branch of two branches of level n is assigned level n+1. The parent of branches of different level is assigned the same level as the child branch of the highest level.

For the edges and nodes in the graph, the following measurements are collected.

Node

  • level - distance in the graph to the nearest leaf. A leaf has level 1.
  • Strahler - Strahler order.
  • dia - diameter

Edge

  • level - distance in the graph to the nearest leaf. A leaf has level 1.
  • Strahler - Strahler order.
  • branchlength - length of the branch along the skeleton
  • branchlength_e - Euclidian (straight-line) distance between the end points
  • alpha - angle from parent branch, measured at the node's disk
  • alpha_e - angle from parent branch, measured using the straight graph edges
  • W_mean - mean width of the branch
  • W_max - max width of the branch
  • W_min - min width of the branch
  • W_std - standard deviation of the width of the branch

Image resolution data base

In order to report measurement results in physical units, the program needs to know the resolution of the input image. The resolution, in pixels per mm, and optionally other properties, are stored in a JSON file, leaves.json, in the same directory as the leafsnake script.

"imagename": {
    "px_mm": 430.0
},

When the program is run on a leaf image, it stores the location of the root node in the same data base. This lets the program remember the selected root for each image beteen runs of the program.

Keyboard commands

  • 'd' - delete node closest to pointer
  • 'x' - delete edge closest to pointer
  • 'u' - undo last action
  • 'r' - rebuild the graph - restoring all manually deleted nodes and edges
  • click a node to select it as the root

leafsnake's People

Contributors

fjansson avatar

Watchers

James Cloos avatar Diego Patino avatar

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.