DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# GrowRegionsWeighted

Grow labelled regions using grey-weighted distances

## SYNOPSIS

`#include "dip_regions.h"`

dip_Error GrowRegionsWeighted ( in, grey, mask, out, distance, pixelsize, chamfer, metric )

## DATA TYPES

`in`: binary, integer

`grey`: interger, float (converted to dip_sfloat)

`mask`: dip_uint8

## FUNCTION

The regions in the input image `in` are grown according to a grey-weighted distance metric; the weights are given by `grey`. The optional mask image `mask` limits the growing. `out` contains the grown regions, and `distance`, if not 0, contains the grey-weighted distance of each pixel in `mask` to the nearest pixel in `in`. Non-isotropic sampling is supported through `pixelsize`, which can be set to 0 to assume isotropic sampling. `chamfer` selects the size of the chamfer metric: 3 or 5. Set `chamfer` to 0 to use a custom metric given by the image `metric`. This image should be odd in size, and each pixel gives the distance to the center pixel. The pixels set to 0 will not be considered as neighbors.

The chamfer metric used is the following for `chamfer`==3 (with `ps0=pixelsize->array[0]` and `ps1=pixelsize->array[1]`):

`sqrt(ps0*ps0+ps1*ps1)` | `ps1` | `sqrt(ps0*ps0+ps1*ps1)`
`ps0` | 0 | `ps0`
`sqrt(ps0*ps0+ps1*ps1)` | `ps1` | `sqrt(ps0*ps0+ps1*ps1)`

and the following for `chamfer`==5:

0 | `sqrt(ps0*ps0+4*ps1*ps1)` | 0 | `sqrt(ps0*ps0+4*ps1*ps1)` | 0
`sqrt(4*ps0*ps0+ps1*ps1)` | `sqrt(ps0*ps0+ps1*ps1)` | `ps1` | `sqrt(ps0*ps0+ps1*ps1)` | `sqrt(4*ps0*ps0+ps1*ps1)`
0 | `ps0` | 0 | `ps0` | 0
`sqrt(4*ps0*ps0+ps1*ps1)` | `sqrt(ps0*ps0+ps1*ps1)` | `ps1` | `sqrt(ps0*ps0+ps1*ps1)` | `sqrt(4*ps0*ps0+ps1*ps1)`
0 | `sqrt(ps0*ps0+4*ps1*ps1)` | 0 | `sqrt(ps0*ps0+4*ps1*ps1)` | 0

Setting `chamfer` to 0 and `metric` to an image with these values produces the same results as setting `chamfer` to 3 or 5.

The output image `distance` is comparable to the `out` image of `GreyWeightedDistanceTransform`, except that that function uses optimal chamfer distances whereas this one uses the (sub-optimal) true distance. In return, this function works on images of any dimensionality, allows for non-isotropic sampling, does not skip pixels close to the edge of the image, and can be used with a mask image to constrain the propagation. Note that the `seed` image in `GreyWeightedDistanceTransform` corresponds to the zero pixels of `in` for this function.

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in` | Input binary or labelled image
`dip_Image` | `grey` | Input grey-value image
`dip_Image` | `mask` | Mask image
`dip_Image` | `out` | Output binary or labelled image
`dip_Image` | `distance` | Output distance image
`dip_FloatArray` | `pixelsize` | Pixel size
`dip_int` | `chamfer` | Chamfer distance
`dip_Image` | `metric` | Custom metric

## LITERATURE

"3-D Texture characterized by Accessibility measurements, based on the grey weighted distance transform", K.C. Strasters, A.W.M. Smeulders, and H.T.M. van der Voort, BioImaging, vol 2, no. 1, 1994, p. 1-21.

"An efficient uniform cost algorithm applied to distance transforms", B.J.H. Verwer, P.W. Verbeek, and S.T. Dekker, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 11, no. 4, 1989, 425-429.

## SEE ALSO

`GrowRegions`, `GreyWeightedDistanceTransform`, `Label`