Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

k-max Distance

The k-max distance for images and graphs. The repository contains the source code of the k-max distance and also three samples how to use it.


  • c++ std11
  • opencv


    cmake .
The distance computed in images using Image structure
The distance computed in images using C arrays
The distance computed in graphs using Graph structure

In all the examples, the function compute is used for the k-max distance computing.
This function requires the Image structure (main.cpp), Graph structure (main3.cpp), or arrays with the edge costs in x and y directions (main2.cpp). In addition, the array of source nodes, the number of source nodes, and the destination point (if a negative value is used, the distance is computed to all the image nodes and the distance to the destination node is returned) are required. The function returns the distance to the destination point. Optionally, the distance transform (the negative value of destination point is required), the shortest path, and the maximum vector that gives the distance can be returned from the function.


Michael Holuša, Eduard Sojka, The k-max distance in graphs and images, In Pattern Recognition Letters, Volume 98, 2017, Pages 103-109, ISSN 0167-8655, (


title = {The k-max distance in graphs and images},
author = {Michael Holuša and Eduard Sojka},
journal = {Pattern Recognition Letters},
volume = {98},
pages = {103 - 109},
year = {2017},
issn = {0167-8655},
doi = {},
url = {},
keywords = "Distance measuring, Shortest path, -max distance, Geodesic distance, Image processing, Image segmentation",