Git Product home page Git Product logo

fmm's Introduction

Fast marching method

  • To use in a project, include fmm.hpp and use fmm::fmm<image_data_type>(image, seeds, weight_map_type[, image_segmentation_threshold]) This is a single-file header-only library without any dependencies. The CMakeLists.txt is only for building the sample program (which I encourage you to try).

  • If you are using OpenCV and only need support for OpenCV Mat's, there is the (almost) drop-in replacement fmmcv.hpp which should be faster since it uses some of OpenCV's built-in functions. This, and the sample program, depend on OpenCV.

  • fmm.hpp Includes a bare-bones Image struct which allows you to use any row-major contiguous matrix type: Image<field_type>(rows, cols, data_ptr) or create a image managing its own memory: Image<field_type>(rows, cols). The functions are also templated to support any Image, Point data types, and is by default compatible with OpenCV Mat/Point as well. To support a custom image type, you will have to specialize the __create_like template function which should create a new uninitialized image of the same type and size as the input.

Samples

Computing distances/segmenting grayscale image (OpenCV sample image: fruit) Grayscale image segmentation (from OpenCV demo image)

Computing distances/segmenting depth image (picture of me captured by Azure Kinect) Depth image segmentation (picture of me)

Function documentation

Comment on top of fmm.hpp copied here:

/** Fast marching method implementation
 *  usage: fmm::fmm(image, seeds, weight_map_type = IDENTITY,
 *                  segmentation_threshold = disabled,
 *                  normalize_output_geodesic_distances = true,
 *                  output = nullptr)
 *  > returns an image, either geodesic distance map or, if
 *    segmentation_threshold is given, a segmentation mask
 *  image: input image (can be OpenCV Mat or fmm::Image<T>)
 *  seeds: std::vector of points (each can be OpenCV Point or fmm::Point)
 *  weight_map_type: transformation to apply to input image to use as FMM
*                    weight function. Can be one of:
 *                    fmm::weight::IDENTITY  no transformation (avoids a copy, faster)
 *                    fmm::weight::GRADIENT  recommended: image gradient magnitude (using Sobel gradients) 
 *                    fmm::weight::ABSDIFF   absolute difference from average
 *                                           grayscale value of seeds
 *                    fmm::weight::LAPLACIAN absolute value of image Laplacian
 *  segmentation_threshold: if specified, sets pixels with geodesic value less
 *                          than or equal to this threshold to 1 and others to 0
 *                          in the output image. If not given,the geodesic
 *                          distances map will be returned.
 *  normalize_output_geodesic_distances: if true, normalizes geodesic distances
 *                                       values to be in the interval [0, 1].
 *                                       If segmentation_threshold is specified,
 *                                       this occurs prior to segmentation.
 *                                       Default true.
 *  max_visits: maximum number of points to visit. Can help speed up the computation
 *              if objects larger than a certain area are eliminated (e.g. background)
 *  output: optionally, a pointer to an already-allocated output image.
 *          This allows you to avoid a copy if you already have one
 *          allocated. By default a new image is created, and this
 *          is not necessary. Note: for fmmcv.hpp, this should just be
 *          a cv::Mat instead of a pointer.
 *
 *  fmm::Image<T> usage (optional)
 *  - To make owning image fmm::Image<T>(rows, cols)
 *  - To make non-owning image that maps to row-major data (of same type, or char/uchar):
 *    fmm::Image<T>(rows, cols, data_ptr)
 * */

License

Apache 2.0

fmm's People

Contributors

sxyu avatar

Watchers

James Cloos 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.