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

# MeasurementFeatureRegister

Register a measurement function

## SYNOPSIS

`#include "dip_measurement.h"`

dip_Error dip_MeasurementFeatureRegister ( registry )

## FUNCTION

This function registers a measurement function, specified by `registry`. Once a function is registered, it can be used through the `Measure` function by specifying `registry.id.rtid` as the measurement ID. `registry` contains pointers to a series of functions related to making the measurement, and contains information on how these functions should be called. See below for more information.

## ARGUMENTS

Data type | Name | Description
`dip_MeasurementFeatureRegistry` | `registry` | Registry

## THE REGISTRY STRUCTURE

The `dip_MeasurementFeatureRegistry` structure contains the following fields:

Data type | Name | Description
`dip_Identifier` | `id` | Unique identifier
`dipf_FeatureMeasureFunction` | `type` | Type of function `measure` points to
`dip_FeatureCreateFunction` | `create` | Function pointer, see `FeatureCreateFunction`
`dip_FeatureComposeFunction` | `compose` | Function pointer, see `FeatureComposeFunction`
`dip_FeatureMeasureFunction` | `measure` | Union of function pointers
`dip_FeatureValueFunction` | `value` | Function pointer, see `FeatureValueFunction`
`dip_FeatureDescriptionFunction` | `description` | Function pointer, see `FeatureDescriptionFunction`
`dip_FeatureConvertFunction` | `convert` | Function pointer, see `FeatureConvertFunction`
`dip_int` | `iterations` | Currently ignored (set to 1)
`dip_Boolean` | `needIntensityIm` | Whether or not a grey-value image is needed

`dip_Identifier` is a struct with two values: `uuid` and `rtid`. `rtid` is of type `dip_int`, and needs to be set to a unique number (use `GetUniqueNumber` for that). `uuid` is curently ignored, but should be set to a universally unique number by using the time, date and processor ID at the time of writing the code. The UNIX command `uuidgen` should be used for this.

`measure` points to the main measuring function, and can be of four different types, based on how it does the measuring. `measure` is a union with the following fields:

Data type | Name | Description
`dip_FeatureLineFunction` | `line` | Takes one image line at the time, see `FeatureLineFunction`
`dip_FeatureImageFunction` | `image` | Takes the whole image at once, see `FeatureImageFunction`
`dip_FeatureChainCodeFunction` | `chaincode` | Takes one chain code at the time, see `FeatureChainCodeFunction`
`dip_FeatureConvHullFunction` | `convhull` | Takes one convex polygon at the time, see `FeatureConvHullFunction`
`dip_FeatureCompositeFunction` | `composite` | Combines the results of various other measurements, see `FeatureCompositeFunction`

The `type` flag should match the function type pointed to, and can be one of the following:

Name | Description
`DIP_MSR_FUNCTION_LINE_BASED` | `measure.line` is set
`DIP_MSR_FUNCTION_IMAGE_BASED` | `measure.image` is set
`DIP_MSR_FUNCTION_CHAINCODE_BASED` | `measure.chaincode` is set
`DIP_MSR_FUNCTION_CONVHULL_BASED` | `measure.convhull` is set
`DIP_MSR_FUNCTION_COMPOSITE` | `measure.composite` is set

`create` points to a function that allocates and initialises any data before the measurement can start. `value` points to a function that returns the measurement result (called by `MeasurementObjectValue`). `description` points to a function that returns information on the measurement performed (called by `MeasurementFeatureDescription`). `convert` points to a function that copies the collected measurement data to a second measurement object (called `MeasurementFeatureConvert`). Finally, the `compose` element points to a function that returns the list of measurement IDs that the `DIP_MSR_FUNCTION_COMPOSITE` function depends on. This value is ignored for other types of measurement functions.

`needIntensityIm` should be set if the measurement function expects a grey-value input as well as the labeled image.

## SEE ALSO

`Measure`, `MeasurementFeatureRegistryList`, `MeasurementFeatureRegistryGet`, `MeasurementFeatureRegistryFeatureDescription`, `MeasurementFeatureRegistryFeatureNeedsIntensityImage`, `MeasurementFeatureValid`, `MeasurementFeatureDescription`, `MeasurementObjectData`, `MeasurementObjectValue`, `MeasurementFeatureConvert`, `FeatureLineFunction`, `FeatureImageFunction`, `FeatureChainCodeFunction`, `FeatureConvHullFunction`, `FeatureCompositeFunction`, `FeatureCreateFunction`, `FeatureComposeFunction`, `FeatureValueFunction`, `FeatureConvertFunction`, `FeatureDescriptionFunction`