distmap {EBImage} | R Documentation

## Distance map transform of binary images

### Description

The function performs a distance map transform of binary images. In a distance map each pixel contains the distance from that pixel to the nearest background point.

### Usage

      ## S4 method for signature 'Image':
      distmap(x, t=0.05, exact=FALSE, bg=0.05, ...)

### Arguments

`x` | A `Grayscale` object of `Image`. `x` is considered as a binary image, consisting of 0's for background and all other values for foreground.
`t` | A numeric value for the background threshold in the range `[0,1)`. Pixels with intensity smaller than `t` are considered as background.
`bg` | A numeric value for the allowed minimum for the fraction of background pixels in the image. The default and recommended value corresponds to 5% (0.05). See details for more information.
`exact` | A logical value if the distance to the neighboring diagonal elements should be calculated exactly, as `sqrt(2)`, or it should be set to 1, same as that for the neighbouring pixels on the vertical and horizontal axes.
`...` | Reserved.

### Details

Given a binary or gray scale image with background set to 0, a distance map transform generates an image each pixel of which contains the distance from that pixel to the nearest background pixel (zero) or the edge of the image.

If foreground constitutes more than 95% of the image, computation of a distance map can be very lengthy as the function uses an iterative algorithm. This is a very rare situation anyway and the value of `bg` provides a protection mechanism, e.g. in case a very noise image is supplied performing a threshold first.

This function is used extensively in object detection. Distance map is a standard input for the `watershed` algorithm used to identify and separate closely positioned objects.

### Value

A `Grayscale` object of `Image` with pixels containing the `floor` values of their distances to the nearest background points. The range of the resulting image is `[0,n]`, where `n`, a positive integer, will be the distance from center of the largest object.
To preview the results visually, use `display(normalize(result))`.

### Author(s)

Oleg Sklyar, osklyar@ebi.ac.uk, 2006

### See Also

`Image, watershed, thresh, propagate`

### Examples

      ## Not run: see ?watershed for an example

[Package EBImage version 2.2.0 Index]