Skip to main content

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

Metadata

Release files for distance-map 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for distance-map 1.0.1
File Size Uploaded
distance-map-1.0.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for distance-map 1.0.1
File Interpreter ABI Platform
distance_map-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / distance-map-1.0.1.tar.gz

Download URL distance-map-1.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4ce7cc0ca71765a38ccbbbd9e7b75c75fd3e579288aeacdeceb7ccfff3c61344
BLAKE2b-256 checksum
How to use checksums
c5bffd47c3dcca904897d0d12432a35fc27ed2129556d1f9fe09ee8a6c371f59
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / distance_map-1.0.1-py3-none-any.whl

Download URL distance_map-1.0.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38c901528b2601206d8b2fdd9cb66bdea23e8fdc0593e32f477b0046589971e7
BLAKE2b-256 checksum
How to use checksums
4eb51c9db37c70836c4783ffd532e4970ac4ce5b020c72e3ced9dd3e0c95307e
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page