Skip to main content

Distance Map library

Project description

DistanceMap

Python Distance Map library

For a N-dimension (2 ≤ N ≤ 3) binary matrix, return the corresponding distance map. For each pixel, the value is equal to the minimum distance to a "positive" pixel. Due to the way I plan to use this library, the implementation is in reality articulate over a list of positive points positions and not a binary matrix.

Δ = distance to nearest positive point
α = a user defined function (ℝ+ → ℝ+) (default : x ↦ x)
Ω = the maximum value

P_result(x, y) = min(α(Δ), Ω)

Examples

Example 1 Example 2

Usage

Input is a list of positive points

distance_map(input.shape, points)

Input is binary (boolean) matrix

distance_map_from_binary_matrix(input)

Input is a list of positive points and you want to use custom arguments

distance_map(input.shape, points, distance="manhattan", beta=15.0, alpha="square")

Parameters

  • Distance
    • euclidean
    • manhattan
  • Alpha
    • identity (x ↦ x)
    • square (x ↦ x*x)
    • linear (x ↦ A*x + B)
      • use set_a(a) and def set_b(b) to change A and B values

Benchmark

The following tests has been made on a laptop with an Intel Core i7-7700HQ and 24Go of RAM.

Test Time distance_map Time distance_map_from_binary_matrix
2D 1024 x 1024 image with 10 positive points 8ms 11ms
2D 1024 x 1024 image with 5 positive points 5ms 9ms
3D 128 x 128 x 128 image with 10 positive points 61ms 148ms

Acknowledgement

This library is inspired for use as in the following paper.

N. Xu, B. Price, S. Cohen, J. Yang and T. Huang
"Deep Interactive Object Selection"
2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)
Las Vegas, NV, 2016, pp. 373-381
doi: 10.1109/CVPR.2016.47

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distance-map-1.0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

distance_map-1.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file distance-map-1.0.1.tar.gz.

File metadata

  • Download URL: distance-map-1.0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for distance-map-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4ce7cc0ca71765a38ccbbbd9e7b75c75fd3e579288aeacdeceb7ccfff3c61344
MD5 9bfd4feaf297aa31cc6773e842dd7295
BLAKE2b-256 c5bffd47c3dcca904897d0d12432a35fc27ed2129556d1f9fe09ee8a6c371f59

See more details on using hashes here.

File details

Details for the file distance_map-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: distance_map-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for distance_map-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38c901528b2601206d8b2fdd9cb66bdea23e8fdc0593e32f477b0046589971e7
MD5 bf472fcc633b4d8cad9e979bffae502d
BLAKE2b-256 4eb51c9db37c70836c4783ffd532e4970ac4ce5b020c72e3ced9dd3e0c95307e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page