0% found this document useful (0 votes)
137 views

Diplib Reference Guide

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Diplib Reference Guide

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 732

DIPlib function reference

dr. ir. Geert M. P. van Kempen


dr. ir. Michael van Ginkel
dr. ir. Cris L. Luengo Hendriks
dr. dr. dipl. phys. Bernd Rieger
prof. dr. ir. Lucas J. van Vliet

Quantitative Imaging Group,


Department of Applied Sciences, Delft
Delft University of Technology February 26, 2009
Contents
1 Indices of functions by subject 4
1.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.1 Image Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 Scalar Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.3 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.4 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.5 Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.6 Pixel Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.7 Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.8 Numerical Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.9 Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.10 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1.11 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1.12 Support Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2 File I/O functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.1 File IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3 Image Processing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1 Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.3.3 Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.3.4 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.3.5 Painting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.3.6 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.7 Derivative Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.8 Non-Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.3.9 Binary Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.3.10 Mathematical Morphology . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.3.11 Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.3.12 Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3
4 Contents

1.3.13 Distance Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24


1.4 Application Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4.1 Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4.2 Sharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4.3 Line and Edge Detection . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4.4 Extrema Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4.5 Object Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.4.6 Noise Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.4.7 Image Restoration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.4.8 Shift Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.4.9 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.4.10 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.4.11 Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.4.12 Functions for Microscopy . . . . . . . . . . . . . . . . . . . . . . . . . 31

2 Function reference 32

3 Assorted topics 710


3.1 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
3.2 Compression methods for image files . . . . . . . . . . . . . . . . . . . . . . . 712
3.3 DerivativeSpec data structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
3.4 DIPlib’s data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
3.5 dip MsrRegistry structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
3.6 Description of DIPlib’s pixel tables . . . . . . . . . . . . . . . . . . . . . . . . 719
3.7 File formats recognized by dipIO . . . . . . . . . . . . . . . . . . . . . . . . . 720
3.8 From images to scalars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
3.9 General information about convolution . . . . . . . . . . . . . . . . . . . . . . 724
3.10 General information about sorting . . . . . . . . . . . . . . . . . . . . . . . . 725
3.11 Information about dyadic operations . . . . . . . . . . . . . . . . . . . . . . . 726
3.12 The image structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
3.13 The connectivity parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Chapter 1

Indices of functions by subject

5
6 Chapter 1. Indices of functions by subject
DIPlib function reference 7

1.1 Library Functions


1.1.1 Image Object

• ChangeDataType - Change the data type of an image

• ChangeDimensions - Changes the order of the dimensions in an image

• ChangeTo0d - Make an image zero dimensional

• HasNormalStride - Determines whether an image has a normal stride

• ImageAssimilate - Inherit properties of another image

• ImageCopyProperties - Copy the properties of an image

• ImageForge - Allocate pixel data for an image

• ImageFree - Free an image

• ImageGetData - Get the data pointers of a set of images

• ImageGetDataType - Read the data type field

• ImageGetDimensionality - Read the dimensionality field

• ImageGetDimensions - Read the dimensions array

• ImageGetPlane - Read the plane number

• ImageGetStride - Read the stride array

• ImageGetType - Read the type field

• ImageNew - Allocate a structure

• ImagesCheck - Check properties of several images

• ImagesCheckTwo - Check properties of two images

• ImagesCompare - Compare properties of several images

• ImagesCompareTwo - Compare properties of two images

• ImageSetDataType - Set the data type field

• ImageSetDimensions - Set the dimensions array

• ImageSetType - Set the image type field

• ImagesSeparate - Take care of in-place operations

• ImageStrip - Restore an image to its initial (“raw”) state


8 Chapter 1. Indices of functions by subject

1.1.2 Scalar Images

• ConvertDataType - Converts the data type of an image

• IsScalar - Determines whether an image is a scalar

• ScalarImageNew - Allocate a scalar image

1.1.3 Strings

• StringAppend - Append a string to another

• StringArrayCopy - Copy a string array

• StringArrayFree - Array free function

• StringArrayNew - Allocate an array of strings

• StringCat - Concatenate two strings

• StringCompare - Compare two strings

• StringCompareCaseInsensitive - Compare two strings without minding case

• StringCopy - Copy a String

• StringCrop - Crop a string

• StringFree - Free a string

• StringNew - Allocate a string

• StringReplace - Replace the contents of one string with that of another

• UnderscoreSpaces - Replace spaces with underscores

1.1.4 Arrays

• ArrayFree - Array free function

• ArrayNew - Array allocation function

• BooleanArrayCopy - Copy an array

• BooleanArrayFind - Find value in array

• BooleanArrayFree - Array free function

• BooleanArrayNew - Array allocation function

• BoundaryArrayFree - Array free function

• BoundaryArrayNew - Array allocation function


DIPlib function reference 9

• ComplexArrayCopy - Copy an array

• ComplexArrayFind - Find value in array

• ComplexArrayFree - Array free function

• ComplexArrayNew - Array allocation function

• ConvertArray - converts the data type of an array

• CoordinateArrayFree - Array free function

• CoordinateArrayNew - Array allocation function

• DataTypeArrayCopy - Copy an array

• DataTypeArrayFind - Find value in array

• DataTypeArrayFree - Array free function

• DataTypeArrayNew - Array allocation function

• FloatArrayCopy - Copy an array

• FloatArrayFind - Find value in array

• FloatArrayFree - Array free function

• FloatArrayNew - Array allocation function

• FrameWorkProcessArrayFree - Array free function

• FrameWorkProcessArrayNew - Array allocation function

• ImageArrayFree - Array free function

• ImageArrayNew - Array allocation function

• ImageCheckBooleanArray - Check a boolean array

• ImageCheckBoundaryArray - Check a boundary array

• ImageCheckComplexArray - Check a complex array

• ImageCheckFloatArray - Check a float array

• ImageCheckIntegerArray - Check an integer array

• IntegerArrayCopy - Copy an array

• IntegerArrayFind - Find value in array

• IntegerArrayFree - Array free function

• IntegerArrayNew - Array allocation function

• StringArrayCopy - Copy a string array


10 Chapter 1. Indices of functions by subject

• StringArrayFree - Array free function


• StringArrayNew - Allocate an array of strings
• VoidPointerArrayCopy - Copy an array
• VoidPointerArrayFind - Find value in array
• VoidPointerArrayFree - Array free function
• VoidPointerArrayNew - Array allocation function

1.1.5 Frameworks

• MonadicFrameWork - FrameWork for monadic operations


• PixelTableFrameWork - FrameWork for PixelTable filters
• ScanFrameWork - FrameWork for scanning multiple images
• SeparableFrameWork - FrameWork for separable filters
• SingleOutputFrameWork - FrameWork for generation functions

1.1.6 Pixel Tables

• BinaryImageToPixelTable - Convert a binary image to a pixel table


• PixelTableAddRun - Add a new run to a pixel table
• PixelTableCreateFilter - Create a pixel table from a filter shape
• PixelTableFrameWork - FrameWork for PixelTable filters
• PixelTableGetDimensionality - Get the dimensionality of a pixel table
• PixelTableGetDimensions - Get the dimemsions of a pixel table
• PixelTableGetOffsetAndLength - Converts the pixel table’s runs
• PixelTableGetOrigin - Get the origin of the pixel table
• PixelTableGetPixelCount - Get the number of pixels encoded in the pixel table
• PixelTableGetRun - Get the contents of a pixel table run
• PixelTableGetRuns - Get the number of runs in a pixel table
• PixelTableGetSize - The number of pixels in the pixel table’s bounding box
• PixelTableNew - Allocate a new pixel table
• PixelTableSetRun - Initialises a pixel table run
• PixelTableToBinaryImage - Convert a pixel table to a binary image
DIPlib function reference 11

1.1.7 Data Structures

• PixelHeapFree - Destroy heap structure

• PixelHeapIsEmpty - Query heap

• PixelHeapNew - Create a new heap structure

• PixelHeapPop - Pop item onto heap

• PixelHeapPush - Push item onto heap

• PixelQueueFree - Destroy queue structure

• PixelQueueIsEmpty - Query queue

• PixelQueueNew - Create a new queue structure

• PixelQueuePop - Pop item from queue

• PixelQueuePush - Push item onto queue

• StablePixelHeapFree - Destroy heap structure

• StablePixelHeapIsEmpty - Query heap

• StablePixelHeapNew - Create a new heap structure

• StablePixelHeapPop - Pop item onto heap

• StablePixelHeapPush - Push item onto heap

1.1.8 Numerical Algorithms

• OneDimensionalSearch - Numerical algorithm

1.1.9 Sorting

• DistributionSort - Sort a block of data

• DistributionSortIndices - Sort indices to block of data

• DistributionSortIndices16 - Sort indices to a block of data

• GetRank - Value selection function

• ImageSort - Sort image data

• ImageSortIndices - Sort indices to image data

• InsertionSort - Sort a block of data

• InsertionSortIndices - Sort indices to a block of data


12 Chapter 1. Indices of functions by subject

• InsertionSortIndices16 - Sort indices to a block of data

• QuickSort - Sort a block of data

• QuickSortAnything - Sort data of any type

• QuickSortIndices - Sort indices to a block of data

• QuickSortIndices16 - Sort indices to a block of data

• Sort - Sort a block of data

• SortAnything - Sort data of any type

• SortCompareFunction - Typedef for comparison function (sorting)

• SortIndices - Sort indices to a block of data

• SortIndices16 - Sort indices to a block of data

• SortSwapFunction - Typedef for swap and copy function (sorting)

1.1.10 Indexing

• CoordinateToIndex - Convert coordinate to pixel index

• dip PixelGetFloat - Midlevel PixelIO function

• dip PixelGetInteger - Midlevel PixelIO function

• dip PixelSetFloat - Midlevel PixelIO function

• dip PixelSetInteger - Midlevel PixelIO function

• Get - Get a pixel value

• GetComplex - Get complex pixel value

• GetFloat - Get float pixel value

• GetInteger - Get integer pixel value

• IndexToCoordinate - Convert pixel index to coordinate

• IndexToCoordinateWithSingletons - Convert pixel index to coordinate

• NeighbourIndicesListMake - Get indices to direct neighbours

• NeighbourListMake - Get list of direct neighbours

• NeighbourListMakeChamfer - Get list of neighbours based on Chamfer metric

• NeighbourListMakeImage - Get list of neighbours based on metric in image

• NeighbourListToIndices - Get indices to neighbours


DIPlib function reference 13

• Set - the value of a pixel

• SetComplex - Set a pixel value

• SetFloat - Set a pixel value

• SetInteger - Set a pixel value

1.1.11 Memory Management

• MemoryCopy - Copy memory blocks

• MemoryFree - Free a chunk of memory

• MemoryFunctionsSet - Sets memory allocation functions

• MemoryNew - Allocate and track memory

• MemoryReallocate - Reallocate a chunk of memory

• ResourcesFree - Free resources

• ResourcesMerge - Add one resource list to another

• ResourcesNew - Allocate a resource tracking structure

• ResourceSubscribe - Track a resource

• ResourceUnsubscribe - Stop tracking a resource

1.1.12 Support Functions

• DataTypeAllowed - Check whether a data type is allowed

• DataTypeGetInfo - Get information about a data type

• error.h - Contains error messages

• ErrorFree - Free a DIPlib call tree

• Exit - Clean up before exiting

• FillBoundaryArray - Fill the border of array according to the boundary condition

• GetLibraryInformation - Support function

• GetUniqueNumber - Obtain an unique value

• GlobalBoundaryConditionGet - Get global Boundary Conditions

• GlobalBoundaryConditionSet - Set global boundary conditions

• GlobalFilterShapeGet - Get global filter shape value


14 Chapter 1. Indices of functions by subject

• GlobalFilterShapeSet - Set the global filter shape value

• GlobalGaussianTruncationGet - Get the global gaussian truncation

• GlobalGaussianTruncationSet - Set the global gaussian truncation

• Initialise - Initialise DIPlib

• macros.h - Various macros

• ovl.h - Call an overloaded function

• PhysicalDimensionsCopy - Copy a Physical Dimensions

• PhysicalDimensionsFree - Free a Physical Dimensions data structure

• PhysicalDimensionsIsIsotropic - Checks if the Physical Dimensions are isotropic

• PhysicalDimensionsNew - Allocates a new Physical Dimensions structure

• Register - Generic registry function

• RegisterClass - Register a registry class

• RegistryArrayNew - Allocate a registry array

• RegistryGet - Get a registry item

• RegistryList - Get an array of registry IDs

• RegistryValid - Validate an registry item

• TimerGet - Timing functions

• TimerSet - Timing functions

• tpi.h - Type iterator

• Unregister - Remove a registry item

1.2 File I/O functions


1.2.1 File IO

• Colour2Gray - Convert ND image with colour information to a (n-1)D grayvalue


image (in dipIO)

• ImageFileGetInfo - Get information about image in file (in dipIO)

• ImageFileInformationFree - Free a Image File Information structure (in dipIO)

• ImageFileInformationNew - Allocate an Image File Information structure (in dipIO)

• ImageIsGIF - Confirm that a file is a GIF file (in dipIO)


DIPlib function reference 15

• ImageIsICS - Confirm that a file is an ICS file (in dipIO)

• ImageIsJPEG - Confirm that a file is a JPEG file (in dipIO)

• ImageIsLSM - Confirm that a file is a Zeiss LSM file (in dipIO)

• ImageIsTIFF - Confirm that a file is a TIFF file (in dipIO)

• ImageRead - Read grey-value image from file (in dipIO)

• ImageReadColour - Read colour image from file (in dipIO)

• ImageReadCSV - Read comma-separated values from file (in dipIO)

• ImageReadCSVInfo - Get information about image in comma-separated values file (in


dipIO)

• ImageReadGIF - Read a GIF image from file (in dipIO)

• ImageReadGIFInfo - Get information about image in GIF file (in dipIO)

• ImageReadICS - Read ICS image from file (in dipIO)

• ImageReadICSInfo - Get information about image in ICS file (in dipIO)

• ImageReadJPEG - Read JPEG image from file (in dipIO)

• ImageReadJPEGInfo - Get information about image in JPEG file (in dipIO)

• ImageReadLSM - Read Zeiss LSM image from file (in dipIO)

• ImageReadLSMInfo - Get information about image in LSM file (in dipIO)

• ImageReadPIC - Read BioRad PIC image from file (in dipIO)

• ImageReadPICInfo - Get information about image in BioRad PIC file (in dipIO)

• ImageReadROI - Read a portion of a grey-value image from file (in dipIO)

• ImageReadTIFF - Read TIFF image from file (in dipIO)

• ImageReadTIFFInfo - Get information about image in TIFF file (in dipIO)

• ImageWrite - Write grey-value image to file (in dipIO)

• ImageWriteColour - Write colour image to file (in dipIO)

• ImageWriteCSV - Write image to a comma-separated-value file (in dipIO)

• ImageWriteEPS - Write image to Encapsulated PostScript file (in dipIO)

• ImageWriteFLD - Write image to AVS field file (in dipIO)

• ImageWriteGIF - Write image to a GIF file (in dipIO)

• ImageWriteICS - Write ICS image to file (in dipIO)


16 Chapter 1. Indices of functions by subject

• ImageWriteJPEG - Write JPEG image to file (in dipIO)

• ImageWritePS - Write image to PostScript file (in dipIO)

• ImageWriteTIFF - Write TIFF image to file (in dipIO)

• MeasurementRead - Read measurement results from a file

• MeasurementWrite - Write measurement results to a file

• MeasurementWriteCSV - Write measurement results to a CSV file

• MeasurementWriteHTML - Write measurement results to an HTML file

• MeasurementWriteText - Write measurement results as readable text

1.3 Image Processing Functions


1.3.1 Mathematics

• Abs - Arithmetic function

• Acos - trigonometric function

• Add - arithmetic function

• AddComplex - arithmetic function

• AddFloat - arithmetic function

• And - logic operation

• Asin - trigonometric function

• Atan - trigonometric function

• Atan2 - arithmetic function

• BesselJ0 - mathematical function

• BesselJ1 - mathematical function

• BesselJN - mathematical function

• BesselY0 - mathematical function

• BesselY1 - mathematical function

• BesselYN - mathematical function

• Ceil - Arithmetic function

• Compare - Compare grey values in two images

• Cos - trigonometric function


DIPlib function reference 17

• Cosh - trigonometric function

• CumulativeSum - statistics function

• Div - arithmetic function

• DivComplex - arithmetic function

• DivFloat - arithmetic function

• Equal - Compare grey values in two images

• Erf - mathematical function

• Erfc - mathematical function

• Exp - arithmetic function

• Exp10 - arithmetic function

• Exp2 - arithmetic function

• Floor - Arithmetic function

• Fraction - Arithmetic function

• GetMaximumAndMinimum - statistics function

• Greater - Compare grey values in two images

• IDivergence - difference measure

• Imaginary - Arithmetic function

• Invert - logic operation

• Lesser - Compare grey values in two images

• Ln - arithmetic function

• LnGamma - mathematical function

• LnNormError - difference measure

• Log10 - arithmetic function

• Log2 - arithmetic function

• Max - arithmetic function

• MaxFloat - arithmetic function

• Maximum - statistics function

• mBesselJ0 - mathematical function

• mBesselJ1 - mathematical function


18 Chapter 1. Indices of functions by subject

• mBesselJN - mathematical function

• mBesselY0 - mathematical function

• mBesselY1 - mathematical function

• mBesselYN - mathematical function

• Mean - statistics function

• MeanAbsoluteError - difference measure

• MeanError - difference measure

• MeanModulus - statistics function

• MeanSquareError - difference measure

• MeanSquareModulus - statistics function

• Median - statistics function

• mErf - mathematical function

• mErfc - mathematical function

• mExp10 - mathematical function

• mExp2 - mathematical function

• mFraction - mathematical function

• mGammaP - mathematical function

• mGammaQ - mathematical function

• Min - arithmetic function

• MinFloat - arithmetic function

• Minimum - statistics function

• mLnGamma - mathematical function

• mLog2 - mathematical function

• mNearestInt - mathematical function

• Modulo - Arithmetic function

• Modulus - Arithmetic function

• mReciprocal - mathematical function

• mSign - mathematical function

• mSinc - mathematical function


DIPlib function reference 19

• mTruncate - mathematical function

• Mul - arithmetic function

• MulComplex - arithmetic function

• MulFloat - arithmetic function

• NearestInt - Arithmetic function

• NormaliseSum - Normalise the sum of the pixel values

• NotEqual - Compare grey values in two images

• NotGreater - Compare grey values in two images

• NotLesser - Compare grey values in two images

• Or - logic operation

• Percentile - statistics function

• Phase - Arithmetic function

• RadialMaximum - statistics function

• RadialMean - statistics function

• RadialMinimum - statistics function

• RadialSum - statistics function

• Real - Arithmetic function

• Reciprocal - arithmetic function

• RootMeanSquareError - difference measure

• Select - Configurable selection function

• Sign - Arithmetic function

• Sin - trigonometric function

• Sinc - mathematical function

• SingularValueDecomposition - Singular value decomposition

• Sinh - trigonometric function

• Sqrt - arithmetic function

• StandardDeviation - statistics function

• Sub - arithmetic function

• SubComplex - arithmetic function


20 Chapter 1. Indices of functions by subject

• SubFloat - arithmetic function

• Sum - statistics function

• SumModulus - statistics function

• Tan - trigonometric function

• Tanh - trigonometric function

• Truncate - Arithmetic function

• Variance - statistics function

• WeightedAdd - arithmetic function

• WeightedDiv - arithmetic function

• WeightedMul - arithmetic function

• WeightedSub - arithmetic function

• Xor - logic operation

1.3.2 Statistics

• ChordLength - Compute the chord lengths of the different phases

• CumulativeSum - statistics function

• GetMaximumAndMinimum - statistics function

• IDivergence - difference measure

• LnNormError - difference measure

• Maximum - statistics function

• Mean - statistics function

• MeanAbsoluteError - difference measure

• MeanError - difference measure

• MeanModulus - statistics function

• MeanSquareError - difference measure

• MeanSquareModulus - statistics function

• Median - statistics function

• Minimum - statistics function

• PairCorrelation - Compute the pair correlation function


DIPlib function reference 21

• Percentile - statistics function

• ProbabilisticPairCorrelation - Compute the probabilistic pair correlation function

• RadialMaximum - statistics function

• RadialMean - statistics function

• RadialMinimum - statistics function

• RadialSum - statistics function

• RootMeanSquareError - difference measure

• StandardDeviation - statistics function

• Sum - statistics function

• SumModulus - statistics function

• Variance - statistics function

1.3.3 Manipulation

• Crop - Remove the outer parts of an image

• dip PixelGetFloat - Midlevel PixelIO function

• dip PixelGetInteger - Midlevel PixelIO function

• dip PixelSetFloat - Midlevel PixelIO function

• dip PixelSetInteger - Midlevel PixelIO function

• ExtendRegion - Image manipulation functions

• Get - Get a pixel value

• GetComplex - Get complex pixel value

• GetFloat - Get float pixel value

• GetInteger - Get integer pixel value

• GetLine - Get a line from an image

• GetSlice - Get a slice from an image

• Map - Remaps an image

• Mirror - Mirrors an image

• PutLine - Put a line in an image

• PutSlice - Put a slice in an image


22 Chapter 1. Indices of functions by subject

• Resampling - Interpolation function

• Rotation - Interpolation function

• Rotation3d - Interpolation function

• Rotation3d Axis - Interpolation function

• Set - the value of a pixel

• SetComplex - Set a pixel value

• SetFloat - Set a pixel value

• SetInteger - Set a pixel value

• Shift - an image manipulation function

• Skewing - Interpolation function

• Subsampling - Interpolation function

• Wrap - Wrap an image

1.3.4 Interpolation

• Resampling - Interpolation function

• Rotation - Interpolation function

• Rotation3d - Interpolation function

• Rotation3d Axis - Interpolation function

• Skewing - Interpolation function

• Subsampling - Interpolation function

1.3.5 Painting

• PaintBox - Paint a box

• PaintDiamond - Paint a diamond-shaped object

• PaintEllipsoid - Paint an ellipsoid


DIPlib function reference 23

1.3.6 Linear Filters

• Convolve1d - Perform a 1D convolution

• ConvolveFT - Fourier transform based convolution filter

• Derivative - Derivative filter

• FiniteDifference - A linear gradient filter

• FiniteDifferenceEx - A linear gradient filter

• GaborIIR - Infinite impulse response filter

• Gauss - Gaussian Filter

• GaussFT - Gaussian Filter through the Fourier Domain

• GaussIIR - Infinite impulse response filter

• Laplace - Second order derivative filter

• SeparableConvolution - FrameWork for separable convolution filters

• Sharpen - Enhance an image

• SobelGradient - A linear gradient filter

• Uniform - Uniform filter

1.3.7 Derivative Filters

• Derivative - Derivative filter

• Dgg - Second order derivative filter

• FiniteDifference - A linear gradient filter

• FiniteDifferenceEx - A linear gradient filter

• Gauss - Gaussian Filter

• GaussFT - Gaussian Filter through the Fourier Domain

• GradientDirection2D - Derivative filter

• GradientMagnitude - Derivative filter

• Laplace - Second order derivative filter

• LaplaceMinDgg - Second order derivative filter

• LaplacePlusDgg - Second order derivative filter

• SobelGradient - A linear gradient filter


24 Chapter 1. Indices of functions by subject

1.3.8 Non-Linear Filters

• BiasedSigma - Adaptive edge sharpening & contrast enhancing filter

• Closing - Morphological closing operation

• Dilation - Local maximum filter

• Erosion - Local minimum filter

• GaussianSigma - Adaptive Gaussian smoothing filter

• GeneralisedKuwahara - Generalised Kuwahara filter

• Kuwahara - Edge perserving smoothing filter

• MedianFilter - Non-linear smoothing filter

• MorphologicalSmoothing - Morphological smoothing filter

• Opening - Morphological opening operation

• PercentileFilter - Rank-order filter

• Sigma - Adaptive uniform smoothing filter

• VarianceFilter - Sample Variance Filter

1.3.9 Binary Filters

• BinaryClosing - Binary morphological closing operation

• BinaryDilation - Binary morphological dilation operation

• BinaryErosion - Binary morphological erosion operation

• BinaryOpening - Binary morphological opening operation

• BinaryPropagation - Morphological propagation of binary objects

• EdgeObjectsRemove - Remove binary edge objects

• EuclideanSkeleton - binary skeleton operation

• GrowRegions - Dilate the regions in a labelled image

• Label - Label a binary image


DIPlib function reference 25

1.3.10 Mathematical Morphology

• AreaOpening - Morphological filter

• BinaryClosing - Binary morphological closing operation

• BinaryDilation - Binary morphological dilation operation

• BinaryErosion - Binary morphological erosion operation

• BinaryOpening - Binary morphological opening operation

• BinaryPropagation - Morphological propagation of binary objects

• Closing - Morphological closing operation

• Dilation - Local maximum filter

• EdgeObjectsRemove - Remove binary edge objects

• Erosion - Local minimum filter

• EuclideanSkeleton - binary skeleton operation

• GrowRegions - Dilate the regions in a labelled image

• GrowRegionsWeighted - Grow labelled regions using grey-weighted distances

• Lee - Morphological edge detector

• LocalMinima - Marks local minima (or regional minima)

• Maxima - Detects local maxima

• Minima - Detects local minima

• MorphologicalGradientMagnitude - Morphological edge detector

• MorphologicalRange - Morphological edge detector

• MorphologicalReconstruction - Morphological filter

• MorphologicalSmoothing - Morphological smoothing filter

• MorphologicalThreshold - Morphological smoothing filter

• MultiScaleMorphologicalGradient - Morphological edge detector

• Opening - Morphological opening operation

• SeededWatershed - Morphological segmentation

• Tophat - Morphological high-pass filter

• UpperEnvelope - Upper envelope transform (a flooding and an algebraic closing)

• Watershed - Morphological segmentation


26 Chapter 1. Indices of functions by subject

1.3.11 Point Operations

• Clip - Point operation

• Compare - Compare grey values in two images

• ContrastStretch - Point operation

• Equal - Compare grey values in two images

• ErfClip - Point Operation

• Greater - Compare grey values in two images

• HysteresisThreshold - Point Operation

• IsodataThreshold - Point operation

• Lesser - Compare grey values in two images

• NotEqual - Compare grey values in two images

• NotGreater - Compare grey values in two images

• NotLesser - Compare grey values in two images

• NotZero - Point Operation

• RangeThreshold - Point Operation

• Select - Configurable selection function

• SelectValue - Point Operation

• Threshold - Point Operation

1.3.12 Transforms

• FourierTransform - Computes the Fourier transform

• HartleyTransform - Computes the Hartley transform

1.3.13 Distance Transforms

• EuclideanDistanceTransform - Euclidean distance transform

• GreyWeightedDistanceTransform - Grey weighted distance transform

• GrowRegionsWeighted - Grow labelled regions using grey-weighted distances

• VectorDistanceTransform - Euclidean vector distance transform


DIPlib function reference 27

1.4 Application Functions


1.4.1 Smoothing

• Closing - Morphological closing operation


• Gauss - Gaussian Filter
• GaussFT - Gaussian Filter through the Fourier Domain
• Kuwahara - Edge perserving smoothing filter
• MedianFilter - Non-linear smoothing filter
• MorphologicalSmoothing - Morphological smoothing filter
• MorphologicalThreshold - Morphological smoothing filter
• Opening - Morphological opening operation
• PercentileFilter - Rank-order filter
• Uniform - Uniform filter
• UpperEnvelope - Upper envelope transform (a flooding and an algebraic closing)

1.4.2 Sharpening

• Sharpen - Enhance an image

1.4.3 Line and Edge Detection

• DanielsonLineDetector - Line detector


• GradientMagnitude - Derivative filter
• Laplace - Second order derivative filter
• Lee - Morphological edge detector
• MorphologicalGradientMagnitude - Morphological edge detector
• MorphologicalRange - Morphological edge detector
• MultiScaleMorphologicalGradient - Morphological edge detector

1.4.4 Extrema Detection

• LocalMinima - Marks local minima (or regional minima)


• Maxima - Detects local maxima
• Minima - Detects local minima
28 Chapter 1. Indices of functions by subject

1.4.5 Object Generation

• CityBlockDistanceToPoint - Distance generation function

• EllipticDistanceToPoint - Distance generation function

• EuclideanDistanceToPoint - Distance generation function

• FTBox - Generates the Fourier transform of a box

• FTCross - Generates the Fourier transform of a cross

• FTCube - Generates the Fourier transform of a cube

• FTEllipsoid - Generates Fourier transform of a ellipsoid

• FTGaussian - Generates the Fourier transform of a Gaussian

• FTSphere - Generated Fourier transform of a sphere

• IncoherentOTF - Generates an incoherent OTF

• IncoherentPSF - Generates an incoherent PSF

• PaintBox - Paint a box

• PaintDiamond - Paint a diamond-shaped object

• PaintEllipsoid - Paint an ellipsoid

• TestObjectAddNoise - TestObject generation function

• TestObjectBlur - TestObject generation function

• TestObjectCreate - TestObject generation function

• TestObjectModulate - TestObject generation function

1.4.6 Noise Generation

• BinaryNoise - Generates an image disturbed by binary noise

• BinaryRandomVariable - Binary random variable generator

• GaussianNoise - Generate an image disturbed by Gaussian noise

• GaussianRandomVariable - Gaussian random variable generator

• PoissonNoise - Generate an image disturbed by Poisson noise

• PoissonRandomVariable - Poisson random variable generator

• RandomSeed - Random seed function

• RandomVariable - Random number generator


DIPlib function reference 29

• UniformNoise - Generate an image disturbed by uniform noise

• UniformRandomVariable - Uniform random variable generator

1.4.7 Image Restoration

• AttenuationCorrection - Attenuation correction algorithm

• ExponentialFitCorrection - Exponential fit based attenuation correction

• PseudoInverse - Image restoration filter

• SimulatedAttenuation - Simulation of the attenuation process

• TikhonovMiller - Image restoration filter

• TikhonovRegularizationParameter - Determine the value of the regularisation


parameter

• Wiener - Image Restoration Filter

1.4.8 Shift Estimation

• CrossCorrelationFT - Normalized cross-correlation using the Fourier Transform

• FindShift - Estimate the shift between images

1.4.9 Segmentation

• HysteresisThreshold - Point Operation

• IsodataThreshold - Point operation

• RangeThreshold - Point Operation

• SeededWatershed - Morphological segmentation

• Threshold - Point Operation

• Watershed - Morphological segmentation

1.4.10 Analysis

• ChordLength - Compute the chord lengths of the different phases

• DanielsonLineDetector - Line detector

• Label - Label a binary image

• Measure - Measure object features


30 Chapter 1. Indices of functions by subject

• PairCorrelation - Compute the pair correlation function

• ProbabilisticPairCorrelation - Compute the probabilistic pair correlation function

• StructureTensor2D - Two dimensional Structure Tensor

1.4.11 Measurement

• FeatureAnisotropy2D - Measure the anisotropy in a labeled region

• FeatureBendingEnergy - Undocumented measurement function

• FeatureCenter - Measure the object’s center

• FeatureChainCodeBendingEnergy - Undocumented measurement function

• FeatureDescriptionFree - Free a Feature Description

• FeatureDescriptionGetDescription - Get the description of the described feature

• FeatureDescriptionGetLabels - Get the labels of the described feature

• FeatureDescriptionGetName - Get the name of the described feature

• FeatureDescriptionGetUnits - Get the Units of the described feature

• FeatureDescriptionNew - Allocate a new FeatureDescription

• FeatureDescriptionSetDescription - Set the description of the described feature

• FeatureDescriptionSetDimensionLabels - Label set convenience function

• FeatureDescriptionSetLabel - Set the name of a particular feature label

• FeatureDescriptionSetLabels - Set the labels of the described feature

• FeatureDescriptionSetName - Set the name of the described feature

• FeatureDescriptionSetUnits - Set the units of a described feature

• FeatureDimension - Measure the object’s dimensions

• FeatureExcessKurtosis - Undocumented measurement function

• FeatureFeret - Measure the object’s Feret diameters

• FeatureGinertia - Measure the object’s inertia

• FeatureGmu - Measure the object’s inertia

• FeatureGravity - Measure the object’s gravity

• FeatureInertia - Measure the object’s inertia

• FeatureLongestChaincodeRun - Undocumented measurement function


DIPlib function reference 31

• FeatureMass - Measure the mass of the object (sum of grey-values)

• FeatureMaximum - Measure the object’s maximum coordinate value

• FeatureMaxVal - Measure the object’s maximum intensity

• FeatureMean - Measure the object’s mean intensity

• FeatureMinimum - Measure the object’s minimum coordinate value

• FeatureMinVal - Measure the object’s minimum intensity

• FeatureMu - Measure the object’s inertia

• FeatureOrientation2D - Undocumented measurement function

• FeatureP2A - Measure the circularity of the object

• FeaturePerimeter - Measure the object’s perimeter length

• FeatureShape - Measure shape parameters of the object

• FeatureSize - Measure the object’s size

• FeatureSkewness - Undocumented measurement function

• FeatureStdDev - Measure the standard deviation of the object’s intensity

• FeatureSum - Measure the sum of the grey values of the object

• FeatureSurfaceArea - Measure the area of the object’s surface

• GetObjectLabels - Lists object labels in image

• Label - Label a binary image

• Measure - Measure object features

• MeasurementFeatureConvert - Convert the data of a measurement feature

• MeasurementFeatureDescription - Measurement Description access function

• MeasurementFeatureFormat - Feature data format convenience function

• MeasurementFeatureLabels - Measurement Labels access function

• MeasurementFeatureRegister - Register a measurement function

• MeasurementFeatureRegistryFeatureDescription - Get the feature description of a


registered measurement feature

• MeasurementFeatureRegistryGet - Get the registry information of a measurement


feature

• MeasurementFeatureRegistryList - Obtain a list of the registered measurement


features
32 Chapter 1. Indices of functions by subject

• MeasurementFeatures - Get the measurement ID array

• MeasurementFeatureSize - Feature data convenience function

• MeasurementFeatureValid - Verify a measurement feature ID

• MeasurementForge - Allocate the data of a measurement data structure

• MeasurementFree - Free a measurement data structure

• MeasurementGetName - Get the name of a Measurement structure

• MeasurementGetPhysicalDimensions - Get the physical dimensions info of a


measurement

• MeasurementID - Get the ID of a Measurement structure

• MeasurementIsValid - Checks whether a measurement is valid

• MeasurementNew - Create new measurement data structure

• MeasurementNumberOfFeatures - Get the number of measurement feature IDs

• MeasurementNumberOfObjects - Get the number of object IDs

• MeasurementObjectData - Object data access function

• MeasurementObjects - Get an object ID array

• MeasurementObjectValid - Verify an object ID

• MeasurementObjectValue - Object value access function

• MeasurementSetName - Set the name of a measurement structure

• MeasurementSetPhysicalDimensions - Set the physical dimensions info of the


measurement

• MsrComposeFunction - Measurement compose function

• MsrConvertFunction - Measurement convert function

• MsrCreateFunction - Measurement create function

• MsrDescriptionFunction - Measurement feature description function

• MsrMeasureFunction - Measurement measure function

• MsrValueFunction - Measurement value function

• ObjectToMeasurement - Convert object label value to measurement value

• PhysicalDimensionsCopy - Copy a Physical Dimensions

• PhysicalDimensionsFree - Free a Physical Dimensions data structure


DIPlib function reference 33

• PhysicalDimensionsIsIsotropic - Checks if the Physical Dimensions are isotropic

• PhysicalDimensionsNew - Allocates a new Physical Dimensions structure

• SmallObjectsRemove - Remove small objects from an image

1.4.12 Functions for Microscopy

• AttenuationCorrection - Attenuation correction algorithm

• ExponentialFitCorrection - Exponential fit based attenuation correction

• IncoherentOTF - Generates an incoherent OTF

• IncoherentPSF - Generates an incoherent PSF

• SimulatedAttenuation - Simulation of the attenuation process


Chapter 2

Function reference

34
DIPlib function reference 35

Abs
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Abs ( in, out )

DATA TYPES

binary, integer, integer, float, complex

FUNCTION

Computes the absolute value of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Ceil, Floor, Sign, Truncate, Fraction, NearestInt


36 Chapter 2. Function reference

Acos
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Acos ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the arc cosine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Atan, Atan2, Sinh, Cosh, Tanh


DIPlib function reference 37

AdaptiveBanana
Performs Gaussian filtering steered by paramter images

SYNOPSIS

#include "dip adaptive.h"


dip Error DIP TPI FUNC(dip AdaptiveBanana)( in, out, para images, curv image,
filterSize, order, truncation )

DATA TYPES

sfloat

FUNCTION

This function performs Gaussian filtering steerd by the information stored in the paramter
images (local orientation) and in the curvature image. The meaning of the parameter
images depends on the dimensionality of the input image. Up to now only 2 and 3D images
are supported for adaptive filtering. If the input image is not of type float it is converted to
that type.
para images: ImageArray containing orientation images.
2D: angle of the orientation.
3D: polar coordinate phi, theta for intrinsic 1D structures polar coordinates of two
orientations for intrinsic 2D structures.
filterSize: Array containing the sigmas of the derivatives.
For intrinsic 1D structures, the first value is along the contour, the second perpendicular to
it.
For intrinsic 2D structures, the first two are in the plane, whereas the other is perpendicular
to them. If a value is zero no convolution is done is this direction.
38 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip ImageArray para images Parameter images
dip Image curv Curvature image
dip FloatArray filterSize Size of the filter
dip IntegerArray order Order of the Gaussian derivative
dip int truncation Truncation of the Gaussian

SEE ALSO

AdaptivePercentile, AdaptiveGauss, Gauss

LITERATURE

P. Bakker, “Image structure analysis for seismic interpretation”, PhD Thesis, TU Delft, The
Netherlands, 2001
L. Haglund, Adaptive Mulitdimensional Filtering”, PhD Thesis, Link”oping University,
Sweden, 1992
W.T. Freeman,“ Steerable Filters and Local Analysis of Image Structure”, PhD Thesis,
MIT, USA, 1992
DIPlib function reference 39

AdaptiveGauss
Performs Gaussian filtering steered by paramter images

SYNOPSIS

#include "dip adaptive.h"


dip Error dip AdaptiveGauss( in,out,para images,filterSize,order,truncation )

DATA TYPES

sfloat

FUNCTION

This function performs Gaussian filtering steerd by the information stored in the paramter
images. The meaning of the parameter images depends on the dimensionality of the input
image. Up to now only 2 and 3D images are supported for adaptive filtering. If the input
image is not of type float it is converted to that type.
para images: ImageArray containing orientation images.
2D: angle of the orientation
3D: polar coordinate phi, theta for intrinsic 1D structures polar coordinates of two
orientations for intrinsic 2D structures
filterSize: Array containing the sigmas of the derivatives.
For intrinsic 1D structures, the first value is along the contour, the second perpendicular to
it.
For intrinsic 2D structures, the first two are in the plane, whereas the other is perpendicular
to them. If a value is zero no convolution is done is this direction.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip ImageArray para images Parameter images
dip FloatArray filterSize Size of the filter
dip IntegerArray order Order of the Gaussian derivative
dip int truncation Truncation of the Gaussian
40 Chapter 2. Function reference

SEE ALSO

AdaptivePercentile, AdaptiveBanana, Gauss

LITERATURE

P. Bakker, “Image structure analysis for seismic interpretation”, PhD Thesis, TU Delft, The
Netherlands, 2001
L. Haglund, Adaptive Mulitdimensional Filtering”, PhD Thesis, Link”oping University,
Sweden, 1992
W.T. Freeman,“ Steerable Filters and Local Analysis of Image Structure”, PhD Thesis,
MIT, USA, 1992
DIPlib function reference 41

AdaptivePercentile
Performs Percentile filtering steered by paramter images

SYNOPSIS

#include "dip adaptive.h"


dip Error DIP TPI FUNC(dip AdaptivePercentile)( in, out, para images,
filterSize, precentile )

DATA TYPES

sfloat

FUNCTION

This function performs percentile filtering steerd by the information stored in the paramter
images (local orientation). The meaning of the parameter images depends on the
dimensionality of the input image. Up to now only 2 and 3D images are supported for
adaptive filtering. If the input image is not of type float it is converted to that type.
para images: ImageArray containing orientation images.
2D: angle of the orientation.
3D: polar coordinate phi, theta for intrinsic 1D structures polar coordinates of two
orientations for intrinsic 2D structures.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip ImageArray para images Parameter images
dip FloatArray filterSize Size of the filter
dip float percentile Percentile value

SEE ALSO

AdaptiveBanana, AdaptiveGauss, PercentileFilter, MedianFilter


42 Chapter 2. Function reference

LITERATURE

P. Bakker, “Image structure analysis for seismic interpretation”, PhD Thesis, TU Delft, The
Netherlands, 2001
L. Haglund, Adaptive Mulitdimensional Filtering”, PhD Thesis, Link”oping University,
Sweden, 1992
W.T. Freeman,“ Steerable Filters and Local Analysis of Image Structure”, PhD Thesis,
MIT, USA, 1992
DIPlib function reference 43

Add
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Add ( in1, in2, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in1 + in2 on a pixel by pixel basis. The data types of the
in1 and in2 image may be of different types. See Information about dyadic operations for
more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div,


DivFloat, DivComplex
44 Chapter 2. Function reference

AddComplex
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip AddComplex ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in + constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip complex constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div, DivFloat,
DivComplex
DIPlib function reference 45

AddFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip AddFloat ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in + constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip float constant Constant
dip Image out Output

SEE ALSO

Add, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div, DivFloat,
DivComplex
46 Chapter 2. Function reference

And
logic operation

SYNOPSIS

#include "dip math.h"


dip Error dip And ( in1, in2, out )

DATA TYPES

binary, integer

FUNCTION

The function And performs the logic AND operation between the corresponding pixels in
in1 and in2, and stores the result in out.

ARGUMENTS

Data type Name Description


dip Image in1 First binary input image
dip Image in2 Second binary input image
dip Image out Output image

SEE ALSO

Xor, Or, Invert


DIPlib function reference 47

AreaOpening
Morphological filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip AreaOpening ( grey, mask, out, filtersize, connectivity,
closing )

DATA TYPES

integer, float

FUNCTION

The image grey will be filtered to remove local maxima (closing is DIP FALSE) or local
minima (closing is DIP TRUE) with an area smaller than filtersize (in pixels).
Theoretically, the area opening can be written as the supremum of all the openings with
each of the possible compact structuring elements of filtersize pixels. The connectivity
parameter indicates which shapes are considered compact (i.e. all pixels are connected). See
The connectivity parameter for more information.

ARGUMENTS

Data type Name Description


dip Image grey Grey-value input image
dip Image mask Mask image for ROI processing
dip Image out Output image
dip int filtersize Size of structuring element
dip int connectivity Connectivity
dip Boolean closing DIP FALSE for area opening, DIP TRUE for area closing.

SEE ALSO

Opening, Closing, MorphologicalReconstruction


48 Chapter 2. Function reference

ArrayFree
Array free function

SYNOPSIS

dip Error dip ArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip Array * array pointer to a dip Array

SEE ALSO

ArrayNew, ArrayFree
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 49

ArrayNew
Array allocation function

SYNOPSIS

dip Error dip ArrayNew ( array, size, elementSize, resources )

FUNCTION

This functions allocates the size elements of a dip Array and sets the size of the array to
size. The size of each element is determined by elementSize.

ARGUMENTS

Data type Name Description


dip Array * array Array
dip int size Size
dip int elementSize ElementSize
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

ArrayNew, ArrayFree
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
50 Chapter 2. Function reference

Asin
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Asin ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the arc sine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Acos, Atan, Atan2, Sinh, Cosh, Tanh


DIPlib function reference 51

Atan
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Atan ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the arc tangent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan2, Sinh, Cosh, Tanh


52 Chapter 2. Function reference

Atan2
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Atan2 ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function computes out = atan2(in1 , in2) on a pixel by pixel basis. The data types of
the in1 and in2 image may be of different types. See Information about dyadic operations
for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh


DIPlib function reference 53

AttenuationCorrection
Attenuation correction algorithm

SYNOPSIS

#include "dip microscopy.h"


dip Error dip AttenuationCorrection ( in, out, fAttenuation, bAttenuation,
background, threshold, NA, refIndex, ratio, method )

DATA TYPES

binary, integer, float

FUNCTION

This function implements an attenuation correction using three different recursive


attenuation correction algorithms. The RAC-DET algorithm is the most accurate one, since
it takes both forward and backward attenuation into account. It is however considerably
slower that the RAC-LT2 and RAC-LT1 algorithms which take only forward attenuation
into account. These last two algorithms assume a constant attenuation (background) for
pixels with an intensity lower than the threshold.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float fAttenuation Forward attenuation factor
dip float bAttenuation Backward attenuation factor
dip float background Background attenuation factor
dip float threshold Background threshold
dip float NA Numerical aperture
dip float refIndex Refractive index
dip float ratio Z/X sampling ratio
dipf AttenuationCorrection method Correction method
The dipf AttenuationCorrection enumaration consists of the following flags:
54 Chapter 2. Function reference

Name Description
DIP ATTENUATION RAC LT2 Recursive Attenuation Correction algorithm using two Light
Cone convolutions
DIP ATTENUATION RAC LT1 Recursive Attenuation Correction algorithm using one Light
Cone convolution
DIP ATTENUATION RAC DET Recursive Attenuation Correction algorithm using
Directional Extinction Tracking

LITERATURE

K.C. Strasters, H.T.M. van der Voort, J.M. Geusebroek, and A.W.M. Smeulders, Fast
attenuation correction in fluorescence confocal imaging: a recursive approach, BioImaging,
vol. 2, no. 2, 1994, 78-92.

AUTHOR

Karel Strasters, adapted to DIPlib by Geert van Kempen.

SEE ALSO

SimulatedAttenuation, ExponentialFitCorrection
DIPlib function reference 55

BesselJ0
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselJ0 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function J0 of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ1, BesselJN, BesselY0, BesselY1, BesselYN, LnGamma, Erf, Erfc, Sinc


56 Chapter 2. Function reference

BesselJ1
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselJ1 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function J1 of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJN, BesselY0, BesselY1, BesselYN, LnGamma, Erf, Erfc, Sinc


DIPlib function reference 57

BesselJN
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselJN ( in, out, n )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function J of the order n of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int n Order of the Bessel function

SEE ALSO

BesselJ0, BesselJ1, BesselY0, BesselY1, BesselYN, LnGamma, Erf, Erfc, Sinc


58 Chapter 2. Function reference

BesselY0
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselY0 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function Y0 of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY1, BesselYN, LnGamma, Erf, Erfc, Sinc


DIPlib function reference 59

BesselY1
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselY1 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function Y1 of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselYN, LnGamma, Erf, Erfc, Sinc


60 Chapter 2. Function reference

BesselYN
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip BesselYN ( in, out, n )

DATA TYPES

binary, integer, float

FUNCTION

Computes the Bessel function Y of the order n of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int n Order of the Bessel function

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselY1, LnGamma, Erf, Erfc, Sinc


DIPlib function reference 61

BiasedSigma
Adaptive edge sharpening & contrast enhancing filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip BiasedSigma ( in, out, se, boundary, filterSize, shape, sigma,
outputCount )

DATA TYPES

integer, float

FUNCTION

The Biased Sigma filter is an adaptive edge sharpening and contrast enhancing filter. Its
operation differs from the Sigma filter by separating the averaging the pixels with an
intensities higher than the pixel being filtered, from the pixels with lower intensities. The
absolute difference of these two averages with the value of the pixel being filtered. The value
of this pixel is being replaced by the average with the smallest difference. If outputCount is
DIP TRUE, the output values represent the number of pixel over which the average has been
calculated. When threshold is DIP TRUE, the pixel intensities are being thresholded at +/-
2 sigma, when it is set to DIP FALSE, the intensities are weighted with the Gaussian
difference with the intensity of the central pixel.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterSize Filter sizes
dip FilterShape shape Filter shape
dip float sigma Sigma
dip Boolean outputCount Output the Count
The enumerator dip FilterShape contains the following constants:
62 Chapter 2. Function reference

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

LITERATURE

John-Sen Lee, Digital Image Smoothing and the Sigma Filter, Computer Vision, Graphics
and Image Processing, 24, 255-269, 1983

SEE ALSO

Sigma, GaussianSigma
DIPlib function reference 63

BinaryClosing
Binary morphological closing operation

SYNOPSIS

#include "dip binary.h"


dip Error dip BinaryClosing ( in, out, connectivity, iterations, edge )

DATA TYPES

binary

FUNCTION

The connectivity parameter defines the metric, that is, the shape of the structuring
element. 1 indicates city-block metric, or a diamond-shaped structuring element. 2 indicates
chessboard metric, or a square structuring element. -1 and -2 indicate alternating
connectivity and produce an octagonal structuring element. See The connectivity parameter
for more information. The edge parameter specifies whether the border of the image should
be treated as object (DIP TRUE) or as background (DIP FALSE). Additionally, you can set it
to -1 for special handling: DIP FALSE for the dilation, DIP TRUE for the erosion; this avoids
the border effect you can get in the corners of the image in some cases.
See section 9.6, “Morphology-based operations”, in “Fundamentals of Image Processing” for
a description of binary mathematical morphology operations.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int connectivity Connectivity
dip int iterations Iterations
dip int edge Edge condition

KNOWN BUGS

This function is only implemented for images with a dimension up to three.


64 Chapter 2. Function reference

SEE ALSO

BinaryDilation, BinaryErosion, BinaryOpening, BinaryPropagation


DIPlib function reference 65

BinaryDilation
Binary morphological dilation operation

SYNOPSIS

#include "dip binary.h"


dip Error dip BinaryDilation ( in, out, connectivity, iterations, edge )

DATA TYPES

binary

FUNCTION

The connectivity parameter defines the metric, that is, the shape of the structuring
element. 1 indicates city-block metric, or a diamond-shaped structuring element. 2 indicates
chessboard metric, or a square structuring element. -1 and -2 indicate alternating
connectivity and produce an octagonal structuring element. See The connectivity parameter
for more information. The edge parameter specifies whether the border of the image should
be treated as object (DIP TRUE) or as background (DIP FALSE).
See section 9.6, “Morphology-based operations”, in “Fundamentals of Image Processing” for
a description of binary mathematical morphology operations.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int connectivity Connectivity
dip int iterations Iterations
dip Boolean edge Edge pixels on

KNOWN BUGS

This function is only implemented for images with a dimension up to three.

SEE ALSO

BinaryErosion, BinaryClosing, BinaryOpening, BinaryPropagation


66 Chapter 2. Function reference

BinaryErosion
Binary morphological erosion operation

SYNOPSIS

#include "dip binary.h"


dip Error dip BinaryErosion ( in, out, connectivity, iterations, edge )

DATA TYPES

binary

FUNCTION

The connectivity parameter defines the metric, that is, the shape of the structuring
element. 1 indicates city-block metric, or a diamond-shaped structuring element. 2 indicates
chessboard metric, or a square structuring element. -1 and -2 indicate alternating
connectivity and produce an octagonal structuring element. See The connectivity parameter
for more information. The edge parameter specifies whether the border of the image should
be treated as object (DIP TRUE) or as background (DIP FALSE).
See section 9.6, “Morphology-based operations”, in “Fundamentals of Image Processing” for
a description of binary mathematical morphology operations.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int connectivity Connectivity
dip int iterations Iterations
dip Boolean edge Edge condition

KNOWN BUGS

This function is only implemented for images with a dimension up to three.

SEE ALSO

BinaryDilation, BinaryClosing, BinaryOpening, BinaryPropagation


DIPlib function reference 67

BinaryImageToPixelTable
Convert a binary image to a pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip BinaryImageToPixelTable ( im, table, resources)

DATA TYPES

binary

FUNCTION

This functions converts a binary image to a new allocated pixel table table.

ARGUMENTS

Data type Name Description


dip Image im Binary image
dip PixelTable * table Pixel table
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableToBinaryImage, PixelTableCreateFilter
68 Chapter 2. Function reference

BinaryNoise
Generates an image disturbed by binary noise

SYNOPSIS

#include "dip noise.h"


dip Error dip BinaryNoise ( in, out, p10, p01, random )

DATA TYPES

binary

FUNCTION

Generate an image disturbed by binary noise.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float p10 Probability of a one to zero transition
dip float p01 Probability of a one to zero transition
dip Random * random Pointer to a random value structure

EXAMPLE

Get a binary noise disturbed image as follows:

dip_Image in, out;


dip_float p10, p01;
dip_Random random;

p10 = 0.1;
p01 = 0.2;
DIPXX( dip_BinaryNoise(in, out, p10, p01, &random ));

SEE ALSO

RandomVariable, RandomSeed, UniformNoise, GaussianNoise, PoissonNoise


DIPlib function reference 69

BinaryOpening
Binary morphological opening operation

SYNOPSIS

#include "dip binary.h"


dip Error dip BinaryOpening ( in, out, connectivity, iterations, edge )

DATA TYPES

binary

FUNCTION

The connectivity parameter defines the metric, that is, the shape of the structuring
element. 1 indicates city-block metric, or a diamond-shaped structuring element. 2 indicates
chessboard metric, or a square structuring element. -1 and -2 indicate alternating
connectivity and produce an octagonal structuring element. See The connectivity parameter
for more information. The edge parameter specifies whether the border of the image should
be treated as object (DIP TRUE) or as background (DIP FALSE). Additionally, you can set it
to -1 for special handling: DIP TRUE for the erosion, DIP FALSE for the dilation; this avoids
the border effect you can get in the corners of the image in some cases.
See section 9.6, “Morphology-based operations”, in “Fundamentals of Image Processing” for
a description of binary mathematical morphology operations.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int connectivity Connectivity
dip int iterations Iterations
dip int edge Edge condition

KNOWN BUGS

This function is only implemented for images with a dimension up to three.


70 Chapter 2. Function reference

SEE ALSO

BinaryDilation, BinaryErosion, BinaryClosing, BinaryPropagation


DIPlib function reference 71

BinaryPropagation
Morphological propagation of binary objects

SYNOPSIS

#include "dip binary.h"


dip Error dip BinaryPropagation ( seed, mask, out, connectivity, iterations,
edge )

DATA TYPES

binary

FUNCTION

The connectivity parameter defines the metric, that is, the shape of the structuring
element. 1 indicates city-block metric, or a diamond-shaped structuring element. 2 indicates
chessboard metric, or a square structuring element. -1 and -2 indicate alternating
connectivity and produce an octagonal structuring element. See The connectivity parameter
for more information. The edge parameter specifies whether the border of the image should
be treated as object (DIP TRUE) or as background (DIP FALSE).
See section 9.6, “Morphology-based operations”, in “Fundamentals of Image Processing” for
a description of binary mathematical morphology operations, and section 10.3,
“Segmentation”, for applications of binary propagation.

ARGUMENTS

Data type Name Description


dip Image seed Input seed
dip Image mask Input mask
dip Image out Output
dip int connectivity Connectivity
dip int iterations (0) Iterations
dip Boolean edge Edge condition

KNOWN BUGS

This function is only implemented for images with a dimension up to three.


72 Chapter 2. Function reference

SEE ALSO

BinaryDilation, BinaryErosion, BinaryClosing, BinaryOpening, EdgeObjectsRemove,


GrowRegions
DIPlib function reference 73

BinaryRandomVariable
Binary random variable generator

SYNOPSIS

#include "dip noise.h"


dip Error dip BinaryRandomVariable ( random, input, p10, p01, output )

FUNCTION

The binary random variable is generated by altering the input value, if the value of a
generated random variable is higher than the p10 probability, if input is DIP TRUE, or
higher than p01 otherwise.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip Boolean input Input
dip float p10 Probability of a one to zero transition
dip float p01 Probability of a one to zero transition

EXAMPLE

Get a binary random variable as follows:

dip_Random random;
dip_float p10, p01, value;

p10 = 0.1;
p01 = 0.2;
DIPXX( dip_BinaryRandomVariable( &random, 1, p10, p01, &value));

SEE ALSO

RandomVariable, RandomSeed, UniformRandomVariable, GaussianRandomVariable,


PoissonRandomVariable
74 Chapter 2. Function reference

BooleanArrayCopy
Copy an array

SYNOPSIS

dip Error dip BooleanArrayCopy ( dest, src, resources )

FUNCTION

This function copies the boolean array src to dest. The array dest is created by this
function as well.

ARGUMENTS

Data type Name Description


dip BooleanArray * dest Destination array
dip BooleanArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

BooleanArrayNew, BooleanArrayFree, BooleanArrayCopy, BooleanArrayFind


IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
DIPlib function reference 75

BooleanArrayFind
Find value in array

SYNOPSIS

dip Error dip BooleanArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
BooleanArrayFind will produce an error if value is not found, otherwise found obtains the
search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip BooleanArray array Array to find value in
dip Boolean value Value to find
dip int * index Index of the found value
dip Boolean * found Value found or not

SEE ALSO

BooleanArrayNew, BooleanArrayFree, BooleanArrayCopy, BooleanArrayFind


IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
76 Chapter 2. Function reference

BooleanArrayFree
Array free function

SYNOPSIS

dip Error dip BooleanArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip BooleanArray * array Array

SEE ALSO

VoidPointerArrayNew, VoidPointerArrayFree, VoidPointerArrayCopy,


VoidPointerArrayFind
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 77

BooleanArrayNew
Array allocation function

SYNOPSIS

dip Error dip BooleanArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip BooleanArray and sets the size of the
array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip BooleanArray * array Array
dip int size Size
dip Boolean value Initial value
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

BooleanArrayNew, BooleanArrayFree, BooleanArrayCopy, BooleanArrayFind


ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
78 Chapter 2. Function reference

BoundaryArrayFree
Array free function

SYNOPSIS

dip Error dip BoundaryArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip BoundaryArray * array Boundary conditions

SEE ALSO

BoundaryArrayNew, BoundaryArrayFree
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 79

BoundaryArrayNew
Array allocation function

SYNOPSIS

dip Error dip BoundaryArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip BoundaryArray and sets the size of the
array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip BoundaryArray * array Boundary conditions
dip int size Size
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

BoundaryArrayNew, BoundaryArrayFree
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
80 Chapter 2. Function reference

Ceil
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Ceil ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the ceil of the input image values, and outputs a signed integer typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Floor, Sign, Truncate, Fraction, NearestInt


DIPlib function reference 81

ChangeDataType
Change the data type of an image

SYNOPSIS

dip Error dip ChangeDataType( example, target, dataType )

FUNCTION

Inherit all properties of the input image except the data type. The data type is explicitly
specified through dataType. When dataType is zero, the data type of the output image is
not modified. The example image may be either “raw” or “forged”.

ARGUMENTS

Data type Name Description


dip Image example An example image
dip Image target The target image
dip DataType dataType The data type

SEE ALSO

DIPlib’s data types


ImageCopyProperties, ImageAssimilate, ChangeTo0d
82 Chapter 2. Function reference

ChangeDimensions
Changes the order of the dimensions in an image

SYNOPSIS

dip Error dip ChangeDimensions( image, neworder )

FUNCTION

Re-orders the dimensions in an image, optionally removing singleton dimensions (those


dimensions with size 1), without copying the data. neworder is a list of the dimension
numbers in the new order, for example (2,1,3) will swap the first two dimensions. Setting
neworder to 0 removes all singleton dimensions without altering the order. This is useful,
for example, after calling a function such as Maximum to compute a maximum projection
over one dimension. The output image keeps the dimensionality of the input image, and
thus has a singleton dimension.

ARGUMENTS

Data type Name Description


dip Image image The image to modify
dip IntegerArray neworder The new order of the dimensions

SEE ALSO

The image structure


ImageGetDimensions, ImageSetDimensions, ImageGetStride
DIPlib function reference 83

ChangeTo0d
Make an image zero dimensional

SYNOPSIS

dip Error dip ChangeTo0d( example, target, dataType )

FUNCTION

Inherit all properties of the input image except the data type and the dimensionality. The
data type is explicitly specified through dataType. When dataType is zero, the data type of
the output image is not modified. The dimensionality is set to zero. The example image
may be either “raw” or “forged”.

ARGUMENTS

Data type Name Description


dip Image example An example image
dip Image target The target image
dip DataType dataType The data type. See DIPlib’s data types

SEE ALSO

ImageCopyProperties, ImageAssimilate, ChangeDataType


84 Chapter 2. Function reference

ChordLength
Compute the chord lengths of the different phases

SYNOPSIS

#include "dip analysis.h"


dip Error dip ChordLength ( object, mask, dist, probes, length, sampling )

DATA TYPES

binary, integer

FUNCTION

This function computes the chord lengths of the different phases in object. If object is a
binary image, the image is a regarded as a two phase image. In case object is of the integer
type, the image is regarded as a labeled image, with each integer value encoding a phase.
Optionally a mask image can be provided so select which pixels in object should be used to
compute the chord lengths. The probes variable specifies how many random point pairs
should be drawn to compute the lengths. Length specifies the maximum correlation length.
The chord length can be computed using a random of grid method, as specified by
sampling.

ARGUMENTS

Data type Name Description


dip Image object Object image
dip Image mask Mask image
dip Distribution dist Ouput distribution
dip int probes Number of probes
dip int length Maximum chord length
dipf CorrelationEstimator sampling Samplings method

SEE ALSO

PairCorrelation, ProbabilisticPairCorrelation
DIPlib function reference 85

CityBlockDistanceToPoint
Distance generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip CityBlockDistanceToPoint ( output, origin, scale )

DATA TYPES

Output: sfloat

FUNCTION

Computes the cityblock distance of each pixel in the output image to a point at origin.
The coordinates of origin may lie outside the image. The scale parameter may be used to
specify the relative distance between pixels in each dimension.

ARGUMENTS

Data type Name Description


dip Image output Output Image
dip FloatArray origin Origin
dip FloatArray scale Relative scale of the pixel distances for each dimension

SEE ALSO

EllipticDistanceToPoint, EuclideanDistanceToPoint
86 Chapter 2. Function reference

Clip
Point operation

SYNOPSIS

#include "dip point.h"


dip Error dip Clip ( in, out, clipLow, clipHigh, clipFlag )

DATA TYPES

integer, float

FUNCTION

Clips in at either the minimum value clipLow of the maximum value clipHigh or both. If
the flag DIP CLIP THRESHOLD AND RANGE is specified, the clip bound are defined by clipLow
+/- clipHigh/2.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float clipLow Lower clip bound value
dip float clipHigh Higher clip bound value
dipf Clip clipFlag Clip flag
The following dipf Clip flags are defined:
Name Description
DIP CLIP BOTH clip both the lower and upper bound
DIP CLIP LOW clip lower bound only
DIP CLIP HIGH clip upper bound only
DIP CLIP THRESHOLD AND RANGE use clipLow and clipHigh as threshold and range
value
DIP CLIP LOW AND HIGH BOUNDS same as DIP CLIP BOTH

SEE ALSO

Threshold, RangeThreshold, ErfClip, ContrastStretch


DIPlib function reference 87

Closing
Morphological closing operation

SYNOPSIS

#include "dip morphology.h"


dip Error dip Closing ( in, out, se, boundary, filterParam, shape )

DATA TYPES

integer, float, binary

FUNCTION

Grey-value closing with different structuring elements.


The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
88 Chapter 2. Function reference

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

SEE ALSO

Opening, Dilation, Erosion


DIPlib function reference 89

Colour2Gray
Convert ND image with colour information to a (n-1)D grayvalue image (in dipIO)

SYNOPSIS

#include "dipio tools.h"


dip Error dipio Colour2Gray ( in, out, photometric )

FUNCTION

This function converts a colour image, as read by ImageReadColour, to a grayvalue


intensity image. in is expected to contain the colour information along the last axis. out
will be a scalar image with one less dimension than the input.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dipio PhotometricInterpretation photometric Photometric interpretation
The enumerator dipio PhotometricInterpretation contains the following constants:
90 Chapter 2. Function reference

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

KNOWN BUGS

Some colourspaces are not converted correctly. R’G’B’ (DIPIO PHM RGB NONLINEAR), is
treated like RGB. From a CIE Lab (DIPIO PHM CIELAB) or Luv (DIPIO PHM CIELUV) the
luminosity channel is extracted, which is also a non-linear conversion away from the
intensity. From HCV (DIPIO PHM HCV) and HSV (DIPIO PHM HSV) the value channel is
extracted, which again is a non-linear conversion away from the intensity. CMYK
(DIPIO PHM CMYK) and CMY (DIPIO PHM CMY) conversion is not implemented. Specifying
these values will result in an error.

SEE ALSO

ImageRead, ImageReadColour, ImageReadROI


DIPlib function reference 91

Compare
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip Compare ( in1, in2, out, selector )

DATA TYPES

binary, integer, float

FUNCTION

This function can perform various pixel-by-pixel comparisons (smaller, smaller- equal, equal,
not equal, greater-equal, greater) between in1 ans in2. out contains the binary result. This
is implemented with a call to Select whose in3 and in4 are set to binary true and false,
respectively.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to the functionality of Threshold, but with more options.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output
dipf Select selector Select flag
Name Description
DIP SELECT LESSER <, Lesser than
DIP SELECT LESSER EQUAL <=, Lesser or equal
DIP SELECT NOT EQUAL !=, Unequal
DIP SELECT EQUAL ==, Equal
DIP SELECT GREATER EQUAL >=, Greater or equal
DIP SELECT GREATER >, Greater
92 Chapter 2. Function reference

SEE ALSO

Select, Threshold, Equal, Greater, Lesser, NotEqual, NotGreater, NotLesser,


SelectValue, NotZero
DIPlib function reference 93

ComplexArrayCopy
Copy an array

SYNOPSIS

dip Error dip ComplexArrayCopy ( dest, src, resources )

FUNCTION

This function copies the complex array src to dest. The array dest is created by this
function as well.

ARGUMENTS

Data type Name Description


dip ComplexArray * dest Destination array
dip ComplexArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

ComplexArrayNew, ComplexArrayFree, ComplexArrayCopy, ComplexArrayFind


IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
94 Chapter 2. Function reference

ComplexArrayFind
Find value in array

SYNOPSIS

dip Error dip ComplexArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
ComplexArrayFind will produce an error if value is not found, otherwise found obtains the
search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip ComplexArray array Array to find value in
dip complex value Value to find
dip int * index Index of the found value
dip Boolean * found Value found or not

SEE ALSO

ComplexArrayNew, ComplexArrayFree, ComplexArrayCopy, ComplexArrayFind


IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
DIPlib function reference 95

ComplexArrayFree
Array free function

SYNOPSIS

dip Error dip ComplexArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip ComplexArray * array Array

SEE ALSO

ComplexArrayNew, ComplexArrayFree, ComplexArrayCopy, ComplexArrayFind


ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
96 Chapter 2. Function reference

ComplexArrayNew
Array allocation function

SYNOPSIS

dip Error dip ComplexArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip ComplexArray and sets the size of the
array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip ComplexArray * array Array
dip int size Size
dip complex value Initial value
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

ComplexArrayNew, ComplexArrayFree, ComplexArrayCopy, ComplexArrayFind


ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
DIPlib function reference 97

ContrastStretch
Point operation

SYNOPSIS

#include "dip point.h"


dip Error dip ContrastStretch ( in, out, lowerBound, upperBound, outMaximum,
outMinimum, method, sigmoidSlope, sigmoidPoint, maxDecade )

DATA TYPES

integer, float

FUNCTION

ContrastStretch stretches the pixel values of the input image. Pixel values higher or equal
to UpperBound are stretched to the OutMaximum value. A similar thing holds for
LowerBound and OutMinimum. Method determines how pixel values are stretched.
SigmoidSlope and SigmoidPoint are used by the DIP CST SIGMOID method. MaxDecade
determines the maximum number of decades the method DIP CST DECADE will stretch
(values lower than MaxDecade will be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float lowerBound LowerBound (%)
dip float upperBound UpperBound (%)
dip float outMax OutMaximum
dip float outMin OutMinimum
dipf ContrastStretch method Method
dip float sigmoidSlope SigmoidSlope
dip float sigmoidPoint SigmoidPoint
dip float maxDecade MaxDecade
The following dipf ContrastStretch flags are defined:
98 Chapter 2. Function reference

Name Description
DIP CST LINEAR linear contrast stretch
DIP CST SIGNED LINEAR linear stretch with zero at fixed value
DIP CST LOGARITHMIC logarithmic contrast stretch
DIP CST SIGNED LOGARITHMIC signed logarithmic contrast stretch
DIP CST ERF linear contrast stretch with erf clipping
DIP CST DECADE Decade contrast stretching
DIP CST SIGMOID Contrast stretched by sigmoid function
DIP CST CLIP Simple clipping
DIP CST 01 Stretching of [0,1] input values
DIP CST PI Stretching of [-Pi,Pi] input values
In the explanaition of the different contrast stretch flags, the variables input, output,
inMin, inMax, outMin and outMax are used. With input and output is meant the pixel
being processed of respecitively the input and output image. inMin and inMax are the pixel
values corresponding to the lowerBound and upperBound of the input image. outMin and
outMax are parameters passed to the function dip ContrastStretch.
The DIP CST LINEAR stretches the input in the following way:

scale = (outMax - outMin) / (inMax - inMin)


output = scale * (MIN(inMax, MAX(inMin, input )) - inMin) + outMin

The DIP CST SIGNED LINEAR stretches the input in the following way:

max = MAX(inMax, ABS( inMin ));


scale = (outMax - outMin) / (2 * max)
offset = (outMax - outMin)/ 2
output = scale * (MIN(inMax, MAX(inMin, input)) - offset) + outMin

The DIP CST LOGARITHMIC stretches the input in the following way:

scale = (outMax - outMin) / log( inMax - inMin + 1)


offset = inMin - 1
output = scale * log(MIN(inMax, MAX(inMin, input)) - offset) + outMin

The DIP CST SIGNED LOGARITHMIC stretches the input in the following way:

max = MAX(inMax, ABS( inMin ))


scale = (outMax - outMin) / (2 * log( max + 1))
offset = (outMax + outMin)/ 2
output = scale * log(MIN(inMax, MAX(inMin, input))- offset) + outMin

The DIP CST ERF stretches the input in the following way:

scale = (outMax - outMin) / (inMax - inMin)


DIPlib function reference 99

threshold = (inMax + inMin)/ 2


range = inMax - inMin
in = MIN(inMax, MAX(inMin, input))
out = (range / 2) * erf( SQRT_PI * (in - threshold) / range )
output = scale * (out + threshold ) + outMin

The DIP CST DECADE stretches the input in the following way:

inScale = inMax - inMin


outScale = outMax - outMin
in = MIN(inMax, DIP_MAX(inMin, input))
decade = log10(inScale / ( in - inMin + EPSILON))
if(decade < maxDecade)
decade -= floor(decade)
output = outScale * (1 - decade) + outMin
else
output = 0

The DIP CST SIGMOID stretches the input in the following way:

SIGMOID(x) = x / (1. + ABS(x))


min = SIGMOID(sigmoidSlope * inMin + sigmoidPoint)
max = SIGMOID(sigmoidSlope * inMax + sigmoidPoint)
scale = (outMax - outMin) /(max - min)
in = MIN(inMax, MAX(inMin, input))
output = scale * (SIGMOID(slope * in + point) - min) + outMin

The DIP CST CLIP stretches the input in the following way:

output = MIN(outMax, MAX(outMin, input))

The DIP CST 01 stretches the input in the following way:

scale = (outMax - outMin)


output = scale * input + outMin

The DIP CST 01 stretches the input in the following way:

scale = (outMax - outMin) / 2 * Pi


output = scale * (input + Pi) + outMin

SEE ALSO

See section 9.1, “Histogram-based operations”, in “Fundamentals of Image Processing”.


Clip, ErfClip
100 Chapter 2. Function reference

ConvertArray
converts the data type of an array

SYNOPSIS

#include "dip convert array.h"


dip Error DIP TWO FUNC(dip ConvertArray)( in, inStride, inPlane, out,
outStride, outPlane, number )

FUNCTION

Converts the in array to the out array.

ARGUMENTS

Data type Name Description


void * in input array
dip int inStride Stride of the input array
dip int inPlane plane number in case in is a binary array
void * out output array
dip int outStride Stride of the output array
dip int outPlane plane number in case out is a binary array
dip int number size of the arrays
DIPlib function reference 101

ConvertDataType
Converts the data type of an image

SYNOPSIS

#include "dip tpscalar.h"


dip Error dip ConvertDataType ( in, out, dataType )

FUNCTION

Convert the data type of the input data to dataType and stores the result in out.
Conversion from a complex type to another (non-complex) type, is done by taking the real
part.
Conversion to a binary type from another (non-binary) type, is done as follows; any
non-zero number becomes 1, zero becomes zero.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip DataType dataType Data type. See DIPlib’s data types
102 Chapter 2. Function reference

Convolve1d
Perform a 1D convolution

SYNOPSIS

#include "dip linear.h"


dip Error DIP TPI FUNC(dip Convolve1d)( in, out, filter, size, filterSize,
origin, flags, boundary )

DATA TYPES

integer,float

FUNCTION

This function performs a one-dimensional convolution of the input data with the given filter
kernel. In general your filter will be centered around the origin. The origin is uniquely
defined if the filter size is odd, but if the filter size is even you’ll have to specify whether the
origin of the filter lies to the left or the right. Words cannot possibly suffice here, so here is
a small pictorial representation:

filter size is odd : kernel data : x x x x x


^
0

filter size is even and


DIP_CNV_LEFT is specified : kernel data : x x x x x x
^
0

DIP_CNV_RIGHT is specified : kernel data : x x x x x x


^
0

When the filter size is even, one of the flags DIP CNV LEFT or DIP CNV RIGHT must be
specified. When the filter size is odd both flags are ignored. It is also possible to specify the
origin of the filter directly by using the DIP CNV USE ORIGIN flag in combination with the
origin parameter. Again a small pictorial representation:

0 1 2 3 4 5 6 7 8
kernel data : x x x x x x x x x when origin = 2
DIPlib function reference 103

^
0

when DIP CNV USE ORIGIN is NOT specified origin is computed as follows :

filter size odd origin = ( filterSize - 1 ) / 2


filter size even _and_
DIP_CNV_LEFT origin = ( filterSize / 2 ) - 1
DIP_CNV_RIGHT origin = filterSize / 2

The input data is copied to a temporary buffer, after which the input data is extended
according to the boundary condition specified. You can use the flags DIP CNV HAS BORDER to
indicate that the input data already has a border. In this case you must make sure that
there are enough pixels on either size of the array:

on the left : ( ( filterSize - 1 ) - origin ) pixels


on the right : ( origin ) pixels

If DIP CNV HAS BORDER is specified and in != out no auxiliary storage is used. You must
also specify the symmetry of the filter as follows:

odd filter size : a b c b a DIP_CNV_EVEN


a b c -b -a DIP_CNV_ODD
a b c d e DIP_CNV_GENERAL

even filter size : a b c c b a DIP_CNV_EVEN


a b c -c -b -a DIP_CNV_ODD
a b c d e f DIP_CNV_GENERAL

ARGUMENTS

Data type Name Description


void * in Pointer to the input data
void * out Pointer to the output data
void * filter Pointer to the filter data
dip int size Size of the input data
dip int filterSize Size of the filter
dip int origin Origin of the filter. Only valid in conjunction with
DIP CNV USE ORIGIN
dipf Convolve flags A combination of the flags described above
dip Boundary boundary One of the standard boundary conditions. See Boundary
conditions

SEE ALSO

General information about convolution


104 Chapter 2. Function reference

SeparableConvolution, SeparableFrameWork
DIPlib function reference 105

ConvolveFT
Fourier transform based convolution filter

SYNOPSIS

#include "dip linear.h"


dip Error dip ConvolveFT ( in, psf, out, inrep, psfrep, outrep )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function convolves the input image with the point spread function psf, by multiplying
their Fourier transforms. The inrep, psfrep and outrep specify whether the images are
spatial images (DIP IMAGE REPRESENTATION SPATIAL) or their Fourier transform.
(DIP IMAGE REPRESENTATION SPECTRAL).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image psf Psf image
dip Image out Output image
dipf ImageRepresentation inrep Input spatial or spectral
dipf ImageRepresentation psfrep PSF spatial or spectral
dipf ImageRepresentation outrep Output spatial or spectral

SEE ALSO

General information about convolution


106 Chapter 2. Function reference

CoordinateArrayFree
Array free function

SYNOPSIS

dip Error dip CoordinateArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip CoordinateArray * array Array

SEE ALSO

CoordinateArrayNew, CoordinateArrayFree
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 107

CoordinateArrayNew
Array allocation function

SYNOPSIS

dip Error dip CoordinateArrayNew ( array, ndims, size, resources )

FUNCTION

This function allocates the size elements of a dip CoordinateArray and sets the size of
the array to size. Each element has ndims values, to store coordinates of an
ndims-dimensional image. Each array element is initialized to 0.

ARGUMENTS

Data type Name Description


dip CoordinateArray * array Array
dip int ndims Dimensionality
dip int size Size
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

CoordinateArrayNew, CoordinateArrayFree
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
108 Chapter 2. Function reference

CoordinateToIndex
Convert coordinate to pixel index

SYNOPSIS

#include "dip coordsindx.h"


dip Error dip CoordinateToIndex ( coordinates, index, stride )

FUNCTION

This function converts a pixel coordinate to an pixel index which is specific for the image
from which stride was obtained. coordinages and stride must have the same number of
elements.

ARGUMENTS

Data type Name Description


dip IntegerArray coordinates Coordinate array
dip int * index Pointer to pixel index
dip IntegerArray stride stride array

SEE ALSO

IndexToCoordinate
DIPlib function reference 109

Cos
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Cos ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the cosine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Sinh, Cosh, Tanh
110 Chapter 2. Function reference

Cosh
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Cosh ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the hyperbolic cosine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Sinh, Tanh


DIPlib function reference 111

Crop
Remove the outer parts of an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Crop ( in, out, origin, size )

DATA TYPES

binary, integer, float, complex

FUNCTION

Crop a part of the image. The requested part is selected by specifying its upper left corner
(origin ), and its size (size ). If in has a different type than out, it will be converted to
the type of out.

ARGUMENTS

Data type Name Description


dip Image in Input Image
dip Image out Output Image
dip IntegerArray origin Coordinate in in of the upper left corner of the section
dip IntegerArray size Size of the new image

SEE ALSO

GetSlice, GetLine
112 Chapter 2. Function reference

CrossCorrelationFT
Normalized cross-correlation using the Fourier Transform

SYNOPSIS

#include "dip findshift.h"


dip Error dip CrossCorrelationFT ( in1, in2, out, in1rep, in2rep, outrep )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function calculates the cross-correlation between two images of equal size. The
returned image is the cross-correlation normalized in such a way that only the phase
information is of importance. This results as a very sharp peak in the spatial domain. This
function performs out = (Conj(in1)*in2)/((Abs(in1))^2) in the Fourier domain. It is
used by FindShift. The inrep, psfrep and outrep specify whether the images are spatial
images (DIP IMAGE REPRESENTATION SPATIAL) or their Fourier transform.
(DIP IMAGE REPRESENTATION SPECTRAL).

ARGUMENTS

Data type Name Description


dip Image in1 Input image
dip Image in2 Input image
dip Image out Output image
dipf ImageRepresentation in1rep Input 1 spatial or spectral
dipf ImageRepresentation in2rep Input 2 spatial or spectral
dipf ImageRepresentation outrep Output spatial or spectral

SEE ALSO

FindShift
DIPlib function reference 113

CumulativeSum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip CumulativeSum ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the cumulative sum of the pixel values over all those dimensions which are
specified by ps, i.e.:
out(x,y)=sum i=0:x,j=0:y in(i,j) when ps specifies both x and y out(x,y)=sum j=0:y
in(x,j) when ps specifies only y

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Mean, Variance, StandardDeviation, MeanModulus, SumModulus, MeanSquareModulus,
Maximum, Minimum, Median, Percentile
114 Chapter 2. Function reference

DanielsonLineDetector
Line detector

SYNOPSIS

#include "dip orientation.h"


dip Error dip DanielsonLineDetector ( in, line, energy, angle, boundary,
sigma, truncation, flavour )

DATA TYPES

binary, integer, float

FUNCTION

The Danielson line dectector uses second derivatives to detect lines in 2D images and to
estimate their orientation. See the literature reference for an in-depth information on this
detector.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image line Line image
dip Image energy Energy image
dip Image angle Angle image
dip BoundaryArray boundary Boundary conditions
dip FloatArray sigma Sigma of second derivatives
dip float truncation Gauss Truncation
dip DerivativeFlavour flavour Derivative filter flavour

LITERATURE

P.E. Danielson, Q. Lin and Q-Z Yes, i“Efficient detection of second degree variations in 2D
and 3D images”, Report LiTH-ISY-R-2155, Linkoping University, Linkoping, Sweden, 1999

SEE ALSO

Derivative, StructureTensor2D
DIPlib function reference 115

DataTypeAllowed
Check whether a data type is allowed

SYNOPSIS

dip Error dip DataTypeAllowed( dataType, allow, allowedTypes, allowed )

FUNCTION

This function checks whether the dataType is (or is not) in the set of data types specified
by allowedTypes. If allow is DIP TRUE, the data type should be in this set. If allow is
DIP FALSE, the data type should not be in this set. If the allowed parameter is zero, the
routine returns dip errorDataTypeNotSupported if the required condition is not satisfied.
If nonzero, it should point to a boolean variable. This boolean variable will be set to
DIP TRUE if the condition is satisfied, or DIP FALSE if not.

ARGUMENTS

Data type Name Description


dip DataType dataType The data type to check
dip Boolean allow DIP TRUE: check if the data type is
included. DIP FALSE: check if the data type
is not included
dip DataTypeProperties allowedTypes The set of data types to check against, see
DataTypeGetInfo
dip Boolean * allowed Pointer to a boolean to store the answer, or
0 to indicate that
dip errorDataTypeNotSupported should
be returned if the condition is not satisfied

SEE ALSO

DIPlib’s data types


DataTypeGetInfo
116 Chapter 2. Function reference

DataTypeArrayCopy
Copy an array

SYNOPSIS

dip Error dip DataTypeArrayCopy ( dest, src, resources )

FUNCTION

This function copies the data type array src to dest. The array dest is created by this
function as well.

ARGUMENTS

Data type Name Description


dip DataTypeArray * dest Destination array
dip DataTypeArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

DIPlib’s data types


DataTypeArrayNew, DataTypeArrayFree, DataTypeArrayCopy, DataTypeArrayFind
IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
DIPlib function reference 117

DataTypeArrayFind
Find value in array

SYNOPSIS

dip Error dip DataTypeArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
DataTypeArrayFind will produce an error if value is not found, otherwise found obtains
the search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip DataTypeArray array Array to find value in
dip DataType value Value to find
dip int * index Index of the found value
dip Boolean * found Value found or not

SEE ALSO

DIPlib’s data types


DataTypeArrayNew, DataTypeArrayFree, DataTypeArrayCopy, DataTypeArrayFind
IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
118 Chapter 2. Function reference

DataTypeArrayFree
Array free function

SYNOPSIS

dip Error dip DataTypeArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip DataTypeArray * array Array

SEE ALSO

DIPlib’s data types


DataTypeArrayNew, DataTypeArrayFree, DataTypeArrayCopy, DataTypeArrayFind
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 119

DataTypeArrayNew
Array allocation function

SYNOPSIS

dip Error dip DataTypeArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip DataTypeArray and sets the size of the
array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip DataTypeArray * array Array
dip int size Size
dip DataType value Initial value
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

DIPlib’s data types


DataTypeArrayNew, DataTypeArrayFree, DataTypeArrayCopy, DataTypeArrayFind
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
120 Chapter 2. Function reference

DataTypeGetInfo
Get information about a data type

SYNOPSIS

dip Error dip DataTypeGetInfo( dataType, info, whatInfo )

ARGUMENTS

Data type Name Description


dip DataType dataType The data type to get information about
void * info Pointer to a variable to put the information in
dipf DataTypeGetInfo whatInfo What information should be returned

FUNCTION

Get information about a data type. Depending on the whatInfo flag this routine will return
information about the data type through the info parameter. A pointer must be passed to
this routine which must point to a variable of the proper type to contain the information
which will be returned. This pointer is passed as a void pointer through the info
parameter. Below is a table of the flags that determine what information is returned, the
type of the variable that is used to store the information in and a description of the
information that is returned.
dipf DataTypeGetInfo type description
DIP DT INFO PROPS dip DataTypeProperties a set of flags as shown in
the table below
DIP DT INFO SIZEOF dip int sizeof( data type )
DIP DT INFO C2R dip DataType for complex types returns
the corresponding floating
point type (i.e.
dip scomplex ->
dip sfloat) for other data
types returns the data type
itself
The following table shows which dip DataTypeProperties flags are set for which data
types:
DIPlib function reference 121

Data type identifier group data types


DIP DT IS UINT unsigned integer
DIP DT IS UNSIGNED unsigned integer
DIP DT IS SINT signed integer
DIP DT IS INT signed and unsigned integer
DIP DT IS INTEGER signed and unsigned intege
DIP DT IS FLOAT floating-point
DIP DT IS REAL integer and floating-point
DIP DT IS COMPLEX complex floating-point
DIP DT IS SIGNED signed integer, floating-point and complex
DIP DT IS BINARY binary
DIP DT IS ANY all

SEE ALSO

DIPlib’s data types


122 Chapter 2. Function reference

Derivative
Derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip Derivative ( in, out, boundary, ps, sigmas, order, truncation,
flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

This function provides a common interface to different families of regularised derivative


operators. Which family is used, is specified by the flavour parameter. The order of the
derivative operator along each of the cartesian axes may be specified independently.
Be sure to read the documentation on the underlying implementation to learn about the
properties and limitations of the various families.
For the Gaussian family of filters, sigmas must be given, but order can be 0 (only smooth,
don’t take the derivative).
For the finite difference filter, sigmas can be 0, in which case the non-derivative dimensions
will not be processed. Any element of sigmas that is non-zero where the corresponding
order is zero, indicates a dimension that will be smoothed. Note it’s possible to reporduce
the SobelGradient filter this way.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray bc Boundary conditions
dip BooleanArray ps (0) Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip int order (0) Derivative order
dip float truncation Truncation
dip DerivativeFlavour flavour Derivative filter flavour
DIPlib function reference 123

The enumerator flavour parameter is one of:


Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx

SEE ALSO

See section 9.5, “Derivative-based operations”, in “Fundamentals of Image Processing”.


Gauss, GaussFT, GaussIIR, FiniteDifferenceEx, GradientMagnitude,
GradientDirection2D, Laplace, SobelGradient
124 Chapter 2. Function reference

Dgg
Second order derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip Dgg ( in, out, boundary, ps, sigmas, tc, flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes the second derivative in gradient direction of an image using the Derivative
function.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float tc Truncation of Gaussian
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx
DIPlib function reference 125

SEE ALSO

See section 9.5, “Derivative-based operations”, in “Fundamentals of Image Processing” (Dgg


is called SDGD in the text).
Derivative, GradientMagnitude, GradientDirection2D, Laplace, LaplacePlusDgg,
LaplaceMinDgg
126 Chapter 2. Function reference

Dilation
Local maximum filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip Dilation ( in, out, se, boundary, filterParam, shape )

DATA TYPES

integer, float, binary

FUNCTION

Grey-value dilation with different structuring elements.


The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
DIPlib function reference 127

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

SEE ALSO

Closing, Opening, Erosion


128 Chapter 2. Function reference

dip PixelGetFloat
Midlevel PixelIO function

SYNOPSIS

dip Error dip PixelGetFloat ( vptr, type, position, stride, plane, val )

FUNCTION

The dip PixelGet/SetInteger and dip PixelGet/SetFloat functions provide midlevel access
to image pixel values. These functions are faster than the highlevel Get and Set functions,
but are easier to use than the lowlevel DIP PIXEL GET and DIP PIXEL SET macros as defined
in dip macros.h.

ARGUMENTS

Data type Name Description


void * vptr Void pointer to the image data
dip DataType type Image data type. See DIPlib’s data types
dip IntegerArray position Position of the pixel in the image
dip IntegerArray stride Image data stride
dip int plane Plane of the pixel (binary images)
dip float * val Pointer to the variable receiving the obtained pixel
value

SEE ALSO

dip PixelGetInteger, dip PixelSetInteger, dip PixelSetFloat, Get, Set,


GetInteger, SetInteger, GetFloat, SetFloat
DIPlib function reference 129

dip PixelGetInteger
Midlevel PixelIO function

SYNOPSIS

#include "dip support.h"


dip Error dip PixelGetInteger ( vptr, type, position, stride, plane, val )

FUNCTION

The dip PixelGet/SetInteger and dip PixelGet/SetFloat functions provide midlevel access
to image pixel values. These functions are faster than the highlevel Get and Set functions,
but are easier to use than the lowlevel DIP PIXEL GET and DIP PIXEL SET macros as defined
in dip macros.h.

ARGUMENTS

Data type Name Description


void * vptr Void pointer to the image data
dip DataType type Image data type. See DIPlib’s data types
dip IntegerArray position Position of the pixel in the image
dip IntegerArray stride Image data stride
dip int plane Plane of the pixel (binary images)
dip int * val Pointer to the variable receiving the obtained pixel
value

SEE ALSO

dip PixelGetFloat, dip PixelSetInteger, dip PixelSetFloat, Get, Set, GetInteger,


SetInteger, GetFloat, SetFloat
130 Chapter 2. Function reference

dip PixelSetFloat
Midlevel PixelIO function

SYNOPSIS

dip Error dip PixelSetFloat ( val, vptr, type, position, stride, plane )

FUNCTION

The dip PixelGet/SetInteger and dip PixelGet/SetFloat functions provide midlevel access
to image pixel values. These functions are faster than the highlevel Get and Set functions,
but are easier to use than the lowlevel DIP PIXEL GET and DIP PIXEL SET macros as defined
in dip macros.h.

ARGUMENTS

Data type Name Description


dip float val Value to write to the pixel
void * vptr Void pointer to the image data
dip DataType type Image data type. See DIPlib’s data types
dip IntegerArray position Position of the pixel in the image
dip IntegerArray stride Image data stride
dip int plane Plane of the pixel (binary images)

SEE ALSO

dip PixelGetInteger, dip PixelGetFloat, dip PixelSetInteger, Get, Set,


GetInteger, SetInteger, GetFloat, SetFloat
DIPlib function reference 131

dip PixelSetInteger
Midlevel PixelIO function

SYNOPSIS

dip Error dip PixelSetInteger ( val, vptr, type, position, stride, plane )

FUNCTION

The dip PixelGet/SetInteger and dip PixelGet/SetFloat functions provide midlevel access
to image pixel values. These functions are faster than the highlevel Get and Set functions,
but are easier to use than the lowlevel DIP PIXEL GET and DIP PIXEL SET macros as defined
in dip macros.h.

ARGUMENTS

Data type Name Description


dip int val Value to write to the pixel
void * vptr Void pointer to the image data
dip DataType type Image data type. See DIPlib’s data types
dip IntegerArray position Position of the pixel in the image
dip IntegerArray stride Image data stride
dip int plane Plane of the pixel (binary images)

SEE ALSO

dip PixelGetInteger, dip PixelGetFloat, dip PixelSetFloat, Get, Set, GetInteger,


SetInteger, GetFloat, SetFloat
132 Chapter 2. Function reference

DistributionSort
Sort a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip DistributionSort ( data, size, dataType )

FUNCTION

Sorts a block of data (of size size and data type dataType ) using the distribution sort
algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


DistributionSortIndices, DistributionSortIndices16, Sort, ImageSort,
SortIndices, SortIndices16, ImageSortIndices
DIPlib function reference 133

DistributionSortIndices
Sort indices to block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip DistributionSortIndices ( data, indices, size, dataType )

FUNCTION

Sorts a list of indices rather than the data itself using the distribution sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint32 * indices Indices
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


DistributionSort, DistributionSortIndices16, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
134 Chapter 2. Function reference

DistributionSortIndices16
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip DistributionSortIndices16 ( data, indices, size, dataType )

FUNCTION

Sorts a list of (16 bit) indices rather than the data itself using the distribution sort
algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint16 * indices Indices
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


DistributionSort, DistributionSortIndices, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
DIPlib function reference 135

Div
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Div ( in1, in2, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in1 / in2 on a pixel by pixel basis. If a pixel in in2 has the
value of zero, the corresponding pixel in out will be set to zero. The data types of the in1
and in2 image may be of different types. See Information about dyadic operations for more
information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex,


DivFloat, DivComplex
136 Chapter 2. Function reference

DivComplex
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip DivComplex ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in / constant on a pixel by pixel basis. If constant is zero,
out will be set to zero. The data types of the in1 image and constant may be of different
types. See Information about dyadic operations for more information about what the type
of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip complex constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div,
DivFloat
DIPlib function reference 137

DivFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip DivFloat ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in / constant on a pixel by pixel basis. If constant is zero,
out will be set to zero. The data types of the in1 image and constant may be of different
types. See Information about dyadic operations for more information about what the type
of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip float constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div,
DivComplex
138 Chapter 2. Function reference

EdgeObjectsRemove
Remove binary edge objects

SYNOPSIS

#include "dip binary.h"


dip Error dip EdgeObjectsRemove ( in, out, connectivity )

DATA TYPES

binary

FUNCTION

The function EdgeObjectsRemove removes those binary objects from in which are connected
to the edges of the image. The connectivity of the objects is determined by connectivity.
This function is a front-end to BinaryPropagation. It calls BinaryPropagation with no
seed image and the edge pixels turned on. The result of the propagation is xor-ed with the
input image. The connectivity parameter defines the metric, that is, the shape of the
structuring element. 1 indicates city-block metric, or a diamond-shaped structuring element.
2 indicates chessboard metric, or a square structuring element. -1 and -2 indicate
alternating connectivity and produce an octagonal structuring element. See The
connectivity parameter for more information. The edge parameter specifies whether the
border of the image should be treated as object (DIP TRUE) or as background (DIP FALSE).
See section 10.3, “Segmentation”, in “Fundamentals of Image Processing” for a description
of the edge object removal operation.

ARGUMENTS

Data type Name Description


dip Image in Binary input image
dip Image out Output
dip int connectivity Pixel connectivity

KNOWN BUGS

This function is only implemented for images with a dimension up to three.


DIPlib function reference 139

SEE ALSO

BinaryPropagation, Xor
140 Chapter 2. Function reference

EllipticDistanceToPoint
Distance generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip EllipticDistanceToPoint ( output, origin, scale )

DATA TYPES

Output: sfloat

FUNCTION

Computes the elliptic distance of each pixel in the output image to a point at origin. The
coordinates of origin may lie outside the image. The scale parameter may be used to
specify the relative distance between pixels in each dimension.

ARGUMENTS

Data type Name Description


dip Image output Output Image
dip FloatArray origin Coordinates of the Origin
dip FloatArray scale Relative scale of the pixel distances for each dimension

SEE ALSO

EuclideanDistanceToPoint, CityBlockDistanceToPoint
DIPlib function reference 141

Equal
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip Equal ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when corresponding pixels in in1 and in2 are
equal. This is the same as Compare with the DIP SELECT EQUAL selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to a functionality similar to SelectValue.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Greater, Lesser, NotEqual, NotGreater, NotLesser, SelectValue,


NotZero
142 Chapter 2. Function reference

Erf
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip Erf ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the error function of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselY1, BesselYN, LnGamma, Erfc, Sinc


DIPlib function reference 143

Erfc
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip Erfc ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the complementary error function of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselY1, BesselYN, LnGamma, Erf, Sinc


144 Chapter 2. Function reference

ErfClip
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip ErfClip ( in, out, threshold, range, clipFlag )

DATA TYPES

integer, float

FUNCTION

Clips in using the erf function at either or both the values threshold +/- range/2. If the
flag DIP CLIP LOW AND HIGH BOUNDS is specified, threshold and range are used as lower
and upper bounds respectively.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float threshold Threshold value
dip float range Range value
dipf Clip clipFlag clipFlag
The following dipf Clip flags are defined:
Name Description
DIP CLIP BOTH clip both the lower and upper bound
DIP CLIP LOW clip lower bound only
DIP CLIP HIGH clip upper bound only
DIP CLIP THRESHOLD AND RANGE same as DIP CLIP BOTH
DIP CLIP LOW AND HIGH BOUNDS use threshold and range as lower and upper bounds

LITERATURE

L.J. van Vliet, Grey-Scale Measurements in Multi-Dimensional Digitized Images, Ph.D.


thesis Delft University of Technology, Delft University Press, Delft, 1993
DIPlib function reference 145

SEE ALSO

Clip, ContrastStretch
146 Chapter 2. Function reference

Erosion
Local minimum filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip Erosion ( in, out, se, boundary, filterParam, shape )

DATA TYPES

integer, float, binary

FUNCTION

Grey-value erosion with different structuring elements.


The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
DIPlib function reference 147

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

SEE ALSO

Closing, Opening, Dilation


148 Chapter 2. Function reference

error.h
Contains error messages

SYNOPSIS

#include "dip error.h"

FUNCTION

Contains a lot of definitions to do with DIPlib’s error mechanism. In particular, this include
file contains definitions for a number of error messages. These are all of the type extern
const char *. A list of the error sorted by category follows below:
Memory allocation
Name Description
dip errorCouldNotAllocateMemory No memory could be allocated
Image creation errors
Name Description
dip errorImageIsLocked Image is locked
dip errorImageNotRaw Image is not in the RAW state
dip errorImageNotValid Image is not in the VALID state
dip errorImagesNotUnique Image is used as an output image more than once
dip errorImageLockInvalidKey Cannot unlock. Wrong key
Image type errors
Name Description
dip errorIllegalImageType Illegal image type
dip errorImageTypeDoesNotExist Image type does not exist
dip errorImageTypeAlreadyExists Adding image type failed. Type already exists
dip errorImageTypeNotSupported Image type not supported
dip errorImageTypeHandlerMissing No type handler for image type
Image data type errors
Name Description
dip errorDataTypeNotSupported Data type not supported
dip errorIllegalDataType Illegal data type
Image dimension(ality) errors
Name Description
dip errorIllegalDimensionality Illegal dimensionality
dip errorDimensionalityNotSupported Dimensionality not supported
dip errorIllegalDimension Illegal dimension
DIPlib function reference 149

ErrorFree
Free a DIPlib call tree

SYNOPSIS

void dip ErrorFree( error )

FUNCTION

Free a DIPlib call tree.

ARGUMENTS

Data type Name Description


dip Error error DIPlib call tree

RETURNS

Nothing
150 Chapter 2. Function reference

EuclideanDistanceToPoint
Distance generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip EuclideanDistanceToPoint ( output, origin )

DATA TYPES

Output: sfloat

FUNCTION

Computes the Euclidean distance of each pixel in the output image to a point at origin.
The coordinates of origin may lie outside the image.

ARGUMENTS

Data type Name Description


dip Image output Output Image
dip FloatArray origin Coordinates of the Origin

SEE ALSO

EllipticDistanceToPoint, CityBlockDistanceToPoint
DIPlib function reference 151

EuclideanDistanceTransform
Euclidean distance transform

SYNOPSIS

#include "dip distance.h"


dip Error dip EuclideanDistanceTransform ( in, out, distance, border, method
)

DATA TYPES

binary

FUNCTION

This function computes the Euclidean distance transform of an input binary image using
the vector-based method as opposed to the chamfer method. This method computes
distances from the objects (binary 1’s) to the nearest background (binary 0’s) of in and
stored the result in out. The out image is a sfloat type image.
The distance parameter can be used to specify anisotropic sampling densities. If it is set to
zero, the sampling density is assumed to be 1.0 along all axes.
The border parameter specifies whether the edge of the image should be treated as objects
(border = DIP TRUE) or as background (border = DIP FALSE).
Individual vector components of the Euclidean distance transform can be obtained with the
VectorDistanceTransform.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip FloatArray distance Sampling distances
dip Boolean border Image border type
dipf DistanceTransform method Transform method
dipf DistanceTransform defines the following distance transform types:
152 Chapter 2. Function reference

Name Description
DIP EDT FAST fastest, but most errors
DIP EDT TIES slower, but fewer errors
DIP EDT TRUE slow, uses lots of memory, but is “error free”
DIP EDT BRUTE FORCE gives a result from which errors are calculated for the other
methods. This method is extremly slow and should only be used
for testing purposes.

LITERATURE

Danielsson, P.E. (1980). “Euclidean distance mapping.“ Computer Graphics and Image
Processing 14: 227-248.
Mullikin, J.C. (1992). “The vector distance transform in two and three dimensions.“
CVGIP: Graphical Models and Image Processing 54(6): 526-535.
Ragnemalm, I. (1990). Generation of Euclidean Distance Maps, Thesis No. 206. Licentiate
thesis. Linkoing University, Sweden.
Ye, Q.Z. (1988). “The signed Euclidean distance transform and its applications.“ in
Proceedings, 9th International Conference on Pattern Recognition, Rome, 495-499.

KNOWN BUGS

The EDT TRUE transform type is prone to produce an internal buffer overflow when applied
to larger (almost) spherical objects. It this cases use EDT TIES or EDT BRUTE FORCE instead.
The option border = DIP FALSE is not supported for EDT BRUTE FORCE.
This function supports 2 and 3-dimensional images.

AUTHOR

James C. Mullikin, adapted to DIPlib by Geert M.P. van Kempen

SEE ALSO

VectorDistanceTransform, GreyWeightedDistanceTransform
DIPlib function reference 153

EuclideanSkeleton
binary skeleton operation

SYNOPSIS

#include "dip binary.h"


dip Error dip EuclideanSkeleton ( in, out, endpixelCondition, edgeCondition )

DATA TYPES

binary

FUNCTION

This function calculates an accurate (euclidean)skeleton. It tests Hilditch conditions to


preserve topology. The algorithms uses the following distance metrics:
2D
5 4-connected neighbor
7 8-connected neighbor
11 neighbors reachable with a knight’s move
3D
4 6-connected neighbors
6 18-connected neighbors
7 26-connected neighbors
9 neighbors reachable with knight’s move
10 (2,1,1) neighbors
12 (2,2,1) neighbors
The edge parameter specifies whether the border of the image should be treated as object
(DIP TRUE) or as background (DIP FALSE). See section 9.6, “Morphology-based operations”,
in “Fundamentals of Image Processing” for a description of the skeleton operation.

ARGUMENTS

Data type Name Description


dip Image in Binary input image
dip Image out Output image
dip EndpixelCondition endpixelCondition Endpixel condition
dip Boolean edgeCondition Edge condition
The dip EndpixelCondition enumeration consists of the following flags:
154 Chapter 2. Function reference

Name Description
DIP ENDPIXEL CONDITION LOOSE ENDS AWAY Loose ends are eaten away
DIP ENDPIXEL CONDITION NATURAL “natural” endpixel condition of
this algorithm
DIP ENDPIXEL CONDITION KEEP WITH ONE NEIGHBOR Keep endpoint if it has a
neighbor
DIP ENDPIXEL CONDITION KEEP WITH TWO NEIGHBORS Keep endpoint if it has two
neighbors
DIP ENDPIXEL CONDITION KEEP WITH THREE NEIGHBORS Keep endpoint if it has three
neighbors

KNOWN BUGS

EuclideanSkeleton is only implemented for 2 and 3 D images.


EuclideanSkeleton does not process pixels in a 2-pixel border around the edge. If this is
an issue, consider adding 2 pixels on each side of your image.

LITERATURE

“Improved metrics in image processing applied to the Hilditch skeleton”, B.J.H. Verwer, 9th
ICPR, Rome, November 14-17, 1988.

AUTHOR

Ben Verwer, adapted to DIPlib by Geert van Kempen.

SEE ALSO

BinaryPropagation
DIPlib function reference 155

Exit
Clean up before exiting

SYNOPSIS

dip Error dip Exit( void )


dip Error dipio Exit( void )

FUNCTION

Free all memory used internally by DIPlib. Call this function when you stop using DIPlib
(before exiting your program).

SEE ALSO

Initialise
156 Chapter 2. Function reference

Exp
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Exp ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the natural exponent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp2, Exp10, Ln, Log2, Log10


DIPlib function reference 157

Exp10
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Exp10 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the base ten exponent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp, Exp2, Ln, Log2, Log10


158 Chapter 2. Function reference

Exp2
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Exp2 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the base two exponent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp, Exp10, Ln, Log2, Log10


DIPlib function reference 159

ExponentialFitCorrection
Exponential fit based attenuation correction

SYNOPSIS

#include "dip microscopy.h"


dip Error dip ExponentialFitCorrection ( in, out, method, percentile,
fromWhere, hysteresis, varWeighted )

DATA TYPES

binary, integer, float

FUNCTION

This routine implements a simple absorption, reflection and bleaching correction based upon
the assumption that the sum of these effects result in a exponential extinction of the signal
as a function of depth. Only pixels that are non-zero are taken into account. Depending
upon the chosen method, the mean or a percentile of all the non-zero pixels are calculated
as a function of the slice number (depth). Then an exponential function is fitted through
these slice-representing values. The starting point of the fit is determined by fromWhere.
The first maximum is found with point[z+1] > hysteresis * point[z]. If the mean variant is
chosen one can chose to apply a variance weighting to the fit.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dipf ExpFitData method Data statistic to fit on
dip float percentile Percentile
dipf ExpFitStart fromWhere From where to start the fit
dip float hysteresis First maximum hysteresis
dip Boolean varWeighted Fit with variance weights
The dipf ExpFitData enumaration consists of the following flags:
Name Description
DIP ATTENUATION EXP FIT DATA MEAN Fit on the mean values
DIP ATTENUATION EXP FIT DATA PERCENTILE Fit on the specified percentile of the data
The dipf ExpFitStart enumaration consists of the following flags:
160 Chapter 2. Function reference

Name Description
DIP ATTENUATION EXP FIT START FIRST PIXEL Start fit on first pixel
DIP ATTENUATION EXP FIT START GLOBAL MAXIMUM Start fit on global maximum
DIP ATTENUATION EXP FIT START FIRST MAXIMUM Start fit on first maximum

LITERATURE

K.C. Strasters, H.T.M. van der Voort, J.M. Geusebroek, and A.W.M. Smeulders, “Fast
attenuation correction in fluorescence confocal imaging: a recursive approach”, BioImaging,
vol. 2, no. 2, 1994, 78-92.

AUTHOR

Karel Strasters, adapted to DIPlib by Geert van Kempen.

SEE ALSO

AttenuationCorrection, SimulatedAttenuation
DIPlib function reference 161

ExtendRegion
Image manipulation functions

SYNOPSIS

#include "dip manipulation.h"


dip Error dip ExtendRegion ( image, origin, regDims, bc, ordering, imValues )

FUNCTION

This functions extends a region in an image with a specified boundary condition.

ARGUMENTS

Data type Name Description


dip Image image Image
dip IntegerArray origin Origin
dip IntegerArray regDims RegDims
dip BoundaryArray bc Boundary conditions
dip IntegerArray ordering Ordering
dip Image * imValues Complex values
162 Chapter 2. Function reference

FeatureAnisotropy2D
Measure the anisotropy in a labeled region

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureAnisotropy2DID ( dip int * )

FUNCTION

dip FeatureAnisotropy2DID returns the ID value of this measurement function, that is


registered by Initialise.
The grey value input image should contain an orienation field. For each labeled region, a
tensor is constructed at each of the region’s pixels. This tensor is as follow:

cos^2(phi) cos(phi)sin(phi)
[ ]
cos(phi)sin(phi) sin^2(phi)

The next step is to compute a new tensor, each element computed by averaging the
corresponding elements of all the individual tensors. This average tensor represents the
orientation information of the region as a whole. Eigenvalue analysis of this tensor yields
two eigenvalues, the largest l0, the smallest l1. The anisotropy measure is: ( l0 - l1 ) / ( l0 +
l1 ) which is zero for a fully isotropic regions (i.e. one where there is no prefered
orientation), and one for a fully anisotropic region (i.e. when there is a single orientation).

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia,
StructureTensor2D
DIPlib function reference 163

FeatureBendingEnergy
Undocumented measurement function
164 Chapter 2. Function reference

FeatureCenter
Measure the object’s center

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureCenterID ( void )

FUNCTION

dip FeatureCenterID returns the ID value of this measurement function, that is registered
by Initialise.
This functions measures the centre of an object by calculating the first moments of the
object using the object labels as binary mask. The intensity information is not taken into
account.

SEE ALSO

Measure, FeatureSize, FeatureGravity, FeatureMean, FeatureStdDev, FeatureMaximum,


FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 165

FeatureChainCodeBendingEnergy
Undocumented measurement function
166 Chapter 2. Function reference

FeatureDescriptionFree
Free a Feature Description

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionFree ( description )

FUNCTION

This function frees a Feature Description data structure. This is not the preferred way of
freeing a Feature Description. Use the resources mechanism instead (Resources tracking
structure. See ResourcesNew).

ARGUMENTS

Data type Name Description


dip FeatureDescription * description Feature Description to be freed

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 167

FeatureDescriptionGetDescription
Get the description of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionGetDescription ( description, text, resources
)

FUNCTION

Gets the description of the feature described by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip String * text Description text
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
168 Chapter 2. Function reference

FeatureDescriptionGetLabels
Get the labels of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionGetLabels ( description, labels, resources )

FUNCTION

Gets the labels of the data of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip StringArray * labels Feature Labels
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 169

FeatureDescriptionGetName
Get the name of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionGetName ( description, name, resources )

FUNCTION

Gets the name of the feature described by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip String * name Name of the measurement feature
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
170 Chapter 2. Function reference

FeatureDescriptionGetUnits
Get the Units of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionGetUnits ( description, units, resources )

FUNCTION

Gets the units of the data of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip StringArray * units Array of Unit texts
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 171

FeatureDescriptionNew
Allocate a new FeatureDescription

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionNew ( description, resources )

FUNCTION

This function allocates a new dip FeatureDescription data structure. A feature description
contains the name, a short description of a measurement feature, as well as the labels and
units of the data measured by the feature.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
172 Chapter 2. Function reference

FeatureDescriptionSetDescription
Set the description of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetDescription ( description, text )

FUNCTION

Sets the description of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
char * text Description text

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 173

FeatureDescriptionSetDimensionLabels
Label set convenience function

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetDimensionLabels ( description,
measurement, featureID, baseLabel )

FUNCTION

This function set the labels of the feature, described by description, by adding for each
label a dimension indicator to baseLabel. For dimensions 0 to 3, X, Y or Z is added. For
dimensions higher, the numerical value of the dimension is added.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip Measurement measurement Measurement data structure
dip int featureID ID of the measurement feature
char * baseLabel Base label

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
174 Chapter 2. Function reference

FeatureDescriptionSetLabel
Set the name of a particular feature label

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetLabel ( description, number, label )

FUNCTION

This function sets the name of a particular label of the described feature.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip int number Index of the label
char * label Label text

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 175

FeatureDescriptionSetLabels
Set the labels of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetLabels ( description, measurement,
featureID, labels, label )

FUNCTION

Sets the labels of the data of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip Measurement measurement Measurement data structure
dip int featureID ID of the measurement feature
dip StringArray labels Array of label describing strings, one for
each label
char * label Single description of all feature labels

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
176 Chapter 2. Function reference

FeatureDescriptionSetName
Set the name of the described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetName ( description, name )

FUNCTION

Sets the name of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
char * name Name of the measurement feature

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
DIPlib function reference 177

FeatureDescriptionSetUnits
Set the units of a described feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip FeatureDescriptionSetUnits ( description, measurement,
featureID, units, unit )

FUNCTION

Sets the units of the data of the feature descripted by description.

ARGUMENTS

Data type Name Description


dip FeatureDescription description Feature description data structure
dip Measurement measurement Measurement data structure
dip int featureID ID of the measurement feature
dip StringArray units Array of Unit texts, one for each unit
char * unit Single text for all units

SEE ALSO

MeasurementFeatureDescription, FeatureDescriptionFree, FeatureDescriptionNew,


FeatureDescriptionSetName, FeatureDescriptionGetName,
FeatureDescriptionSetDescription, FeatureDescriptionGetDescription,
FeatureDescriptionSetLabels, FeatureDescriptionGetLabels,
FeatureDescriptionSetLabel, FeatureDescriptionSetUnits,
FeatureDescriptionGetUnits, FeatureDescriptionSetDimensionLabels
178 Chapter 2. Function reference

FeatureDimension
Measure the object’s dimensions

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureDimensionID ( void )

FUNCTION

dip FeatureDimensionID returns the ID value of this measurement function, that is


registered by Initialise.
This function meaaures the length of an object along the principal axes of the label image
(e.g. the length object along the X, Y & Z axes).

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 179

FeatureExcessKurtosis
Undocumented measurement function
180 Chapter 2. Function reference

FeatureFeret
Measure the object’s Feret diameters

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureFeretID ( void )

FUNCTION

dip FeatureFeretID returns the ID value of this measurement function, that is registered
by Initialise.
This function measures the Feret maximum and minimum diameters of an object. The
Feret diameter are found by rotating the object chaincode. The default angle stepsize is
defined by DIP MSR FERET ACCURACY (set to 0.5 degrees). This measurement function
supports a measurement parameter (see Measure), which is defined in dip measurement.h.
If a non-zero pointer to a dip FeretParameters structure is supplied, the structure’s
stepsize parameter is used instead of the default angle stepsize. Furthermore the
structure’s angles boolean parameter specifies whether the angles of the Feret diameters
should be measured as well. This function supports 2D images only.
The original code on which the current implementation is based, was donated by Gerie van
der Heijden.

ARGUMENTS

Data type Name Description


dip FeretParameters *feret Pointer to a Feret measurement parameters structure
(not yet implemented)

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureMass, FeatureInertia
DIPlib function reference 181

FeatureGinertia
Measure the object’s inertia

SYNOPSIS

#include "dip measurement.h"


dip int FeatureGinertiaID ( void )

FUNCTION

dip FeatureGinertiaID returns the ID value of this measurement function, that is


registered by Initialise.
This function calculates the inertia (weighted by its grey values) of an object by calculating
the eigenvalues of the object’s second order moments tensor. This measure only supports
2D and 3D objects. FeatureGinteria supports a measurement parameter (see Measure). If
a pointer to a non-zero boolean is supplied, this function will not only measure the
eigenvalues of the second order moments tensor, but also the angles of its eigenvectors.

ARGUMENTS

Data type Name Description


dip Boolean * angles Pointer to a boolean specifying that “eigenangles” should be
measured (not yet implemented)

LITERATURE

“Pratical Handbook on Image Processing for Scientific Applications, chapter 16”, Bernd
Jahne, CRC Press, 1999.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia,
FeatureMu, FeatureGmu
182 Chapter 2. Function reference

FeatureGmu
Measure the object’s inertia

SYNOPSIS

#include "dip measurement.h"


dip int FeatureGmuID ( void )

FUNCTION

dip FeatureGmuID returns the ID value of this measurement function, that is registered by
Initialise.
This function calculates the inertia (weighted by its grey values) of an object by calculating
the object’s second order moments tensor. This measure only supports 2D and 3D objects.
The output tensor is ordered as follows:
2D: xx, xy, yy
3D: xx, xy, xz, yy, yz, zz

LITERATURE

“Mechanics”, Florian Scheck, Springer, 1999.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia,
FeatureGinertia, FeatureMu
DIPlib function reference 183

FeatureGravity
Measure the object’s gravity

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureGravityID ( void )

FUNCTION

dip FeatureGravityID returns the ID value of this measurement function, that is


registered by Initialise.
This function measures the point of gravity of the object, by calculating the object’s first
moment weighted by the intensity of each object pixel.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureMean, FeatureStdDev, FeatureMaximum,


FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
184 Chapter 2. Function reference

FeatureInertia
Measure the object’s inertia

SYNOPSIS

#include "dip measurement.h"


dip int FeatureInertiaID ( void )

FUNCTION

dip FeatureInertiaID returns the ID value of this measurement function, that is


registered by Initialise.
This function calculates the inertia of an object by calculating the eigenvalues of the
object’s second order moments tensor. This measure only supports 2D and 3D objects.
FeatureInteria supports a measurement parameter (see Measure). If a pointer to a
non-zero boolean is supplied, this function will not only measure the eigenvalues of the
second order moments tensor, but also the angles of its eigenvectors.

ARGUMENTS

Data type Name Description


dip Boolean * angles Pointer to a boolean specifying that “eigenangles” should be
measured (not yet implemented)

LITERATURE

“Pratical Handbook on Image Processing for Scientific Applications, chapter 16”, Bernd
Jahne, CRC Press, 1999.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass,
FeatureGinertia, FeatureMu, FeatureGmu
DIPlib function reference 185

FeatureLongestChaincodeRun
Undocumented measurement function
186 Chapter 2. Function reference

FeatureMass
Measure the mass of the object (sum of grey-values)

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMassID ( void )

FUNCTION

dip FeatureMassID returns the ID value of this measurement function, that is registered by
Initialise. This function is just an alias for dip FeatureSumID.
This function measures the sum of the grey-value in the intensity image (see Measure) of
pixels inside the object, and is equivalent to FeatureSum

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMass, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 187

FeatureMaximum
Measure the object’s maximum coordinate value

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMaximumID ( void )

FUNCTION

dip FeatureMaximumID returns the ID value of this measurement function, that is


registered by Initialise.
This function measures the maximum coordinate value of each dimension of the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
188 Chapter 2. Function reference

FeatureMaxVal
Measure the object’s maximum intensity

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMaxValID ( void )

FUNCTION

dip FeatureMaxValID returns the ID value of this measurement function, that is registered
by Initialise.
This function measures the maximum intensity in the intensity image (see Measure) of
pixels inside the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 189

FeatureMean
Measure the object’s mean intensity

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMeanID ( void )

FUNCTION

dip FeatureMeanID returns the ID value of this measurement function, that is registered by
Initialise.
This function measures the mean intensity in the intensity image (see Measure) of pixels
inside the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMass, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
190 Chapter 2. Function reference

FeatureMinimum
Measure the object’s minimum coordinate value

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMinimumID ( void )

FUNCTION

dip FeatureMinimumID returns the ID value of this measurement function, that is


registered by Initialise.
This function measures the minimum coordinate value of each dimension of the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 191

FeatureMinVal
Measure the object’s minimum intensity

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureMinValID ( void )

FUNCTION

dip FeatureMinValID returns the ID value of this measurement function, that is registered
by Initialise.
This function measures the minimum intensity in the intensity image (see Measure) of pixels
inside the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
192 Chapter 2. Function reference

FeatureMu
Measure the object’s inertia

SYNOPSIS

#include "dip measurement.h"


dip int FeatureMuID ( void )

FUNCTION

dip FeatureMuID returns the ID value of this measurement function, that is registered by
Initialise.
This function calculates the inertia of an object by calculating the object’s second order
moments tensor. This measure only supports 2D and 3D objects. The output tensor is
ordered as follows:
2D: xx, xy, yy
3D: xx, xy, xz, yy, yz, zz

LITERATURE

“Mechanics”, Florian Scheck, Springer, 1999.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia,
FeatureGmu, FeatureGinertia
DIPlib function reference 193

FeatureOrientation2D
Undocumented measurement function
194 Chapter 2. Function reference

FeatureP2A
Measure the circularity of the object

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureP2AID ( void )

FUNCTION

dip FeatureP2AID returns the ID value of this measurement function, that is registered by
Initialise.
This function is a composite measurement function, that uses FeatureSize,
FeaturePerimeter, and FeatureSurfaceArea to determine the circularity of an object by
calculating: 2D: P2A = perimeterˆ2 / (4Pi * size) 3D: P2A = surface-areaˆ1.5 / (6 Sqrt(Pi)
* size).

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMass, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia, FeatureShape
DIPlib function reference 195

FeaturePerimeter
Measure the object’s perimeter length

SYNOPSIS

#include "dip measurement.h"


dip int dip FeaturePerimeterID ( void )

FUNCTION

dip FeaturePerimeterID returns the ID value of this measurement function, that is


registered by Initialise.
This measures the perimeter of 2D objects by calculating the length of the chaincode of its
enclosing border. This function assumes that each object has a single connected border.
The used method for measuring the length of the chaincode is optimal for circles, and for a
collection of objects that are randomly orientated, see the referenced literature for detailed.

LITERATURE

A.M. Vossepoel and A.W.M. Smeulders (1982), “Vector Code Probability and Metrication
Error in the Representation of Straight Lines of Finite Length”, Computer Graphics and
Image Processing 20: 347-364

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeatureSurfaceArea, FeatureMass, FeatureInertia
196 Chapter 2. Function reference

FeatureShape
Measure shape parameters of the object

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureShapeID ( void )

FUNCTION

dip FeatureShapeID returns the ID value of this measurement function, that is registered
by Initialise.
This function is a composite measurement function, that uses FeatureSize,
FeaturePerimeter, and FeaturePerimeter to measures the following shape characteristics
of 2D objects: Squarity = area / ( s * sp ) Circularity = area / ( Pi/4 * spˆ2 ) Triangularity
= area / ( 2 * s * sp ) Ellipsity = area / ( Pi/4 * s * sp ) Elongation = p / l with area the
size, s the shortest Feret diameter, l the longest Feret diameter, sp the Feret diameter
perpendicular to s, and p the perimeter of the object.
When the measured object is either a perfect square, circle, triangle or ellips, the values
obtained by FeatureShape will be 1.0.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMass, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia, FeatureP2A
DIPlib function reference 197

FeatureSize
Measure the object’s size

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureSizeID ( void )

FUNCTION

dip FeatureSizeID returns the ID value of this measurement function, that is registered by
Initialise.
This function measures the object’s size by counting the number of pixels having the same
object ID. This measure is the optimal procedure for estimating the area (2D) or volume
(3D) of an object with an arbitrary size. The measurement value’s unit are in pixels
(pixelsˆ2 in 2D, pixelsˆ3 in 3D).

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
198 Chapter 2. Function reference

FeatureSkewness
Undocumented measurement function
DIPlib function reference 199

FeatureStdDev
Measure the standard deviation of the object’s intensity

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureStdDevID ( void )

FUNCTION

dip FeatureStdDevID returns the ID value of this measurement function, that is registered
by Initialise.
This function measures the standard deviation of the intensity in the intensity image (see
Measure) of pixels inside the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
200 Chapter 2. Function reference

FeatureSum
Measure the sum of the grey values of the object

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureSumID ( void )

FUNCTION

dip FeatureSumID returns the ID value of this measurement function, that is registered by
Initialise.
This function measures the sum of the grey-value in the intensity image (see Measure) of
pixels inside the object.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMass, FeatureStdDev,


FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
DIPlib function reference 201

FeatureSurfaceArea
Measure the area of the object’s surface

SYNOPSIS

#include "dip measurement.h"


dip int dip FeatureSurfaceAreaID ( void )

FUNCTION

dip FeatureSurfaceAreaID returns the ID value of this measurement function, that is


registered by Initialise.
This function measures the area of a 3D object’s surface using six-connected boundary
voxels.

LITERATURE

J.C. Mullikin and P.W. Verbeek (1993), “Surface area estimation of digitized planes.“,
bioimaging 1(1): 6-16.

SEE ALSO

Measure, FeatureSize, FeatureCenter, FeatureGravity, FeatureMean, FeatureSum,


FeatureStdDev, FeatureMaximum, FeatureMinimum, FeatureMaxVal, FeatureMinVal,
FeaturePerimeter, FeatureSurfaceArea, FeatureFeret, FeatureMass, FeatureInertia
202 Chapter 2. Function reference

FillBoundaryArray
Fill the border of array according to the boundary condition

SYNOPSIS

dip Error DIP TPI FUNC(dip FillBoundaryArray)( in, out, size, border, boundary
)

FUNCTION

Set the values of the border pixels of an array. The pixels of out outside the range of the
array in are set to a value determined by the boundary condition and the pixel values of in.

ARGUMENTS

Data type Name Description


void * in input array
void * out output array
dip int size size of input array
dip int border size of the extended borders
dip boundary boundary Boundary conditions

NOTE

The out array has to be allocated before this function is called, and should at least has the
size of (size + 2 * border). Thus, border specifies the length of the border on both sides
of the in array. Furthermore, the out pointer should point to that element in the out array
that corresponds to the first element in the in array:

<- size ->


input: ************************
|
in

<- border -><- size -><- border ->


output: ------------************************------------
|
out

The enumerator dip boundary contains the following constants:


DIPlib function reference 203

Name Description
DIP BC SYM MIRROR Symmetric mirroring
DIP BC ASYM MIRROR Asymmetric mirroring
DIP BC PERIODIC Periodic copying
DIP BC ASYM PERIODIC Asymmetric periodic copying
DIP BC ADD ZEROS Extending the image with zeros
DIP BC ADD MAX VALUE Extending the image with +infinity
DIP BC ADD MIN VALUE Extending the image with -infinity

SEE ALSO

SeparableFrameWork
204 Chapter 2. Function reference

FindShift
Estimate the shift between images

SYNOPSIS

#include "dip findshift.h"


dip Error dip FindShift ( in1, in2, out, method, parameter )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function estimates the (sub-pixel) global shift between in1 and in2. The numbers
found represent the shift of in1 with respect to in2, or the position of the first pixel of in2
in the coordinate system of in1. There are two methods that can be used: CPF and MTS.
Both methods require that the shift be small. Therefore, first the integer pixel is calculated,
and both images are cropped to the common part.
If method is 0, DIP FSM MTS is used. method can also be DIP FSM INTEGER ONLY. Integer
shifts can be calculated for images of any dimensionality.

CPF

The CPF method (marked as FFTS in the literature below) uses the phase of the
cross-correlation (as calculated by CrossCorrelationFT) to estimate the shift. parameter
sets the amount of frequencies used in this estimation. The maximum value that makes
sense is sqrt(1/2). Any larger value will give the same result. Choose smaller values to
ignore the higher frequencies, which have a smaller SNR and are more affected by aliasing.
If parameter is set to 0, the optimal found for images sub-sampled by a factor four will be
used (parameter = 0.2).
This method only supports 2-D images (until further notice).

MTS

The MTS method (marked as GRS in the literature below) uses a first order Taylor
approximation of the equation in1(t) = in2(t-s) at scale parameter. Setting parameter
to zero, a scale of 1 will be used. This means that the images will be smoothed with a
Gaussian kernel of 1. This is the more accurate one of the two methods, and therefore is the
DIPlib function reference 205

default.
This method supports images with a dimensionality between 1 and 3.

ITER

The ITER method is an iterative version of the MTS method. It is known that a single
gradient based shift estimation have bias due to truncation of the Taylor expansion series
(see Pham et.al.) The bias can be expressed as a polynomial of the subpixel displacements.
As a result, if Taylor method is applied iteratively and the shift is refined after each
iteration, the bias eventually become negligible. By using just 3 iterations, it is possible to
correct bias that results in high precision O(1e-6).

PROJ

The PROJ method compute shift in each dimension from images’ projections. It is fast and
fairly accurate for high SNR. Should not be used for low SNR

ARGUMENTS

Data type Name Description


dip Image in1 Input image
dip Image in2 Input image
dip FloatArray out Estimated shift
dipf FindShiftMethod method Estimation method
dip float parameter Parameter
The dipf FindShiftMethod enumeration consists of the following flags:
Name Description
DIP FSM DEFAULT Default method (MTS)
DIP FSM INTEGER ONLY Find only integer shift
DIP FSM CPF Use cross-correlation method
DIP FSM FFTS Same
DIP FSM MTS Use Taylor series method
DIP FSM GRS Same

LITERATURE

C.L. Luengo Hendriks, Improved Resolution in Infrared Imaging Using Randomly Shifted
Images, M.Sc. Thesis, Delft University of Technology, 1998 T.Q. Pham, M. Bezuijen, L.J.
van Vliet, K. Schutte, C.L. Luengo Hendriks, Performance of Optimal Registration
Estimators, In Proc. of SPIE 5817 - Visual Information Processing XIV, Defense and
Security Symposium, Orlando, 2005
206 Chapter 2. Function reference

SEE ALSO

CrossCorrelationFT
DIPlib function reference 207

FiniteDifference
A linear gradient filter

SYNOPSIS

#include "dip linear.h"


dip Error dip FiniteDifference ( in, out, boundary, processDim, filter )

DATA TYPES

binary, integer, float, complex

FUNCTION

The FiniteDifference filter implements several basic one dimensional FIR convolution filters.
The dimension in which the operation is to be performed is specified by processDim. The
operation itself is selected with filter. The (1 0 1)/2, (1 -1 0) & (0 1 -1) are difference
filters that approximate a first order derivative, the (1 -2 1) filter approximates a second
order derivative operation. The triangular (1 2 1)/4 filter is a local smoothing filter. All
filters are normalized (sum of filter coeff. is 0 or 1).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BoundaryArray boundary Boundary conditions
dip int processDim ProcessDim
dipf FiniteDifference filter Filter selection
The dipf FiniteDifference enumeration consists of the following flags:
Name Description
DIP FINITE DIFFERENCE M101 out[ii] = (in[ii+1] - in[ii-1])/2
DIP FINITE DIFFERENCE 0M11 out[ii] = in[ii+1] - in[ii]
DIP FINITE DIFFERENCE M110 out[ii] = in[ii] - in[ii-1]
DIP FINITE DIFFERENCE 1M21 out[ii] = in[ii-1] - 2*in[ii] + in[ii+1]
DIP FINITE DIFFERENCE 121 out[ii] = (in[ii-1] + 2*in[ii] + in[ii+1])/4
208 Chapter 2. Function reference

SEE ALSO

General information about convolution


FiniteDifferenceEx, SobelGradient, Uniform, Gauss, SeparableConvolution,
Convolve1d, Derivative
DIPlib function reference 209

FiniteDifferenceEx
A linear gradient filter

SYNOPSIS

#include "dip linear.h"


dip Error dip FiniteDifferenceEx ( in, out, boundary, process, parOrder,
smoothflag )

DATA TYPES

binary, integer, float, complex

FUNCTION

The FiniteDifferenceEx filter implements several basic one dimensional FIR convolution
filters. The difference between this function and FiniteDifference is that this one has an
interface more similar to Gauss and Derivative: it can process different derivatives along
different dimensions at the same time. The first derivative is a convolution with (1 0 -1)/2,
and the second derivative is a convolution with (1 -2 1). When parOrder is 0 for a
dimension, either the triangular smoothing filter (1 2 1)/4 is applied (smoothflag set to
DIP TRUE), or the dimension is not processed at all (smoothflag set to DIP FALSE).
Setting all process to DIP TRUE, all parOrder to 0 except 1 dimension to 1, and
smoothflag to DIP TRUE yields the SobelGradient.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BoundaryArray boundary Boundary conditions
dip BooleanArray process Dimensions to process
dip IntegerArray parOrder Order of Derivative along each dimension
dip Boolean smoothflag Wether or not to smooth in the non-derivative
directions

SEE ALSO

General information about convolution


210 Chapter 2. Function reference

FiniteDifference, SobelGradient, Uniform, Gauss, Derivative


DIPlib function reference 211

FloatArrayCopy
Copy an array

SYNOPSIS

dip Error dip FloatArrayCopy ( dest, src, resources )

FUNCTION

This function copies the float array src to dest. The array dest is created by this function
as well.

ARGUMENTS

Data type Name Description


dip FloatArray * dest Destination array
dip FloatArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

FloatArrayNew, FloatArrayFree, FloatArrayCopy, FloatArrayFind


IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
212 Chapter 2. Function reference

FloatArrayFind
Find value in array

SYNOPSIS

dip Error dip FloatArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
FloatArrayFind will produce an error if value is not found, otherwise found obtains the
search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip FloatArray array Array to find value in
dip float value Value to find
dip int * index Index of the found value
dip Boolean * found Value found or not

SEE ALSO

FloatArrayNew, FloatArrayFree, FloatArrayCopy, FloatArrayFind


IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
DIPlib function reference 213

FloatArrayFree
Array free function

SYNOPSIS

dip Error dip FloatArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip FloatArray * array Array

SEE ALSO

FloatArrayNew, FloatArrayFree, FloatArrayCopy, FloatArrayFind


ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
214 Chapter 2. Function reference

FloatArrayNew
Array allocation function

SYNOPSIS

dip Error dip FloatArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip FloatArray and sets the size of the array
to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip FloatArray * array Array
dip int size Size
dip float value Initial value
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

FloatArrayNew, FloatArrayFree, FloatArrayCopy, FloatArrayFind


ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
DIPlib function reference 215

Floor
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Floor ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the floor of the input image values, and outputs a signed integer typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Ceil, Sign, Truncate, Fraction, NearestInt


216 Chapter 2. Function reference

FourierTransform
Computes the Fourier transform

SYNOPSIS

#include "dip transform.h"


dip Error dip FourierTransform ( in, out, trFlags, process, theFuture )

DATA TYPES

binary, integer, float, complex

FUNCTION

Performs a Fourier transform on in and places the result in out.


Normalisation: 1/sqrt(dimension) for each dimension.
Defaults: process may be zero, indicating that all dimensions should be processed.
Sampling in Fourier Domain (FD): Let one pixel in the spatial domain (SD) be Delta SD
[m], then one pixel in the FD is Delta FD = 1/(Delta SD * N) [mˆ-1], where N is the width
of the image in pixels. As a consequence the maximal frequency in the FD image is N/2 *
1/(Delta SD * N) = 1/(2 * Delta SD) [mˆ-1] and is thus independent of the image width N
and only related to the Nyquist frequency. The frequency of one FD pixel is therefore
related to the image width N.
Note: In consequence of the above the FD resolution will not be isotropic if the image size
are not square.
Note: Spatial zero-padding of the image increases the FD resolution only apparently (empty
magnification).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dipf FourierTransform trFlags Transform flags
dip BooleanArray process (0) Dimensions to process
void * theFuture For future use, should be set to zero
The dipf FourierTransform enumeration consists of the following flags:
DIPlib function reference 217

Name Description
DIP TR FORWARD Forward transformation
DIP TR INVERSE Inverse transformation

SEE ALSO

HartleyTransform
218 Chapter 2. Function reference

Fraction
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Fraction ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the fraction of the input image values, and outputs a float typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Ceil, Floor, Sign, Truncate, NearestInt


DIPlib function reference 219

FrameWorkProcessArrayFree
Array free function

SYNOPSIS

dip Error dip FrameWorkProcessArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip FrameWorkProcessArray * array Array

SEE ALSO

FrameWorkProcessArrayNew, FrameWorkProcessArrayFree
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
220 Chapter 2. Function reference

FrameWorkProcessArrayNew
Array allocation function

SYNOPSIS

dip Error dip FrameWorkProcessArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip FrameWorkProcessArray and sets the
size of the array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip FrameWorkProcessArray * array Array
dip int size Size
dip FrameWorkProcess value Initial value
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

FrameWorkProcessArrayNew, FrameWorkProcessArrayFree
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
DIPlib function reference 221

FTBox
Generates the Fourier transform of a box

SYNOPSIS

#include "dip generation.h"


dip Error dip FTBox ( image, length, scale, amplitude )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of a box with the half length of its sides specified by
length and scale.

ARGUMENTS

Data type Name Description


dip Image image Output Image
dip float length Length
dip FloatArray scale Scale
dip float amplitude Amplitude

SEE ALSO

FTEllipsoid, FTSphere, FTCube, FTCross, FTGaussian


222 Chapter 2. Function reference

FTCross
Generates the Fourier transform of a cross

SYNOPSIS

#include "dip generation.h"


dip Error dip FTCross ( image, length, scale, amplitude )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of a cross with the length of its sides specified by length
and radius.

ARGUMENTS

Data type Name Description


dip Image image Output Image
dip float length Length of the cross’ axes
dip FloatArray scale Scale
dip float amplitude Amplitude

SEE ALSO

FTEllipsoid, FTSphere, FTBox, FTCube, FTGaussian


DIPlib function reference 223

FTCube
Generates the Fourier transform of a cube

SYNOPSIS

#include "dip generation.h"


dip Error dip FTCube ( image, length, amplitude )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of a cube with the length of its sides equal to two times
length.

ARGUMENTS

Data type Name Description


dip Image image Output Image
dip float length Length
dip float amplitude Amplitude

SEE ALSO

FTEllipsoid, FTSphere, FTBox, FTCross, FTGaussian


224 Chapter 2. Function reference

FTEllipsoid
Generates Fourier transform of a ellipsoid

SYNOPSIS

#include "dip generation.h"


dip Error dip FTEllipsoid ( image, radius, scale, amplitude )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of an ellipsoid with the length of its axes specified by
radius and scale.

ARGUMENTS

Data type Name Description


dip Image image Output Image
dip float radius Radius
dip FloatArray scale Scale
dip float amplitude Amplitude

LITERATURE

L.J. van Vliet, Grey-Scale Measurements in Multi-Dimensional Digitized Images, Ph.D.


thesis Delft University of Technology, Delft University Press, Delft, 1993

KNOWN BUGS

This function is only implemented for images with a dimensionality up to three.

SEE ALSO

FTSphere, FTBox, FTCube, FTCross, FTGaussian


DIPlib function reference 225

FTGaussian
Generates the Fourier transform of a Gaussian

SYNOPSIS

#include "dip generation.h"


dip Error dip FTGaussian ( output, sigma, volume, cutoff )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of a Gaussian with sigma’s sigma. (The Fourier transform
of a Gaussian, is a Gaussian.) volume is the integral of the Gaussian in the spatial domain.
The cutoff variable can be used to avoid the calculation of the exponent of large negative
values, which is can be very time consuming. Values of the exponent that are below cutoff
yield a 0 value for the exponent. When cutoff is set to 0 or a positive value,
DIP GENERATION EXP CUTOFF is used (it is defined as -50).

ARGUMENTS

Data type Name Description


dip Image output Output Image
dip FloatArray sigma Sigma of the Gaussian
dip float volume Total intensity of the Gaussian
dip float cutoff Cutoff value for the exponent

SEE ALSO

FTEllipsoid, FTSphere, FTBox, FTCube, FTCross


226 Chapter 2. Function reference

FTSphere
Generated Fourier transform of a sphere

SYNOPSIS

#include "dip generation.h"


dip Error dip FTSphere ( image, radius, amplitude )

DATA TYPES

Output: sfloat, scomplex

FUNCTION

Generates the Fourier transform of a sphere with radius radius and an amplitude of
amplitude.

ARGUMENTS

Data type Name Description


dip Image image Output Image
dip float radius Radius
dip float amplitude Amplitude

KNOWN BUGS

This function is only implemented for images with a dimensionality up to three.

SEE ALSO

FTEllipsoid, FTBox, FTCube, FTCross, FTGaussian


DIPlib function reference 227

GaborIIR
Infinite impulse response filter

SYNOPSIS

#include "dip iir.h"


dip Error dip GaborIIR ( in, out, boundary, ps, sigmas, frequencies, order,
truncation )

DATA TYPES

binary, integer, float

FUNCTION

Recursive infinite impulse response implementation of the Gabor filter.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip FloatArray frequencies frequencies
dip IntegerArray order order
dip float truncation Truncation

SEE ALSO

GaussIIR
228 Chapter 2. Function reference

Gauss
Gaussian Filter

SYNOPSIS

#include "dip linear.h"


dip Error dip Gauss ( in, out, boundary, process, sigmas, order, truncation )

DATA TYPES

binary, integer, float

FUNCTION

Finite impulse response implementation of a Gaussian convolution filter and Gaussian


derivative convolution filters.
The Gaussian kernel is cut off at truncation times the sigma of the filter (in each
dimension). The sum of the Gaussian’s coefficients is normalised to one. A truncation of
zero or less indicates that the global preferred truncation ought to be used, see
dip GlobalGaussianTruncationSet. For the derivatives, the trunction value is increased
slightly: the actual value for truncation used is truncation + 0.5*order. The minimum
filter size is 3 pixels, or 5 pixels for the 3rd order derivative.
Both the process and the order parameter may be zero. If process is zero all dimensions
are processed. If order is zero no derivatives are taken.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray process (0) Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip IntegerArray order (0) Order of Derivative along each dimension
dip float truncation (<0) Truncation of Gaussian
DIPlib function reference 229

LIMITATIONS

The order of the derivative is limited to the interval 0-3. Sigmas considerably smaller than
1.0 will yield nonsensical results.

SEE ALSO

See sections 9.4, “Smoothing operations”, and 9.5, “Derivative-based operations”, in


“Fundamentals of Image Processing”.
General information about convolution
GaussFT, GaussIIR, Derivative, dip GlobalGaussianTruncationSet
230 Chapter 2. Function reference

GaussFT
Gaussian Filter through the Fourier Domain

SYNOPSIS

#include "dip linear.h"


dip Error dip GaussFT ( in, out, sigmas, order, truncation )

DATA TYPES

binary, integer, float, complex

FUNCTION

Fourier Domain implementation of a Gaussian convolution filter and Gaussian derivative


convolution filters. The Gaussian kernel in the Fourier Domain is cut off at the equivalent of
truncation times sigmas. If truncation is smaller or equal to 0, it is cut off where the
argument to exp is smaller than -50, as in FTGaussian.
The order parameter may be zero, in which case no derivatives are taken.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip FloatArray sigmas Sigma of Gaussian
dip IntegerArray order (0) Order of Derivative along each dimension
dip float truncation Truncation of Gaussian kernel

SEE ALSO

See sections 9.4, “Smoothing operations”, and 9.5, “Derivative-based operations”, in


“Fundamentals of Image Processing”.
General information about convolution
Gauss, GaussIIR, Derivative
DIPlib function reference 231

GaussianNoise
Generate an image disturbed by Gaussian noise

SYNOPSIS

#include "dip noise.h"


dip Error dip GaussianNoise ( in, out, variance, random )

DATA TYPES

integer, float

FUNCTION

Generate an image disturbed by additive Gaussian noise.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float variance Variance of the Gaussian distribution the noise is drawn
from
dip Random * random Pointer to a random value structure

EXAMPLE

Get a image with additive Gaussian noise as follows:

dip_Image in, out;


dip_float variance;
dip_Random random;

variance = 1.0;
DIPXX(dip_GaussianNoise(in, out, variance, &random ));

SEE ALSO

RandomVariable, RandomSeed, UniformNoise, PoissonNoise, BinaryNoise


232 Chapter 2. Function reference

GaussianRandomVariable
Gaussian random variable generator

SYNOPSIS

#include "dip noise.h"


dip Error dip GaussianRandomVariable ( random, mean, variance, output1,
output2 )

FUNCTION

dip GaussianRandomVariable uses the algorithm, described by D.E. Knuth as the Polar
Method, to generate two Gaussian distributed random variables.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip float mean Mean of the distribution, the samples are drawn from
dip float variance Variance of the distribution, the samples are drawn from
dip float * output1 First output value
dip float * output2 Second output value

EXAMPLE

Get two Gaussian random variable as follows:

dip_Random random;
dip_float mean, variance, value1, value2;

mean = 0.0;
variance = 1.0;
DIPXX(dip_GaussianRandomVariable( &random, mean, variance, &value1, &value2 ));

LITERATURE

Knuth, D.E., Seminumerical algorithms, The art of computer programming, vol. 2, second
edition Addison-Wesley, Menlo Park, California, 1981.
DIPlib function reference 233

SEE ALSO

RandomVariable, RandomSeed, UniformRandomVariable, PoissonRandomVariable,


BinaryRandomVariable
234 Chapter 2. Function reference

GaussianSigma
Adaptive Gaussian smoothing filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip GaussianSigma ( in, out, boundary, sigma, gaussSigma,
outputCount, truncation )

DATA TYPES

integer, float

FUNCTION

The GaussianSigma filter is an adaptive Gauss-ian smoothing filter. The value of the pixel
under investigation is replaced by the Gaussian-weighted average of the pixelvalues in the
filter region which lie in the interval +/- 2 sigma from the value of the pixel that is filtered.
The filter region is specified by gaussSigma and truncation. If outputCount is DIP TRUE,
the output values represent the number of pixel over which the average has been calculated.
When threshold is DIP TRUE, the pixel intensities are being thresholded at +/- 2 sigma,
when it is set to DIP FALSE, the intensities are weighted with the Gaussian difference with
the intensity of the central pixel.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BoundaryArray boundary Boundary conditions
dip float sigma Sigma
dip FloatArray gaussSigma Sigma of Gaussian
dip Boolean outputCount Output the Count
dip float truncation (-1.0) Truncation of Gaussian

LITERATURE

John-Sen Lee, Digital Image Smoothing and the Sigma Filter, Computer Vision, Graphics
and Image Processing, 24, 255-269, 1983
DIPlib function reference 235

SEE ALSO

Sigma, BiasedSigma, Gauss


236 Chapter 2. Function reference

GaussIIR
Infinite impulse response filter

SYNOPSIS

#include "dip iir.h"


dip Error dip GaussIIR ( in, out, boundary, process, sigmas, order,
truncation )

DATA TYPES

binary, integer, float

FUNCTION

Recursive infinite impulse response implementation of the Gauss filter.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray process Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip IntegerArray order Order of Derivative
dip IntegerArray order Order of the IIR Filter
dip int designMethod Method of IIR design
dip float truncation Truncation of Gaussian

SEE ALSO

Gauss, Derivative
DIPlib function reference 237

GeneralisedKuwahara
Generalised Kuwahara filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip GeneralisedKuwahara ( in, selection, out, se, boundary,
filterSize, shape, minimum )

DATA TYPES

binary, integer, float

FUNCTION

This function is a generalisation of the Kuwahara filter in the sense that is does not use the
variance criterion to select the smoothed value, but instead accepts an image with the
selection values. The algorithm finds, for every pixel, the minimum or maximum (as
specified with minimum) value of selection within the filter window (its size specified by
filterSize).
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image selection Selection
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterSize Filter sizes
dip FilterShape shape Filter shape
dip Boolean minimum Minimum
The enumerator dip FilterShape contains the following constants:
238 Chapter 2. Function reference

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

Kuwahara, VarianceFilter
DIPlib function reference 239

Get
Get a pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Get ( in, const, cor, adjust )

FUNCTION

This functions get the value of a pixel in image in at the coordinate cor. If cor is zero, the
first pixel value is retrieved.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image const 0-D output image
dip IntegerArray cor Pixel coordinate
dip Boolean adjust Adjust data type of output image

SEE ALSO

GetInteger, GetFloat, GetComplex, dip PixelGetInteger, dip PixelGetFloat, Set


240 Chapter 2. Function reference

GetComplex
Get complex pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip GetComplex ( in, value, cor )

FUNCTION

This functions get the value of a pixel in image in at the coordinate cor. If cor is zero, the
first pixel value is retrieved.

ARGUMENTS

Data type Name Description


dip Image in Input
dip complex * value Value
dip IntegerArray cor Pixel coordinate

SEE ALSO

Get, GetInteger, GetFloat, dip PixelGetInteger, dip PixelGetFloat, Set


DIPlib function reference 241

GetFloat
Get float pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip GetFloat ( in, value, cor )

FUNCTION

This functions get the value of a pixel in image in at the coordinate cor. If cor is zero, the
first pixel value is retrieved.

ARGUMENTS

Data type Name Description


dip Image in Input
dip float * value Value
dip IntegerArray cor Pixel coordinate

SEE ALSO

Get, GetInteger, GetComplex, dip PixelGetInteger, dip PixelGetFloat, Set


242 Chapter 2. Function reference

GetInteger
Get integer pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip GetInteger ( in, value, cor )

FUNCTION

This functions get the value of a pixel in image in at the coordinate cor. If cor is zero, the
first pixel value is retrieved.

ARGUMENTS

Data type Name Description


dip Image in Input
dip int * value Value
dip IntegerArray cor Pixel coordinate

SEE ALSO

Get, GetFloat, GetComplex, dip PixelGetInteger, dip PixelGetFloat, Set


DIPlib function reference 243

GetLibraryInformation
Support function

SYNOPSIS

#include "dip information.h"


dip Error dip GetLibraryInformation ( info )
#include "dipio image.h"
dip Error dipio GetLibraryInformation ( info )

FUNCTION

This function fills the given dip LibraryInformation structure with information about the
release version and date, copyright information and author information of the DIPlib library.

ARGUMENTS

Data type Name Description


dip LibraryInformation* info DIPlib library information
244 Chapter 2. Function reference

GetLine
Get a line from an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip GetLine ( in, out, cor, dimension )

DATA TYPES

binary, integer, float, complex

FUNCTION

Get a orthogonal line form an image. The position of the line in the image is specified by
the coordinates at which its left most pixel (cor) should be placed and on which dimension
of the image, the dimension of the line maps (dimension). If in has If in has a different
type than out, it will be converted to the type of out.

ARGUMENTS

Data type Name Description


dip Image in Input Image
dip Image out Output Line Image
dip IntegerArray cor Coordinate in the image of the left most pixel of the
line
dip int dimension Dimension of the image on which the line’s dimension
maps

SEE ALSO

GetSlice, PutSlice, PutLine


DIPlib function reference 245

GetMaximumAndMinimum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip GetMaximumAndMinimum ( in, mask, max, min )

DATA TYPES

integer, float

FUNCTION

This function gets both the maximum and minimum of all the pixel values in the in image.
Optionally, a mask image can be specified to exclude pixels from this search.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image mask (0) Mask image
dip float *max Pointer to maximum variable
dip float *min Pointer to minimum variable

SEE ALSO

Maximum, Minimum
246 Chapter 2. Function reference

GetObjectLabels
Lists object labels in image

SYNOPSIS

dip Error dip GetObjectLabels ( in, mask, labels, nullIsObject, resources )

DATA TYPES

binary, integer

FUNCTION

This function produces an array of object labels present in the image in. Optionally, mask
can mask the regions in in where to search for labels. The boolean nullIsObject specifies
whether or not to treat the value zero as an object label.

ARGUMENTS

Data type Name Description


dip Image in Input label image
dip Image mask Mask image
dip IntegerArray * labels Array of labels
dip Boolean nullIsObject treat the value zero ad an object label
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Label, IntegerArrayFind
DIPlib function reference 247

GetRank
Value selection function

SYNOPSIS

#include "dip sort.h"


dip Error dip GetRank ( array, datatype, min, max, rank, value )

FUNCTION

GetRank gets the value at rank rank in the array array. min should be set to the first
index of array, max to the last. dip GetRank will use array for temporary storage, so the
values in the array will be changed are this function is ready.

ARGUMENTS

Data type Name Description


dip float * array Array to searched in
dip DataType datatype
dip int min minimal array index
dip int max maximal array index
dip int rank Rank
dip float * value Value of the rank element

EXAMPLE

This example finds the median value for the array.

dip_float array[ SIZE ], median;


dip_int rank;

/* fill the array with values */

rank = SIZE/2;
DIPXX( dip_GetRank( array, DIP_DT_FLOAT, 0, (SIZE - 1), rank, &median ));

SEE ALSO

General information about sorting


DistributionSort, DistributionSortIndices, DistributionSortIndices16,
248 Chapter 2. Function reference

InsertionSort, InsertionSortIndices, InsertionSortIndices16, QuickSort,


QuickSortIndices, QuickSortIndices16, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
DIPlib function reference 249

GetSlice
Get a slice from an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip GetSlice ( in, out, cor, dim1, dim2 )

DATA TYPES

binary, integer, float, complex

FUNCTION

Get a orthogonal slice from a image. The requested slice is selected by specifying its upper
left corner (cor) and on which dimensions of the image, the dimensions of the slice map
(dim1, dim2). If in has a different type than out, it will be converted to the type of out.

ARGUMENTS

Data type Name Description


dip Image in 3D Input Image
dip Image out 2D Output Image
dip IntegerArray cor Coordinate in in of the upper left corner of the slice
dip int dim1 Dimension of in on which the slice’s first dimension maps
dip int dim2 Dimension of in on which the slice’s second
dimensionmaps

SEE ALSO

PutSlice, GetLine, PutLine


250 Chapter 2. Function reference

GetUniqueNumber
Obtain an unique value

SYNOPSIS

#include "dip globals.h"


dip Error dip GetUniqueNumber ( number )

FUNCTION

This function gives an unique integer value. The value is unique is the sense that its value
has not yet been returned by this function nor will it be returned by subsequent calls.

ARGUMENTS

Data type Name Description


dip int * number Pointer to an integer in which the number is stored
DIPlib function reference 251

GlobalBoundaryConditionGet
Get global Boundary Conditions

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalBoundaryConditionGet ( boundary, size, resources )

FUNCTION

This function allocates the boundary array array of size size with the global default
boundary conditions for each dimension of the image. The initial values of this global array
is DIP BC SYMMETRIC MIRROR.

ARGUMENTS

Data type Name Description


dip BoundaryArray * boundary Pointer to Boundary conditions
dip int size Size of the new array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Boundary conditions
GlobalBoundaryConditionSet, GlobalGaussianTruncationGet,
GlobalGaussianTruncationSet, GlobalFilterShapeGet, GlobalFilterShapeSet
252 Chapter 2. Function reference

GlobalBoundaryConditionSet
Set global boundary conditions

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalBoundaryConditionSet ( boundary )

FUNCTION

This function sets the global boundary conditions equal to boundary.

ARGUMENTS

Data type Name Description


dip BoundaryArray boundary Boundary conditions

SEE ALSO

GlobalBoundaryConditionGet, GlobalGaussianTruncationGet,
GlobalGaussianTruncationSet, GlobalFilterShapeGet, GlobalFilterShapeSet
DIPlib function reference 253

GlobalFilterShapeGet
Get global filter shape value

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalFilterShapeGet ( shape )

FUNCTION

This function gets the global default of the filter shape used by DIPlib’s linear and
morphology filters. The initial value of this global is DIP FLT SHAPE RECTANGULAR.

ARGUMENTS

Data type Name Description


dip FilterShape * shape Filter shape

SEE ALSO

GlobalBoundaryConditionGet, GlobalBoundaryConditionSet,
GlobalGaussianTruncationGet, GlobalGaussianTruncationSet, GlobalFilterShapeSet
254 Chapter 2. Function reference

GlobalFilterShapeSet
Set the global filter shape value

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalFilterShapeSet ( shape )

FUNCTION

This function sets the global default of the filter shape used by DIPlib’s linear and
morphology filters. The initial value of this global is DIP FLT SHAPE RECTANGULAR.

ARGUMENTS

Data type Name Description


dip FilterShape shape Filter shape

SEE ALSO

GlobalBoundaryConditionGet, GlobalBoundaryConditionSet,
GlobalGaussianTruncationGet, GlobalGaussianTruncationSet, GlobalFilterShapeGet
DIPlib function reference 255

GlobalGaussianTruncationGet
Get the global gaussian truncation

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalGaussianTruncationGet ( truncation )

FUNCTION

This function gets the global default of the truncation used by the finite impluse response
implementation of the Gauss (derivative) filter. The initial value of this global is 3.0.

ARGUMENTS

Data type Name Description


dip float * truncation Gaussian truncation

SEE ALSO

GlobalBoundaryConditionGet, GlobalBoundaryConditionSet,
GlobalGaussianTruncationSet, GlobalFilterShapeGet, GlobalFilterShapeSet
256 Chapter 2. Function reference

GlobalGaussianTruncationSet
Set the global gaussian truncation

SYNOPSIS

#include "dip globals.h"


dip Error dip GlobalGaussianTruncationSet ( void )

FUNCTION

This function sets the global default of the truncation used by the finite impluse response
implementation of the Gauss (derivative) filter. The initial value of this global is 3.0.

ARGUMENTS

Data type Name Description


dip float truncation Truncation

SEE ALSO

GlobalBoundaryConditionGet, GlobalBoundaryConditionSet,
GlobalGaussianTruncationGet, GlobalFilterShapeGet, GlobalFilterShapeSet
DIPlib function reference 257

GradientDirection2D
Derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip GradientDirection2D ( in, out, boundary, ps, sigmas, tc,
atanFlavour, flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes the gradient direction of an image using the Derivative function. This functions
supports only two dimensional images.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float tc Truncation of Gaussian
dip GradientDirectionAtanFlavour atanFlavour Atan flavour
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx
258 Chapter 2. Function reference

SEE ALSO

See section 9.5, “Derivative-based operations”, in “Fundamentals of Image Processing”.


Derivative, GradientMagnitude, Laplace, Dgg, LaplacePlusDgg, LaplaceMinDgg
DIPlib function reference 259

GradientMagnitude
Derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip GradientMagnitude ( in, out, boundary, ps, sigmas, tc, flavour
)

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes the gradient magnitude of an image using the Derivative function.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps (0) Dimensions to process
dip FloatArray sigmas Sigma of the Gaussian
dip float tc Gaussian truncation
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx

SEE ALSO

See section 9.5, “Derivative-based operations”, in “Fundamentals of Image Processing”.


260 Chapter 2. Function reference

Derivative, GradientDirection2D, Laplace, Dgg, LaplacePlusDgg, LaplaceMinDgg


DIPlib function reference 261

Greater
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip Greater ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when for corresponding pixels in1 > in2.
This is the same as Compare with the DIP SELECT GREATER selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to a functionality similar to that of Threshold.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Equal, Lesser, NotEqual, NotGreater, NotLesser, SelectValue,


NotZero
262 Chapter 2. Function reference

GreyWeightedDistanceTransform
Grey weighted distance transform

SYNOPSIS

#include "dip distance.h"


dip Error dip GreyWeightedDistanceTransform ( in, seed, out, distance,
chamfer, neighborhood, metric )

DATA TYPES

in: integer, float


seed: binary

FUNCTION

GreyWeightedDistanceTransform determines the grey weighted distance transform of the


object elements in the in image and returns the result in the out image. The implemented
algorithm uses a heap sort for sorting the pixels to be processed.
The images in and seed must have the same dimensions. The out image will be converted
to a sfloat typed image. The seed image defines the elements that are part of the object
for which the GDT is determined. It can be any type of image where all image elements not
equal to 0 are considered to be part of the object(s). Those elements that are neighboring an
object element in the output image are considered seeds. Before any seeds are detected the
borders of the out image are set to 0. The size of the border is determined by the chamfer
metric size (see below). In case of a 3 by 3 chamfer metric the image border is one element,
in case of a 5 by 5 chamfer it is 2 elements. Elements in the border are not considered seeds.
If no valid seeds are found the routine will terminate with an Illegal value error code.
The chamfer metric is defined by two parameters: neighborhood and metric. neigborhood
should supply the different relative addresses of the neighboring elements according to the
chamfer metric. The first element neighborhood[0] contains the number of elements in the
chamfer neighborhood. The next three elements contain the maximum number of elements
a chamfer metric exceeds the central element. The rest of the elements (starting from the
fifth element) contain addresses of the different chamfer elements relative to the central
element. The metric array contains the corresponding chamfer metric value. An example of
a 3x3 neighborhood array with the corresponding metric is:

neighborhood[0] = 8 (number of elements)


neighborhood[1] = 1 (x-border size)
neighborhood[2] = 1 (y-border size)
DIPlib function reference 263

neighborhood[3] = 0 (z-border size)


neighborhood[4] = -imagewidth - 1, metric[0] = 7
neighborhood[5] = -imagewidth, metric[1] = 5
neighborhood[6] = -imagewidth + 1, metric[2] = 7
neighborhood[7] = -1, metric[3] = 5
neighborhood[8] = 1, metric[4] = 5
neighborhood[9] = imagewidth - 1, metric[5] = 7
neighborhood[10] = imagewidth, metric[6] = 5
neighborhood[11] = imagewidth + 1, metric[7] = 7

where imagewidth represents the width of the image in image pixels. If both neighborhood
and metric pointers are NULL, the chamfer variable can be set to either 1 (indicating a 3x3
or 3x3x3 chamfer using only 4 or 6 direct neighbors), 3 (indicating a 3x3 or 3x3x3 chamfer,
using all neighbors) or 5 (indicating a 5x5 or 5x5x5 chamfer). In these cases a preset
neighborhood and metric arrays will be used.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image seed Seed image
dip Image out Integrated grey-value over least-resistance path
(output image)
dip Image distance Metric distance over least-resistance path (output
image)
dip int chamfer Chamfer distance metric
dip IntegerArray neighborhood Neighborhood
dip FloatArray metric Metric

LITERATURE

“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.
“Shading from shape, the eikonal equation solved by grey-weighted distance transform”, P.W.
Verbeek and B.J.H. Verwer, Pattern Recognition Letters, vol. 11, no. 10, 1990, 681-690.
“Local distances for distance transformations in two and three dimensions”, B.J.H. Verwer,
Pattern Recognition Letters, vol. 12, no. 11, 1991, 671-682.
“Distance Transforms, Metrics, Algorithms, and Applications”, B.J.H. Verwer, Ph.D. thesis
Delft University of Technology, Delft University Press, Delft, 1991.
“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.
“Quantitative Analysis in Confocal Image Cytometry”, Karel C. Strasters, Delft University
264 Chapter 2. Function reference

Press, Delft, 1994. ISBN 90-407-1038-4, NUGI 841

KNOWN BUGS

GreyWeightedDistanceTransform works only on 2 or 3-dimensional images. It will not


work if any of the images has different strides.
GreyWeightedDistanceTransform does not process pixels in a 2-pixel border around the
edge. If this is an issue, consider adding 2 pixels on each side of your image.
The function GrowRegionsWeighted produces a grey-weighted distance transform without
these limitations and with some other possibilities.

AUTHOR

Karel C. Strasters, adapted to DIPlib by Geert M.P. van Kempen

SEE ALSO

GrowRegionsWeighted, EuclideanDistanceTransform, VectorDistanceTransform


DIPlib function reference 265

GrowRegions
Dilate the regions in a labelled image

SYNOPSIS

#include "dip regions.h"


dip Error dip GrowRegions ( in, grey, mask, out, connectivity, iterations,
order )

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 with several options:
If grey is NULL, the regions are dilated iterations steps, according to connectivity (see
The connectivity parameter), and optionally constrained by mask. This is the labelled
equivalent to BinaryPropagation. If iterations is 0, the objects are dilated until no
further change is possible. order is ignored.
If an image grey is given, the labels are grown in order of the grey-values in grey. order
indicates whether pixels with high grey-values are added first or last. iterations is
ignored, and mask is an optional constraint. This is a watershed algorithm with initial
labels. The function Watershed does not accept an initial segmentation, so these two
functions complement each other. Note that GrowRegions does not leave any watershed
pixels in between the regions.
266 Chapter 2. Function reference

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 int connectivity Connectivity
dip int iterations Number of iterations
dipf GreyValueSortOrder order Whether to grow from low to high or high
to low
The dipf GreyValueSortOrder enumeration consists of the following values:
Name Description
DIP GVSO HIGH FIRST Process the pixels from high grey-value to low grey-value.
DIP GVSO LOW FIRST Process the pixels from low grey-value to high grey-value.

SEE ALSO

GrowRegionsWeighted, Watershed, BinaryPropagation, Label


DIPlib function reference 267

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:
268 Chapter 2. Function reference

0 0 0
sqrt(ps0*ps0+4*ps1*ps1) sqrt(ps0*ps0+4*ps1*ps1)
ps1
sqrt(4*ps0*ps0+ps1*ps1)
sqrt(ps0*ps0+ps1*ps1) sqrt(ps0*ps0+ps1*ps1)
sqrt(4*ps0*ps0+ps1*ps1)
0 ps0 0 ps0 0
ps1
sqrt(ps0*ps0+ps1*ps1)
sqrt(4*ps0*ps0+ps1*ps1) sqrt(ps0*ps0+ps1*ps1)
sqrt(4*ps0*ps0+ps1*ps1)
0 0 0
sqrt(ps0*ps0+4*ps1*ps1) sqrt(ps0*ps0+4*ps1*ps1)
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


DIPlib function reference 269

HartleyTransform
Computes the Hartley transform

SYNOPSIS

#include "dip transform.h"


dip Error dip HartleyTransform ( in, out, trFlags, process )

DATA TYPES

binary, integer, float

FUNCTION

This function computes a Hartley transform on in and places the result in out.
Normalisation: 1/sqrt(dimension) for each dimension.
The main advantage of the Hartley transform over the Fourier transform is that is requires
half the storage for real valued images. Note, that is also possible to directly reduce the
storage requirements of the Fourier transform by just storing the right half plane, since for
real valued images the left half plane can be derived from the right half using the symmetry
properties of the Fourier transform.
Unfortunately there seem to be two definitions of the multi-dimensional Hartley transform
(they are identical in the 1-D case). DIPlib implements the Bracewell (see below) variant,
since this one is easy to implement and inherits the storage advantage from the 1-D case.
The following are references which each use a different variant (all scaling factors have been
dropped):
Bracewell, “Discrete Hartley Transform”, J. Opt. Soc. Am, vol. 73, no. 12, December 1983 :

DHT(u,v) = Sum Sum I(x,y) cas( ux ) cas( vy )


y x

Kenneth R. Castleman, “Digital image processing”, Prentice Hall, 1996 :

DHT(u,v) = Sum Sum I(x,y) cas( ux + vy )


y x

Using cas(a) = cos(a) + sin(a) :

cas(ux)cas(vy) = cos(ux)cos(vy)+cos(ux)sin(vy)+sin(ux)cos(vy)+sin(ux)sin(vy)
270 Chapter 2. Function reference

cas(ux+vy) = cos(ux)cos(vy)+cos(ux)sin(vy)+sin(ux)cos(vy)-sin(ux)sin(vy)
^^^

A subtle difference. The two definitions have very similar properties, for example the
convolution property.
In implementation terms, Bracewell is equivalent to perform the one-dimensional Hartley
transform along each dimension. The Castleman variant is equivalent to the definition:
DHT = re(DFT) - im(DFT). On a final note, I’ve not noticed mention of the difference
between the two variants, so the indications Bracewell’s and Castleman’s variant are not and
should not be accepted “labels” to refer to the variants (For both variants I have selected
the first reference I came across, not chronologically the first reference to use the variant).
Defaults: process may be zero, indicating that all dimensions should be processed.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dipf FourierTransform trFlags Transformation flags
dip BooleanArray process (0) Dimensions to process
The dipf FourierTransform enumeration consists of the following flags:
Name Description
DIP TR FORWARD Forward transformation
DIP TR INVERSE Inverse transformation

SEE ALSO

FourierTransform
DIPlib function reference 271

HasNormalStride
Determines whether an image has a normal stride

SYNOPSIS

dip Error dip HasNormalStride( image, &answer )

FUNCTION

Determines whether an image has a normal stride. If answer is not zero, the verdict is
passed in this variable. Otherwise, HasNormalStride returns an error in case image does
not have a normal stride.

ARGUMENTS

Data type Name Description


dip Image image The image under investigation
dip Boolean * answer The verdict

SEE ALSO

The image structure


ImageGetStride, IsScalar
272 Chapter 2. Function reference

HysteresisThreshold
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip HysteresisThreshold ( in, out, low, high )

DATA TYPES

integer, float

FUNCTION

Performs hysteresis thresholding. From the binary image (in>low) only those regions are
selected for which at least one location also has (in>high). The output image will be a
binary image with foreground pixel 1 and background pixel 0;

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float low Lower threshold
dip float high Higher threshold

SEE ALSO

Threshold, RangeThreshold, IsodataThreshold


DIPlib function reference 273

IDivergence
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip IDivergence ( in1, in2, mask, out )

DATA TYPES

binary, integer, float

FUNCTION

Calculates the I-divergence between each pixel value of in1 and in2. Optionally the mask
image can be used to exclude pixels from the calculation by setting the value of these pixels
in mask to zero.
The I-Divergence is defined as: I(x,y) = x ln(x/y) - (x - y) and is divied by the
number of pixels. It is the -log of a possion distribution p(x,y)=e^(-y)/x!-y^x with the
stirling approximation for ln x!. For x=0, the stirling approximation would fail, y is
returned.

ARGUMENTS

Data type Name Description


dip Image in1 First input, Data:x
dip Image in2 Second input, Model:y
dip Image mask Mask
dip Image out Output

LITERATURE

Why Least Squares and Maximum Entropy? An axiomatic approach to inference for linear
inverse problems , I. Csiszar, The Annals of Statistics, 19, 2032-2066, 1991.

SEE ALSO

MeanError, MeanSquareError, RootMeanSquareError, MeanAbsoluteError, LnNormError


274 Chapter 2. Function reference

ImageArrayFree
Array free function

SYNOPSIS

dip Error dip ImageArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip ImageArray * array Array

SEE ALSO

ImageArrayNew, ImageArrayFree
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 275

ImageArrayNew
Array allocation function

SYNOPSIS

dip Error dip ImageArrayNew ( array, size, resources )

FUNCTION

This function allocates the size elements of a dip ImageArray and sets the size of the array
to size.

ARGUMENTS

Data type Name Description


dip ImageArray * array Array
dip int size Size
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

ImageArrayNew, ImageArrayFree
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
276 Chapter 2. Function reference

ImageAssimilate
Inherit properties of another image

SYNOPSIS

dip Error dip ImageAssimilate( example, target )

FUNCTION

Give the target image the same properties ( type, data type, etc... ) as the example image.
The example image may be either “raw” or “forged”. The target image is forged.
If the target was forged before calling this function, and it exactly matches the example,
nothing happens. If it doesn’t match the example, it is stripped before the properties are
copied.

ARGUMENTS

Data type Name Description


dip Image example An example image
dip Image target The target image

SEE ALSO

ImageCopyProperties, ChangeDataType, ChangeTo0d


DIPlib function reference 277

ImageCheckBooleanArray
Check a boolean array

SYNOPSIS

dip Error dip ImageCheckBooleanArray ( im, array, answer)

FUNCTION

This functions check whether the size of array is equal to the dimensionality of im. If
answer is not zero, it will contain the result of the test, otherwise the
DIP E ARRAY ILLEGAL SIZE will be set when the test has failed.

ARGUMENTS

Data type Name Description


dip Image im Image
dip BooleanArray array Array
dip Boolean * answer Answer

SEE ALSO

ImageCheckIntegerArray, ImageCheckFloatArray, ImageCheckComplexArray,


ImageCheckBoundaryArray
278 Chapter 2. Function reference

ImageCheckBoundaryArray
Check a boundary array

SYNOPSIS

dip Error dip ImageCheckBoundaryArray ( im, array, answer)

FUNCTION

This functions check whether the size of array is equal to the dimensionality of im. If
answer is not zero, it will contain the result of the test, otherwise the
DIP E ARRAY ILLEGAL SIZE will be set when the test has failed.

ARGUMENTS

Data type Name Description


dip Image im Image
dip BoundaryArray array Boundary conditions
dip Boolean * answer Answer

SEE ALSO

ImageCheckIntegerArray, ImageCheckFloatArray, ImageCheckComplexArray,


ImageCheckBoundaryArray
DIPlib function reference 279

ImageCheckComplexArray
Check a complex array

SYNOPSIS

dip Error dip ImageCheckComplexArray ( im, array, answer)

FUNCTION

ARGUMENTS

Data type Name Description


dip Image im Image
dip ComplexArray array Array
dip Boolean * answer Answer

SEE ALSO

ImageCheckIntegerArray, ImageCheckFloatArray, ImageCheckComplexArray,


ImageCheckBoundaryArray
280 Chapter 2. Function reference

ImageCheckFloatArray
Check a float array

SYNOPSIS

dip Error dip ImageCheckFloatArray ( im, array, answer)

FUNCTION

This functions check whether the size of array is equal to the dimensionality of im. If
answer is not zero, it will contain the result of the test, otherwise the
DIP E ARRAY ILLEGAL SIZE will be set when the test has failed.

ARGUMENTS

Data type Name Description


dip Image im Image
dip FloatArray array Array
dip Boolean * answer Answer

SEE ALSO

ImageCheckIntegerArray, ImageCheckFloatArray, ImageCheckComplexArray,


ImageCheckBoundaryArray
DIPlib function reference 281

ImageCheckIntegerArray
Check an integer array

SYNOPSIS

dip Error dip ImageCheckIntegerArray ( im, array, answer)

FUNCTION

This functions check whether the size of array is equal to the dimensionality of im. If
answer is not zero, it will contain the result of the test, otherwise the
DIP E ARRAY ILLEGAL SIZE will be set when the test has failed.

ARGUMENTS

Data type Name Description


dip Image im Image
dip IntegerArray array Integer rray
dip Boolean * answer Answer

SEE ALSO

ImageCheckIntegerArray, ImageCheckFloatArray, ImageCheckComplexArray,


ImageCheckBoundaryArray
282 Chapter 2. Function reference

ImageCopyProperties
Copy the properties of an image

SYNOPSIS

dip Error dip ImageCopyProperties( example, target )

FUNCTION

Give the target image the same properties ( type, data type, etc... ) as the example image.
The example image may be either “raw” or “forged”, whereas the target image must be
“raw”. See ImageAssimilate.

ARGUMENTS

Data type Name Description


dip Image example An example image
dip Image target The target image

SEE ALSO

The image structure


DIPlib function reference 283

ImageFileGetInfo
Get information about image in file (in dipIO)

SYNOPSIS

dip Error dipio ImageFileGetInfo ( imInfo, filename, format, addExtensions,


recognised, resources )

FUNCTION

This function opens an image file and fills a dipio ImageFileInformation structure with
the information from that file. imInfo is allocated by this function. Use
ImageFileInformationFree to free this structure, or set the resources parameter for
automatic deallocation. If format is 0, all different ImageRead functions are called in
sequence until the correct format has been found. If you know the format, get the correct
format ID through the registry functions. See File formats recognized by dipIO for a list of
currently supported formats.
The boolean addExtensions specifies whether ImageFileGetInfo should try to add file
format extensions to filename, if the registered file format reader fails to recognise
filename straight away. The extensions are provided by the registered file readers.
If recognised is not zero, ImageFileGetInfo will set it to DIP TRUE when it has been able to
read filename, and it will set it to DIP FALSE when it is not able to read the file. No error
will be generated in this case.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation * imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name
dip int format ID of file format
dip Boolean addExtensions Add file format extensions to
filename
dip Boolean * recognised Pointer to boolean containing the
file read status
dip Resources resources Resources tracking structure. See
ResourcesNew
284 Chapter 2. Function reference

SEE ALSO

ImageReadCSVInfo, ImageReadGIFInfo, ImageReadICSInfo, ImageReadLSMInfo,


ImageReadPICInfo, ImageReadTIFFInfo, ImageReadJPEGInfo, ImageRead,
ImageReadColour, ImageReadROI
DIPlib function reference 285

ImageFileInformationFree
Free a Image File Information structure (in dipIO)

SYNOPSIS

dip Error dipio ImageFileInformationFree ( imInfo )

FUNCTION

Frees a dipio ImageFileInformation structure allocated through


ImageFileInformationNew or by ImageFileGetInfo.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation * imInfo Structure to free

SEE ALSO

ImageFileInformationNew, ImageFileGetInfo
286 Chapter 2. Function reference

ImageFileInformationNew
Allocate an Image File Information structure (in dipIO)

SYNOPSIS

dip Error dipio ImageFileInformationNew ( newImInfo, name, filetype,


datatype, dims, resources )

FUNCTION

Allocates a dipio ImageFileInformation structure. It must be freed through


ImageFileInformationFree, unless a resources parameter is given, in which case it will
be freed automatically when freeing the resources. This structure is usually allocated by
ImageFileGetInfo.
This function will fill out some of the values in the structure with the values given on the
command line. All of these can be 0.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation * newImInfo Output structure
dip String name Initial value for name
dip String filetype Initial value for filetype
dip DataType datatype Initial value for datatype
dip IntegerArray dims Initial value for dimensions
dip Resources resources Resources tracking structure. See
ResourcesNew
The structure dipio ImageFileInformation contains the following elements:
DIPlib function reference 287

Data type Name Description


dip String name File name
dip String filetype File format string
dip DataType datatype Data type of image
dip int sigbits Significant bits
dip IntegerArray dimensions Dimensions of image
dipio PhotometricInterpretation photometric Color space
dip PhysicalDimensions physDims Physical dimensions structure.
See PhysicalDimensionsNew
dip int numberOfImages Number of images in a TIFF
file. If filetype is not
“TIFF”, this number is not set
dip StringArray history History tags
dip Resources resources Resource tracking; all elements
within this structure are
tracked here
The enumerator dipio PhotometricInterpretation contains the following constants:
Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SEE ALSO

ImageFileInformationFree, ImageFileGetInfo, PhysicalDimensionsNew


288 Chapter 2. Function reference

ImageForge
Allocate pixel data for an image

SYNOPSIS

dip Error dip ImageForge( image )

FUNCTION

Allocates a block of memory to store pixel data for an image. The image must be “raw”,
and will be “forged” afterwards. The routine will fail if the image fields do not contain a
valid combination of values for the image type.

ARGUMENTS

Data type Name Description


dip Image image The image for which the pixel data must be allocated

SEE ALSO

The image structure


ImageNew, ImageFree, ImageStrip, ImageCopyProperties
DIPlib function reference 289

ImageFree
Free an image

SYNOPSIS

dip Error dip ImageFree( image )

FUNCTION

Free any pixel data associated with the image and return all fields to their initial (“raw”)
state by calling ImageStrip. Then the image structure itself is freed. Notice that you must
pass a pointer to the image instead of the image itself. This allows ImageFree to set your
image variable to zero, preventing further use of the now freed image.
Because ImageNew accepts a resources structure to keep track of allocated images, direct
calls to ImageFree should be unnecessary.

ARGUMENTS

Data type Name Description


dip Image * image A pointer to the image to be freed

SEE ALSO

The image structure


ImageNew, ImageForge, ImageStrip, ImageCopyProperties
290 Chapter 2. Function reference

ImageGetData
Get the data pointers of a set of images

SYNOPSIS

dip Error dip ImageGetData( in, idp, iflags, out, odp, oflags, flags,
resources )

FUNCTION

Get the data pointers of a set of images. This function should not be called before the clean
up of the previous invocation (by ResourcesFree) has been performed. Currently no clean
up is required by ImageGetData, but any data pointers obtained by a previous call to this
function should be considered invalid when calling this function. The iflags, oflags, and
flags parameters are not used in the current version. These fields should be set to zero.
The resources parameter is mandatory. Any of the image arrays’ elements may be set to
zero, indicating that it is to be ignored.
No functions that will possibly modify an image should be called after the call to
ImageGetData and before its clean up. The proper time to call ImageGetPlane and
ImageGetStride is right after the call to ImageGetData.

ARGUMENTS

Data type Name Description


dip ImageArray in Array of input images
dip VoidPointerArray * idp Returns input data pointers
dipf ImageGetDataArray iflags Flags for input images
dip ImageArray out Array of output images
dip VoidPointerArray * odp Returns output data pointers
dipf ImageGetDataArray oflags Flags for output images
dipf ImageGetData flags Flags for all images
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

The image structure


ImageGetPlane, ImageGetStride
DIPlib function reference 291

ImageGetDataType
Read the data type field

SYNOPSIS

dip Error dip ImageGetDataType( image, dataType )

FUNCTION

Read the dip Image data type field.

ARGUMENTS

Data type Name Description


dip Image image An image
dip DataType * dataType Returns the data type field

SEE ALSO

The image structure


DIPlib’s data types
ImageSetDataType
292 Chapter 2. Function reference

ImageGetDimensionality
Read the dimensionality field

SYNOPSIS

dip Error dip ImageGetDimensionality( image, dimensionality )

FUNCTION

Read the dip Image dimensionality field.

ARGUMENTS

Data type Name Description


dip Image image An image
dip int * dimensionality Returns the dimensionality field

SEE ALSO

The image structure


ImageGetDimensions
DIPlib function reference 293

ImageGetDimensions
Read the dimensions array

SYNOPSIS

dip Error dip ImageGetDimensions( image, dimensions, resources )

FUNCTION

Read the dip Image dimensions Array. The array that is used to return the dimensions in,
is allocated by this routine using IntegerArrayNew.

ARGUMENTS

Data type Name Description


dip Image image An image
dip IntegerArray * dimensions Returns the dimensions Array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

The image structure


ImageGetDimensionality
294 Chapter 2. Function reference

ImageGetPlane
Read the plane number

SYNOPSIS

dip Error dip ImageGetPlane( image, plane )

FUNCTION

Read the dip Image plane number. For binary images this is the number of the bit in which
the data is stored. For other data types it is meaningless. The proper time to call this
function is right after ImageGetData.

ARGUMENTS

Data type Name Description


dip Image image An image
dip Int * plane Returns the plane number

SEE ALSO

The image structure


ImageGetData, ImageGetStride
DIPlib function reference 295

ImageGetStride
Read the stride array

SYNOPSIS

dip Error dip ImageGetStride( image, &stride, resources )

FUNCTION

Read the dip Image stride array. The array that is used to return the dimensions in, is
allocated by this routine using IntegerArrayNew. The proper time to call this function is
right after ImageGetData.

ARGUMENTS

Data type Name Description


dip Image image An image
dip IntegerArray * stride Returns the stride array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

The image structure


ImageGetData, ImageGetPlane
296 Chapter 2. Function reference

ImageGetType
Read the type field

SYNOPSIS

dip Error dip ImageGetType( image, type )

FUNCTION

Read the dip Image type field.

ARGUMENTS

Data type Name Description


dip Image image An image
dip ImageType * type Returns the type field

SEE ALSO

The image structure


ImageSetType
DIPlib function reference 297

ImageIsGIF
Confirm that a file is a GIF file (in dipIO)

SYNOPSIS

#include "dipio gif.h"


dip Error dipio ImageIsGIF ( filename, veredict )

FUNCTION

This function verifies that the file is an GIF file. veredict is set to DIP TRUE if it is, and to
DIP FALSE if it isn’t.

ARGUMENTS

Data type Name Description


dip String filename File name
dip Boolean * veredict Set to DIP TRUE or DIP FALSE

SOFTWARE

This function uses GifLib (version 4.1.0 or later), which supports GIF 87a & 98a.
Copyright (c)1997 Eric S. Raymond

SEE ALSO

ImageWriteGIF, ImageReadGIF
298 Chapter 2. Function reference

ImageIsICS
Confirm that a file is an ICS file (in dipIO)

SYNOPSIS

#include "dipio ics.h"


dip Error dipio ImageIsICS ( filename, veredict )

FUNCTION

This function verifies that the file is an ICS file. veredict is set to DIP TRUE if it is, and to
DIP FALSE if it isn’t.

ARGUMENTS

Data type Name Description


dip String filename File name
dip Boolean * veredict Set to DIP TRUE or DIP FALSE

SOFTWARE

This function uses libics (version 1.3), which supports the ICS specification revision 2.0.
Copyright (c)2000-2002 Cris L. Luengo Hendriks, Dr. Hans T.M. van der Voort and many
others.

SEE ALSO

ImageWriteICS, ImageReadICS
DIPlib function reference 299

ImageIsJPEG
Confirm that a file is a JPEG file (in dipIO)

SYNOPSIS

#include "dipio jpeg.h"


dip Error dipio ImageIsJPEG ( filename, veredict )

FUNCTION

This function verifies that the file is a JPEG file. veredict is set to DIP TRUE if it is, and to
DIP FALSE if it isn’t.

ARGUMENTS

Data type Name Description


dip String filename File name
dip Boolean * veredict Set to DIP TRUE or DIP FALSE

SOFTWARE

This function uses libjpeg (version 6b or later). Copyright (c)1994-1998, Thomas G. Lane.

SEE ALSO

ImageWriteJPEG, ImageReadJPEG, ImageReadJPEGInfo


300 Chapter 2. Function reference

ImageIsLSM
Confirm that a file is a Zeiss LSM file (in dipIO)

SYNOPSIS

#include "dipio ics.h"


dip Error dipio ImageIsLSM ( filename, veredict )

FUNCTION

This function verifies that the file is a Zeiss LSM file. veredict is set to DIP TRUE if it is,
and to DIP FALSE if it isn’t.

ARGUMENTS

Data type Name Description


dip String filename File name
dip Boolean * veredict Set to DIP TRUE or DIP FALSE

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.

SEE ALSO

ImageReadLSM
DIPlib function reference 301

ImageIsTIFF
Confirm that a file is a TIFF file (in dipIO)

SYNOPSIS

#include "dipio tiff.h"


dip Error dipio ImageIsTIFF ( filename, veredict )

FUNCTION

This function verifies that the file is a TIFF file. veredict is set to DIP TRUE if it is, and to
DIP FALSE if it isn’t.

ARGUMENTS

Data type Name Description


dip String filename File name
dip Boolean * veredict Set to DIP TRUE or DIP FALSE

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.

SEE ALSO

ImageWriteTIFF, ImageReadTIFF
302 Chapter 2. Function reference

ImageNew
Allocate a structure

SYNOPSIS

dip Error dip ImageNew( image, resources )

FUNCTION

Allocates a dip Image structure and initializes all fields to their default values. The
resulting image is in the “raw” state, see The image structure. By using
ImageCopyProperties and the “ImageSet” access functions, the image fields can be set to
their desired values. Pixel data for the image can be allocated using the ImageForge
function, which will will put the image in the “forged” state.

ARGUMENTS

Data type Name Description


dip Image * image Used to return the newly allocated image
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

The image structure


ImageFree, ImageForge, ImageStrip, ImageCopyProperties
DIPlib function reference 303

ImageRead
Read grey-value image from file (in dipIO)

SYNOPSIS

dip Error dipio ImageRead ( image, filename, format, addExtensions,


recognised )

FUNCTION

This function reads an image from a file and puts it in image. image must be allocated
before calling this function. If format is 0, all different ImageRead functions are called in
sequence until the correct format has been found. If you know the format, get the correct
format ID through the registry functions. See File formats recognized by dipIO for a list of
currently supported formats.
The boolean addExtensions specifies whether ImageRead should try to add file format
extensions to filename, if the registered file format reader fails to recognise filename
straight away. The extensions are provided by the registered file readers.
If recognised is not zero, ImageRead will set it to DIP TRUE when it has been able to read
filename, and it will set it to DIP FALSE when it is not able to read the file. No error will
be generated in this case.
If the file contains a colour image, Colour2Gray is called. That is, this function always
returns a grey-value image.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip int format ID of file format
dip Boolean addExtensions Add file format extensions to filename
dip Boolean * recognised Pointer to boolean containing the file read status

SEE ALSO

ImageReadColour, ImageReadROI, ImageFileGetInfo, ImageReadCSV, ImageReadGIF,


ImageReadICS, ImageReadLSM, ImageReadPIC, ImageReadTIFF, ImageReadJPEG,
ImageWrite, Colour2Gray
304 Chapter 2. Function reference

ImageReadColour
Read colour image from file (in dipIO)

SYNOPSIS

dip Error dipio ImageReadColour ( image, filename, photometric, format,


addExtensions, recognised )

FUNCTION

This function reads an image from a file and puts it in image. image must be allocated
before calling this function. It works the same as ImageRead, except that, if the file contains
a colour image, Colour2Gray is not called. The returned image has an extra dimension with
colours (always the last dimension), and photometric is set to the colour space.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation* photometric Photometric interpretation
(==colour space)
dip int format ID of file format
dip Boolean addExtensions Add file format extensions to
filename
dip Boolean * recognised Pointer to boolean containing
the file read status
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 305

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SEE ALSO

ImageRead, ImageReadROI, ImageFileGetInfo, ImageReadCSV, ImageReadGIF,


ImageReadICS, ImageReadLSM, ImageReadPIC, ImageReadTIFF, ImageReadJPEG,
ImageWrite, Colour2Gray
306 Chapter 2. Function reference

ImageReadCSV
Read comma-separated values from file (in dipIO)

SYNOPSIS

#include "dipio csv.h"


dip Error dipio ImageReadCSV ( image, filename, separator )

FUNCTION

This function reads the comma-separated values from a file and puts it in image. image
must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
char separator Separator character

SEE ALSO

ImageRead, ImageWriteCSV
DIPlib function reference 307

ImageReadCSVInfo
Get information about image in comma-separated values file (in dipIO)

SYNOPSIS

#include "dipio csv.h"


dip Error dipio ImageReadCSVInfo ( imInfo, filename )

FUNCTION

Opens a comma-separated values (CSV) file and fills a dipio ImageFileInformation


structure with the information from that file. imInfo must be allocated before calling this
function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SEE ALSO

ImageFileGetInfo, ImageReadCSV, ImageWriteCSV, ImageFileInformationNew


308 Chapter 2. Function reference

ImageReadGIF
Read a GIF image from file (in dipIO)

SYNOPSIS

#include "dipio gif.h"


dip Error dipio ImageReadGIF ( image, filename, photometric )

FUNCTION

This function reads an image from a GIF file and puts it in image. image must be allocated
before calling this function.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation * photometric Photometric interpretation
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 309

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses GifLib (version 4.1.0 or later), which supports GIF 87a & 98a.
Copyright (c)1997 Eric S. Raymond

SEE ALSO

ImageRead, ImageReadColour, ImageWriteGIF, ImageIsGIF


310 Chapter 2. Function reference

ImageReadGIFInfo
Get information about image in GIF file (in dipIO)

SYNOPSIS

#include "dipio gif.h"


dip Error dipio ImageReadGIFInfo ( imInfo, filename )

FUNCTION

Opens a GIF file and fills a dipio ImageFileInformation structure with the information
from that file. imInfo must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SOFTWARE

This function uses GifLib (version 4.1.0 or later), which supports GIF 87a & 98a.
Copyright (c)1997 Eric S. Raymond

SEE ALSO

ImageFileGetInfo, ImageIsGIF, ImageReadGIF, ImageWriteGIF,


ImageFileInformationNew
DIPlib function reference 311

ImageReadICS
Read ICS image from file (in dipIO)

SYNOPSIS

#include "dipio ics.h"


dip Error dipio ImageReadICS ( image, filename, photometric, offset, roisize,
sampling )

FUNCTION

This function reads the image in the ICS file and puts it in image. image must be allocated
before calling this function. photometric is set to match the photometric interpretation of
the data in the file, if it is recognised. The colour dimension is always the last dimension of
the image (no matter how it was saved in the ICS file). offset, roisize and sampling
define a ROI to read in. See the comments in ImageReadROI for more information on this.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation* photometric Photometric interpretation
dip IntegerArray offset ROI offset
dip IntegerArray roisize ROI size
dip IntegerArray sampling ROI sampling rate
The enumerator dipio PhotometricInterpretation contains the following constants:
312 Chapter 2. Function reference

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libics (version 1.3 or later), which supports the ICS specification
revision 2.0. Copyright (c)2000-2002 Cris L. Luengo Hendriks, Dr. Hans T.M. van der
Voort and many others.
This function uses zlib (version 1.1.4 or later). Copyright (c)1995-2002 Jean-loup Gailly
and Mark Adler

SEE ALSO

ImageRead, ImageReadColour, ImageReadROI, ImageWriteICS, ImageIsICS


DIPlib function reference 313

ImageReadICSInfo
Get information about image in ICS file (in dipIO)

SYNOPSIS

#include "dipio ics.h"


dip Error dipio ImageReadICSInfo ( imInfo, filename )

FUNCTION

Opens a ICS file and fills a dipio ImageFileInformation structure with the information
from that file. imInfo must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SOFTWARE

This function uses libics (version 1.3), which supports the ICS specification revision 2.0.
Copyright (c)2000-2002 Cris L. Luengo Hendriks, Dr. Hans T.M. van der Voort and many
others.

SEE ALSO

ImageFileGetInfo, ImageIsICS, ImageReadICS, ImageWriteICS,


ImageFileInformationNew
314 Chapter 2. Function reference

ImageReadJPEG
Read JPEG image from file (in dipIO)

SYNOPSIS

#include "dipio jpeg.h"


dip Error dipio ImageReadJPEG ( image, filename, imageNumber, photometric )

FUNCTION

This function reads an image from the JPEG file and puts it in image. image must be
allocated before calling this function. photometric is set to either DIPIO PHM RGB or
DIPIO PHM GREYVALUE. If photometric is 0, the image will be read in as grey-value, even if
color information is present in the file. Color images are allocated as 3D images, with the
different samples along the 3rd. dimension.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation * photometric Photometric interpretation
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 315

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libjpeg (version 6b or later). Copyright (c)1994-1998, Thomas G. Lane.

SEE ALSO

ImageRead, ImageReadColour, ImageWriteJPEG, ImageIsJPEG, ImageReadJPEGInfo,


Colour2Gray
316 Chapter 2. Function reference

ImageReadJPEGInfo
Get information about image in JPEG file (in dipIO)

SYNOPSIS

#include "dipio jpeg.h"


dip Error dipio ImageReadJPEGInfo ( imInfo, filename, imageNumber )

FUNCTION

Opens a JPEG file and fills a dipio ImageFileInformation structure with the information
from that file. imInfo must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SOFTWARE

This function uses libjpeg (version 6b or later). Copyright (c)1994-1998, Thomas G. Lane.

SEE ALSO

ImageFileGetInfo, ImageIsJPEG, ImageReadJPEG, ImageWriteJPEG,


ImageFileInformationNew
DIPlib function reference 317

ImageReadLSM
Read Zeiss LSM image from file (in dipIO)

SYNOPSIS

#include "dipio lsm.h"


dip Error dipio ImageReadLSM ( image, filename, offset, roisize, sampling,
imInfo, resources )

FUNCTION

This function reads the image in the Zeiss LSM file and puts it in image. image must be
allocated before calling this function. Depending on the recording mode and the number of
channels recorded, an image with 2 to 5 dimensions is returned. If multiple channels were
recorded, they will be put along the last dimension (which can be either the third, fourth or
fifth). The “stack”, “time series plane” ans “time series z-scan” recording modes return a
3D image, the “time series stack” returns a 4D image, all other modes return a 2D image
(including the “line” mode).
imInfo->physDims contains information on the distance between pixels. resources is only
used to allocate the imInfo structure, so if imInfo is 0, resources can be 0 too.
offset, roisize and sampling define a region of interest to read in. See the comments in
ImageReadROI for more information on this. Note that the channel dimension is part of this
ROI.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip IntegerArray offset ROI offset
dip IntegerArray roisize ROI size
dip IntegerArray sampling ROI sampling rate
dipio ImageFileInformation* imInfo Image file information structure
dip Resources resources Resources tracking structure. See
ResourcesNew

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
318 Chapter 2. Function reference

Graphics, Inc.
This function uses zlib (version 1.1.4 or later). Copyright (c)1995-2002 Jean-loup Gailly
and Mark Adler

SEE ALSO

ImageRead, ImageReadROI, ImageIsLSM


DIPlib function reference 319

ImageReadLSMInfo
Get information about image in LSM file (in dipIO)

SYNOPSIS

#include "dipio lsm.h"


dip Error dipio ImageReadLSMInfo ( imInfo, filename )

FUNCTION

Opens a LSM file and fills a dipio ImageFileInformation structure with the information
from that file. imInfo must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.

SEE ALSO

ImageFileGetInfo, ImageIsLSM, ImageReadLSM, ImageFileInformationNew


320 Chapter 2. Function reference

ImageReadPIC
Read BioRad PIC image from file (in dipIO)

SYNOPSIS

#include "dipio pic.h"


dip Error dipio ImageReadPIC ( image, filename, offset, roisize, sampling,
info, resources )

FUNCTION

This function reads the image in the BioRAD PIC file and puts it in image. image must be
allocated before calling this function. The information stored in the file is put in info.
offset and roisize define a region of interest to be read in. The ROI is clipped to the
actual image data, so it is safe to specify a ROI that is too large. sampling can be used to
read in a subset of the pixels of the chosen ROI. Any or all of these three parameters can be
NULL.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip IntegerArray offset ROI offset
dip IntegerArray roisize ROI size
dip IntegerArray sampling ROI sampling rate
dipio ImageFileInformation * info File information
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

ImageRead, ImageReadROI
DIPlib function reference 321

ImageReadPICInfo
Get information about image in BioRad PIC file (in dipIO)

SYNOPSIS

#include "dipio pic.h"


dip Error dipio ImageReadPICInfo ( imInfo, filename )

FUNCTION

Opens a BioRAD PIC file and fills a dipio ImageFileInformation structure with the
information from that file. imInfo must be allocated before calling this function.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name

SEE ALSO

ImageFileGetInfo, ImageReadPIC, ImageFileInformationNew


322 Chapter 2. Function reference

ImageReadROI
Read a portion of a grey-value image from file (in dipIO)

SYNOPSIS

dip Error dipio ImageReadROI ( image, filename, offset, roisize, sampling,


format, addExtensions, recognised )

FUNCTION

This function reads an image from a file and puts it in image. image must be allocated
before calling this function. It works the same as ImageRead, except that the user is allowed
to specify a region of the image to read. This is done through the offset and roisize
parameters. The ROI is clipped to the image size, so it is safe to specify a ROI that is too
large. sampling can be used to read in a subset of the pixels of the chosen ROI. Any or all
of these three parameters can be NULL.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip IntegerArray offset ROI offset
dip IntegerArray roisize ROI size
dip IntegerArray sampling ROI sampling rate
dip int format ID of file format
dip Boolean addExtensions Add file format extensions to filename
dip Boolean * recognised Pointer to boolean containing the file read status

SEE ALSO

ImageRead, ImageReadColour, ImageFileGetInfo, ImageReadCSV, ImageReadGIF,


ImageReadICS, ImageReadLSM, ImageReadPIC, ImageReadTIFF, ImageReadJPEG,
ImageWrite, Colour2Gray
DIPlib function reference 323

ImageReadTIFF
Read TIFF image from file (in dipIO)

SYNOPSIS

#include "dipio tiff.h"


dip Error dipio ImageReadTIFF ( image, filename, imageNumber, photometric )

FUNCTION

This function reads an image from the TIFF file and puts it in image. image must be
allocated before calling this function. imageNumber indicates which image from the
multi-page TIFF file to read. 0 is the first image. photometric is set to match the
photometric interpretation of the TIFF file. Color images and multi-sample images are
allocated as 3D images, with the different samples along the 3rd. dimension.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip int imageNumber Image number to read
dipio PhotometricInterpretation * photometric Photometric interpretation
The enumerator dipio PhotometricInterpretation contains the following constants:
324 Chapter 2. Function reference

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.
This function uses zlib (version 1.1.4 or later). Copyright (c)1995-2002 Jean-loup Gailly
and Mark Adler

KNOWN BUGS

TIFF is a very flexible file format. We have to limit the types of images that can be read to
the more common ones, and to the ones dipIO writes. These are the most obvious
limitations:
Tiled images are not supported.
Only 1, 4, 8, 16 and 32 bits per pixel integer grayvalues are read, as well as 32-bit and 64-bit
floating point.
Only 4 and 8 bits per pixel colourmapped images are read. Colourmapped images contain
16-bit gray-values: stretching of the display will be necessary.
Class Y images (YCbCr) and Log-compressed images (LogLuv or LogL) are not supported.
DIPlib function reference 325

SEE ALSO

ImageRead, ImageReadColour, ImageWriteTIFF, ImageIsTIFF, Colour2Gray


326 Chapter 2. Function reference

ImageReadTIFFInfo
Get information about image in TIFF file (in dipIO)

SYNOPSIS

#include "dipio tiff.h"


dip Error dipio ImageReadTIFFInfo ( imInfo, filename, imageNumber )

FUNCTION

Opens a TIFF file and fills a dipio ImageFileInformation structure with the information
from that file. imInfo must be allocated before calling this function. imageNumber indicates
which image from the multi-page TIFF file to get info on. 0 is the first image.
imInfo->numberOfImages gives the number of pages in the file.

ARGUMENTS

Data type Name Description


dipio ImageFileInformation imInfo Output image file information. See
ImageFileInformationNew
dip String filename File name
dip int imageNumber Image number to query

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.

SEE ALSO

ImageFileGetInfo, ImageIsTIFF, ImageReadTIFF, ImageWriteTIFF,


ImageFileInformationNew
DIPlib function reference 327

ImagesCheck
Check properties of several images

SYNOPSIS

dip Error dip ImagesCheck( images, imageType, dataType, compareFlag,


checkFlag )

FUNCTION

This function checks whether the image type and the data type of the first image in the
array matches with the imageType and dataType variables, and compares the other image
fields of the first image with those of the other images in the array. This comparison is done
by calling ImagesCompareTwo. The checkFlag can be used to compare properties not
supported by ImagesCompare. An error is returned by ImagesCheck if a check or
comparison fails.

ARGUMENTS

Data type Name Description


dip ImageArray * images Array of Images
dip ImageType imageType Image type of the first Image
dip DataTypeProperties dataType Data type of the first Image. See
DataTypeGetInfo
dipf ImagesCompare compareFlag Properties to compare. See ImagesCompare
dipf ImagesCheck checkFlag Extra properties to be compared

dipf ImagesCheck

Name Description
DIP CKIM MAX PRECISION MATCH Check whether data types match or match to the
DIP GTP MAX PRECISION DataType
DIP CKIM CASTING TYPE MATCH Check whether data types match or match to the
DIP GTP CAST R2C or DIP GTP CAST C2R types of
the first image in image
DIP CKIM IGNORE NULL DIM IMAGES Ignore images with a zero dimensionality, this flag
is usefull when 0d images are used as generic data
containers of constants
328 Chapter 2. Function reference

SEE ALSO

ImagesCompareTwo, ImagesCompare, ImagesCheckTwo


DIPlib function reference 329

ImagesCheckTwo
Check properties of two images

SYNOPSIS

dip Error dip ImagesCheckTwo( image1, image2, imageType, dataType,


compareFlag, checkFlag )

FUNCTION

This function checks whether the image type and the data type of the first DIPlib Image
matches with the imageType and dataType variables, and compares the other Image fields
of the first DIPlib Image with those of the second Image. This comparison is done by calling
ImagesCompareTwo. The checkFlag can be used to compare properties not supported by
ImagesCompare. ImagesCheckTwo returns an error code if a check or comparison fails.

ARGUMENTS

Data type Name Description


dip Image image1 First Image
dip Image image2 Second Image
dip ImageType imageType Image type of the first Image
dip DataTypeProperties dataType Data type of the first Image. See
DataTypeGetInfo
dipf ImagesCompare compareFlag Properties to compare. See ImagesCompare
dipf ImagesCheck checkFlag Extra properties to be compared

dipf ImagesCheck

Name Description
DIP CKIM MAX PRECISION MATCH Check whether data types match or match to the
DIP GTP MAX PRECISION DataType
DIP CKIM CASTING TYPE MATCH Check whether data types match or match to the
DIP GTP CAST R2C or DIP GTP CAST C2R types
DIP CKIM IGNORE NULL DIM IMAGES Ignore images with a zero dimensionality, this flag
is usefull when 0d images are used as generic data
containers of constants
330 Chapter 2. Function reference

SEE ALSO

ImagesCompareTwo, ImagesCompare, ImagesCheck


DIPlib function reference 331

ImagesCompare
Compare properties of several images

SYNOPSIS

dip Error dip ImagesCompare( images, condition, result )

FUNCTION

This function compares some standard fields of a number of Images or performs a full
comparison. Only if the comparison result is true between each of the Images, will the final
comparison result be true. The condition parameter specifies which properties should be
tested. If 0, a full comparison of the Images is performed. Otherwise it should be a logical
OR of the dipf ImagesCompare flags. DIP CPIM MATCH ALL STANDARD is equivalent to all
the flags OR’ed together. The difference between DIP CPIM MATCH ALL STANDARD and the
full comparison specified by 0, is that the first will compare all the standard fields ( type,
data type, dimensions ), whereas the other compares all fields relevant to a particular
DIPlib Image type. This may exclude some of the standard fields and include some fields
particular to the type of DIPlib Image in question. There are two modes of operation. If the
result parameter is set, it is used to store the result of the comparison, a set of OR’ed
dipf ImagesCompare flags. If the result parameter is 0, an error is returned if the condition
parameter and the resulting set of flags are not the same.

ARGUMENTS

Data type Name Description


dip ImageArray images Array of Images
dipf ImagesCompare condition Properties to compare. 0 indicates full
comparison
dipf ImagesCompare * result Result: flags to indicate if the properties were the
same. 0 indicates that an error should be
returned if the requested properties do not match
332 Chapter 2. Function reference

dipf ImagesCompare

Name Description
DIP CPIM DIMENSIONALITIES MATCH Dimensionalities match
DIP CPIM DIMENSIONS MATCH Dimensions match. The comparison is done up to
the lower of the of the two dimensionalities
DIP CPIM SIZE MATCH Combination of
DIP CPIM DIMENSIONALITIES MATCH and
DIP CPIM DIMENSIONS MATCH
DIP CPIM TYPES MATCH Types match
DIP CPIM DATA TYPES MATCH Data types match
DIP CPIM MATCH ALL STANDARD All flags above OR’ed together
DIP CPIM STRIDES MATCH Strides match
DIP CPIM FULL MATCH Full match. Returned in result. To test for a full
match use 0. Note: This is NOT equivalent to the
other flags OR’ed together, and it cannot be used
as condition

SEE ALSO

ImagesCompareTwo, ImagesCheckTwo, ImagesCheck


DIPlib function reference 333

ImagesCompareTwo
Compare properties of two images

SYNOPSIS

dip Error dip ImagesCompareTwo( image1, image2, condition, result )

FUNCTION

This function compares some standard fields of two Images or performs a full comparison.
The condition parameter specifies which properties should be tested. See ImagesCompare
for more information. There are two modes of operation. If the result parameter is set, it is
used to store the result of the comparison, a set of OR’ed dipf ImagesCompare flags. If the
result parameter is 0, an error is returned if the condition parameter and the resulting set of
flags are not the same.

ARGUMENTS

Data type Name Description


dip Image image1 First Image
dip Image image2 Second Image
dipf ImagesCompare condition Properties to compare. See ImagesCompare
dipf ImagesCompare* result Result: flags to indicate if the properties were the
same. 0 indicates that an error should be returned
if the requested properties do not match

SEE ALSO

ImagesCompare, ImagesCheckTwo, ImagesCheck


334 Chapter 2. Function reference

ImageSetDataType
Set the data type field

SYNOPSIS

dip Error dip ImageSetDataType( image, dataType )

FUNCTION

Set the dip Image data type field. The image must be “raw”.

ARGUMENTS

Data type Name Description


dip Image image An image
dip DataType type The image data type

SEE ALSO

DIPlib’s data types


The image structure
ImageGetDataType
DIPlib function reference 335

ImageSetDimensions
Set the dimensions array

SYNOPSIS

dip Error dip ImageSetDimensions( image, dimensions )

FUNCTION

Set the dip Image dimensions array. The image must be “raw”.

ARGUMENTS

Data type Name Description


dip Image image An image
dip IntegerArray dimensions The image dimensions

SEE ALSO

The image structure, ImageGetDimensions, ChangeDimensions


336 Chapter 2. Function reference

ImageSetType
Set the image type field

SYNOPSIS

dip Error dip ImageSetType( image, type )

FUNCTION

Set the dip Image type field. The image must be “raw”.

ARGUMENTS

Data type Name Description


dip Image image An image
dip ImageType type The image type

SEE ALSO

The image structure ImageGetType


DIPlib function reference 337

ImageSort
Sort image data

SYNOPSIS

#include "dip sort.h"


dip Error dip ImageSort ( in, out, algorithm )

FUNCTION

Produces an image (out) with the sorted pixel values of in.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Sort algorithm Sort algorithm
The sortType parameter is one of:
Name Description
DIP SORT DEFAULT Default sort algorithm
DIP SORT QUICK SORT Quick sort
DIP SORT DISTRIBUTION SORT Distribution sort
DIP SORT INSERTION SORT Insertion sort

SEE ALSO

General information about sorting


DistributionSort, InsertionSort, QuickSort, Sort, SortIndices, SortIndices16,
ImageSortIndices
338 Chapter 2. Function reference

ImageSortIndices
Sort indices to image data

SYNOPSIS

#include "dip sort.h"


dip Error dip ImageSortIndices ( in, indices, algorithm, flags )

FUNCTION

Sorts a list of indices rather than the data itself using the algorithm specified by algorithm.
Unless the DIP ISI USE INDICES, the indices image will be initialised with one index for
each pixel in the image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image indices Indices
dip Sort algorithm Sort algorithm
dipf ImageSortIndices flags Flags
The sortType parameter is one of:
Name Description
DIP SORT DEFAULT Default sort algorithm
DIP SORT QUICK SORT Quick sort
DIP SORT DISTRIBUTION SORT Distribution sort
DIP SORT INSERTION SORT Insertion sort
The dipf ImageSortIndices enumeration consists of the following flags:
Name Description
DIP ISI USE INDICES Use the indices as given in the indices image

SEE ALSO

General information about sorting


DistributionSort, InsertionSort, QuickSort, Sort, ImageSort, SortIndices,
SortIndices16
DIPlib function reference 339

ImagesSeparate
Take care of in-place operations

SYNOPSIS

dip Error dip ImagesSeparate( in, out, newOut, saved, resources )

FUNCTION

First the list of output images is checked to see if any output image is used more than once.
If this is the case an error is returned. Then the input and output images are examined. If
any of the output images is also used as an input image, the function allocates a new image.
This image is returned through the newOut array. For each output image a corresponding
image is returned in this array. Either the original output image itself, or either a new
image as discussed above. After the call to dip ImagesSeparate, the images in the newOut
array should be used instead of the original output images. After you are done processing
the images, a call to ResourcesFree will perform the necessary post-processing. The
post-processing consists of copying the data from the temporary output images to the
original output images and freeing the temporary images. Because the post-processing is
called through ResourcesFree, the resources parameter is mandatory. Any of the image
arrays’ elements may be set to zero, indicating that it is to be ignored.
The boolean saved array can be used to indicate that an input image has been stored in a
safe place. In this case dip ImagesSeparate will not have to allocate a temporary image if
the input image is also used as an output image. The saved parameter may either be zero,
which indicates that none of the input images has been saved, or it must be an array
containing booleans corresponding each of the input images. DIP TRUE indicates that the
image has been saved.

ARGUMENTS

Data type Name Description


dip ImageArray in An array of input images
dip ImageArray out An array of output images
dip ImageArray * newOut Returns an array containing the replacement output
images
dip BooleanArray saved An array of booleans indicating which input images
are safely stored
dip Resources resources Resources tracking structure. See ResourcesNew. May
not be zero
340 Chapter 2. Function reference

SEE ALSO

ImageGetData
DIPlib function reference 341

ImageStrip
Restore an image to its initial (“raw”) state

SYNOPSIS

dip Error dip ImageStrip( image )

FUNCTION

Free any pixel data associated with the image and return all fields to their initial (“raw”)
state. Essentially the image is returned to the state it was in right after it was allocated
with ImageNew.

ARGUMENTS

Data type Name Description


dip Image image The image to be stripped

SEE ALSO

The image structure


ImageNew, ImageForge, ImageFree, ImageCopyProperties
342 Chapter 2. Function reference

ImageWrite
Write grey-value image to file (in dipIO)

SYNOPSIS

dip Error dipio ImageWrite ( image, filename, physDims, format, compression )

FUNCTION

This function writes a grey-vlaue image to a file, overwriting any other file with the same
name. physDims gives physical dimensions of the image, and can be set to 0 for default
values. Not all file formats are able to store physical dimensions. Get the format ID through
the registry functions. See File formats recognized by dipIO for a list of currently supported
formats. If format is 0, ICSv2 is used.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip PhysicalDimensions physDims Physical dimensions structure. See
PhysicalDimensionsNew
dip int format ID of file format
dipio Compression compression Compression method and level. See
Compression methods for image files

SEE ALSO

ImageWriteColour, ImageWriteCSV, ImageWriteEPS, ImageWriteFLD, ImageWriteGIF,


ImageWriteICS, ImageWritePS, ImageWriteTIFF, ImageWriteJPEG, ImageRead
DIPlib function reference 343

ImageWriteColour
Write colour image to file (in dipIO)

SYNOPSIS

dip Error dipio ImageWriteColour ( image, filename, photometric, physDims,


format, compression )

FUNCTION

This function writes a colour image to a file, overwriting any other file with the same name.
photometric must be set to the correct value. Not all file formats support all photometric
values, and some don’t support colour at all. physDims gives physical dimensions of the
image, and can be set to 0 for default values. Not all file formats are able to store physical
dimensions. Get the format ID through the registry functions. See File formats recognized
by dipIO for a list of currently supported formats. If format is 0, ICSv2 is used.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
(==colour space)
dip PhysicalDimensions physDims Physical dimensions structure.
See PhysicalDimensionsNew
dip int format ID of file format
dipio Compression compression Compression method and level.
See Compression methods for
image files
The enumerator dipio PhotometricInterpretation contains the following constants:
344 Chapter 2. Function reference

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SEE ALSO

ImageWrite, ImageWriteCSV, ImageWriteEPS, ImageWriteFLD, ImageWriteGIF,


ImageWriteICS, ImageWritePS, ImageWriteTIFF, ImageWriteJPEG, ImageRead,
Colour2Gray
DIPlib function reference 345

ImageWriteCSV
Write image to a comma-separated-value file (in dipIO)

SYNOPSIS

#include "dipio csv.h"


dip Error dipio ImageWriteCSV ( image, filename, separator )
dip Error dipio ImageWriteCSV ( dip Image, dip String, char );

FUNCTION

This function writes the image to a comma-separated-values file, overwriting any other file
with the same name. Optionally, an other separator than the comma can be specified using
separator. Sometimes a space, a tab or a colon are used instead. Each line of image data is
ended by a newline.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
char separator Optional alternative separator character

SEE ALSO

ImageWrite, ImageReadCSV
346 Chapter 2. Function reference

ImageWriteEPS
Write image to Encapsulated PostScript file (in dipIO)

SYNOPSIS

#include "dipio ps.h"


dip Error dipio ImageWriteEPS ( image, filename, photometric, xcm, ycm,
border )

FUNCTION

This function writes the image to an Encapsulated PostScript file, overwriting any other file
with the same name. Set the image size in xcm and ycm. border sets the size of the border
around the image. If border is 0, no border is drawn. For colour images, set photometric
(supported are RGB and CMYK) and write the colour channels along the third image
dimension.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
dip float xcm X-size of image in cm.
dip float ycm Y-size of image in cm.
dip int border Thickness of border, zero is no
border
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 347

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SEE ALSO

ImageWrite, ImageWriteColour, ImageWritePS


348 Chapter 2. Function reference

ImageWriteFLD
Write image to AVS field file (in dipIO)

SYNOPSIS

#include "dipio fld.h"


dip Error dipio ImageWriteFLD ( image, filename )

FUNCTION

This function writes the image to an AVS Field file.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name

SEE ALSO

ImageWrite
DIPlib function reference 349

ImageWriteGIF
Write image to a GIF file (in dipIO)

SYNOPSIS

#include "dipio gif.h"


dip Error dipio ImageWriteGIF ( image, filename, labelImage )

FUNCTION

This function writes the gray-value image to a GIF file, overwriting any other file with the
same name. Optionally, an integer-typed image can be identified as a labeled image using
labelImage. In that case a colour GIF image will be saved.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dip Boolean labelImage Regard an integer image as a labeled image

SOFTWARE

This function uses GifLib (version 4.1.0 or later), which supports GIF 87a & 98a.
Copyright (c)1997 Eric S. Raymond

SEE ALSO

ImageWrite, ImageReadGIF, ImageIsGIF


350 Chapter 2. Function reference

ImageWriteICS
Write ICS image to file (in dipIO)

SYNOPSIS

#include "dipio ics.h"


dip Error dipio ImageWriteICS ( image, filename, photometric, physDims,
history, sigbits, version, compression )

FUNCTION

This function writes the image to an ICS file, overwriting any other file with the same name.
version can set to 1 to use the ICS v.1.0 file format (the 2-file version), instead of ICS
v.2.0. For colour images, set photometric and write the colour channels along the last
image dimension. Set sigbits only if the number of significant bits is different from the full
range of the data type of image (use 0 otherwise). physDims can be set to 0 to fill out
default values. history can be 0 if you do not want to bother.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
dip PhysicalDimensions physDims Physical dimensions structure.
See PhysicalDimensionsNew
dip StringArray history Tags that are written to the
history in the ICS header
dip int sigbits Number of significant bits.
dip int version ICS version
dipio Compression compression Compression method and level.
See Compression methods for
image files
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 351

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libics (version 1.3 or later), which supports the ICS specification
revision 2.0. Copyright (c)2000-2002 Cris L. Luengo Hendriks, Dr. Hans T.M. van der
Voort and many others.
This function uses zlib (version 1.1.4 or later). Copyright (c)1995-2002 Jean-loup Gailly
and Mark Adler

SEE ALSO

ImageWrite, ImageWriteColour, ImageReadICS, ImageIsICS


352 Chapter 2. Function reference

ImageWriteJPEG
Write JPEG image to file (in dipIO)

SYNOPSIS

#include "dipio jpeg.h"


dip Error ImageWriteJPEG ( image, filename, photometric, physDims, complevel
)

FUNCTION

This function writes the image to a JPEG file, overwriting any other file with the same
name. photometric can set to let the function know how to write the JPEG image
(supported colour space is RGB).
If photometric is not DIPIO PHM GRAYVALUE, a 3D image is expected, in which the different
planes are stored along the 3rd dimension.
physDims gives physical dimensions of the image, which will be used to set the dots per inch
property of the JPEG file. It can be set to 0 for default values (300 dpi). If the
physDims->dimensionUnits is not given, meters are assumed.
complevel is a number between 1 (worst quality, smallest files) and 100 (best quality,
largest files). Setting complevel to 0 uses the default compression level, which is 90.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
dip PhysicalDimensions physDims Physical dimensions structure.
See PhysicalDimensionsNew
dipio uint complevel Compression level
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 353

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libjpeg (version 6b or later). Copyright (c)1994-1998, Thomas G. Lane.

SEE ALSO

ImageWrite, ImageWriteColour, ImageReadJPEG, ImageIsJPEG, ImageReadJPEGInfo


354 Chapter 2. Function reference

ImageWritePS
Write image to PostScript file (in dipIO)

SYNOPSIS

#include "dipio ps.h"


dip Error dipio ImageWritePS ( image, filename, photometric, caption, xcm,
ycm, border )

FUNCTION

This function writes the image to a PostScript file, overwriting any other file with the same
name. Set the image size in xcm and ycm. border sets the size of the border around the
image. If border is 0, no border is drawn. You can give the page a title through caption.
For colour images, set photometric (supported are RGB and CMYK) and write the colour
channels along the third image dimension.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
dip String caption Title for page
dip float xcm X-size of image on page, in cm.
dip float ycm Y-size of image on page, in cm.
dip int border Thickness of border, zero is no
border
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 355

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SEE ALSO

ImageWrite, ImageWriteColour, ImageWriteEPS


356 Chapter 2. Function reference

ImageWriteTIFF
Write TIFF image to file (in dipIO)

SYNOPSIS

#include "dipio tiff.h"


dip Error ImageWriteTIFF ( image, filename, photometric, physDims,
compression )

FUNCTION

This function writes the image to a TIFF file, overwriting any other file with the same
name. photometric can set to let the function know how to write the TIFF image
(supported colour spaces are RGB, CIE Lab and CMYK).
If photometric is not DIPIO PHM GRAYVALUE, a 3D image is expected, in which the different
planes are stored along the 3rd dimension.
physDims gives physical dimensions of the image, which will be used to set the dots per inch
property of the TIFF file. It can be set to 0 for default values (300 dpi). If the
physDims->dimensionUnits is not given, meters are assumed.

ARGUMENTS

Data type Name Description


dip Image image Output image
dip String filename File name
dipio PhotometricInterpretation photometric Photometric interpretation
dip PhysicalDimensions physDims Physical dimensions structure.
See PhysicalDimensionsNew
dipio Compression compression Compression method and level.
See Compression methods for
image files
The enumerator dipio PhotometricInterpretation contains the following constants:
DIPlib function reference 357

Name Description
DIPIO PHM GREYVALUE No colour information present; it’s a grey-value image.
DIPIO PHM RGB RGB image (the first three planes are red, green and blue)
DIPIO PHM RGB NONLINEAR Non-linear R’G’B’ image (RGB channels to the power of 0.4)
DIPIO PHM CMY CMY image (the first three planes are cyan, magenta and
yellow)
DIPIO PHM CMYK CMYK image (the first four planes are cyan, magenta,
yellow and black)
DIPIO PHM CIELUV CIE L*u’v’ image (the first three planes are luminosity, u*
and v*)
DIPIO PHM CIELAB CIE L*a*b* image (the first three planes are luminosity, a*
and b*)
DIPIO PHM CIEXYZ CIE XYZ (the first three planes are X, Y and Z)
DIPIO PHM CIEYXY CIE Yxy (the first three planes are Y, x and y)
DIPIO PHM HCV HCV image (the first three planes are hue, chroma and
value)
DIPIO PHM HSV HSV image (the first three planes are hue, saturation and
value)
DIPIO PHM DEFAULT Same as DIPIO PHM GREYVALUE
DIPIO PHM GENERIC Anything can be coded in the channels; the same as
DIPIO PHM CMYK
Most file formats support only some of these.

SOFTWARE

This function uses libtiff (version 3.6.1 or later), which supports the TIFF specification
revision 6.0. Copyright (c)1988-1997 Sam Leffler and Copyright (c)1991-1997 Silicon
Graphics, Inc.
This function uses zlib (version 1.1.4 or later). Copyright (c)1995-2002 Jean-loup Gailly
and Mark Adler

SEE ALSO

ImageWrite, ImageWriteColour, ImageReadTIFF, ImageIsTIFF


358 Chapter 2. Function reference

Imaginary
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Imaginary ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the imaginary part of the input image values, and outputs a float typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Modulus, Phase, Real


DIPlib function reference 359

IncoherentOTF
Generates an incoherent OTF

SYNOPSIS

#include "dip microscopy.h"


dip Error dip IncoherentOTF ( out, defocus, xNyquist, amplitude, otf )

DATA TYPES

Output: sfloat

FUNCTION

This function implements the formulae for a (defocused) incoherent OTF as described by
Castleman. When defocus is unequal to zero, either the Stokseth approximation or the
Hopkins approximation is used. The defocus is defined a the maximum defocus path length
error divided by the wave length (See Castleman for details). The summation over the
Bessel functions in the Hopkins formluation, is stopped when the change is smaller than
DIP MICROSCOPY HOPKINS OTF CUTOFF.

ARGUMENTS

Data type Name Description


dip Image out Output
dip float defocus Defocus
dip float xNyquist Oversampling
dip float amplitude Amplitude
dipf IncoherentOTF otf Otf approximation
The dipf IncoherentOTF enumeration supports the following flags:
Name Description
DIP MICROSCOPY OTF STOKSETH Stokseth OTF approximation
DIP MICROSCOPY OTF HOPKINS Hopkins OTF approximation

LITERATURE

K.R. Castleman, “Digital image processing, second edition”, Prentice Hall, Englewood Cliffs,
1996.
360 Chapter 2. Function reference

SEE ALSO

IncoherentPSF
DIPlib function reference 361

IncoherentPSF
Generates an incoherent PSF

SYNOPSIS

#include "dip microscopy.h"


dip Error dip IncoherentPSF ( output, xNyquist, amplitude )

DATA TYPES

Output: sfloat

FUNCTION

This function generates an incoherent in-focus point spread function of a diffraction limited
objective.

ARGUMENTS

Data type Name Description


dip Image output Output Image
dip float xNyquist Oversampling Factor
dip float amplitude Amplitude

LITERATURE

K.R. Castleman, “Digital image processing, second edition”, Prentice Hall, Englewood Cliffs,
1996.

SEE ALSO

IncoherentOTF
362 Chapter 2. Function reference

IndexToCoordinate
Convert pixel index to coordinate

SYNOPSIS

#include "dip coordsindx.h"


dip Error dip IndexToCoordinate ( index, coordinate, stride )

FUNCTION

This function is identical to IndexToCoordinateWithSingletons, but does not handle


images with singleton dimensions (dimensions where the size is 1). Please use the other
function instead, this one is provided for backwards compatability only.

ARGUMENTS

Data type Name Description


dip int index lineair index
dip IntegerArray coordinate output coordinates
dip IntegerArray stride stride array

SEE ALSO

IndexToCoordinateWithSingletons, CoordinateToIndex
DIPlib function reference 363

IndexToCoordinateWithSingletons
Convert pixel index to coordinate

SYNOPSIS

#include "dip coordsindx.h"


dip Error dip IndexToCoordinateWithSingletons ( index, coordinate, size,
stride )

FUNCTION

This function converts an pixel index of an image to a coordinate array. The conversion is
done by calculating the modulus of the index with the stride and size arrays obtained
from the image. coordinate has to be an allocated integer array with its size equal to the
size of stride and size.
A set of macros can be used instead of this function to avoid some overhead when
repeatedly converting linear indices to coordinates for the same image:

DIP_FNR_DECLARE; /* Declares dip_Registry rg */

dip_Image image;
dip_int index;
dip_IntegerArray coordinates;

dip_IntegerArray size;
dip_IntegerArray stride;

DIP_INDEX_TO_COORDINATE_DECL( ix ); /* This macro declares variable "ix", name it whatever

DIP_FNR_INITIALISE;

/* ... */

DIPXJ( dip_ImageGetDimensions( image, &size, rg ));


DIPXJ( dip_ImageGetStride( image, &stride, rg ));

DIP_INDEX_TO_COORDINATE_INIT( size, stride, ix, rg ); /* This macro initialises variable "

DIPXJ( dip_IntegerArrayNew( &coordinates, stride->size, 0, rg ));

/* Now, every time you need to obtain the coordinates for an index, do: */
364 Chapter 2. Function reference

DIP_INDEX_TO_COORDINATE( index, coordinates, stride, ix );

ARGUMENTS

Data type Name Description


dip int index lineair index
dip IntegerArray coordinate output coordinates
dip IntegerArray size image size array
dip IntegerArray stride stride array

SEE ALSO

IndexToCoordinate, CoordinateToIndex
DIPlib function reference 365

Initialise
Initialise DIPlib

SYNOPSIS

dip Error dip Initialise( void )


dip Error dipio Initialise( void )

FUNCTION

Initialise the DIPlib library. Must be called before using any of the other DIPlib functions.
This function can be invoked more than once; all but the first invocation are ignored.

SEE ALSO

Exit
366 Chapter 2. Function reference

InsertionSort
Sort a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip InsertionSort ( data, size, dataType )

FUNCTION

Sorts a block of data (of size size and data type dataType ) using the insertion sort
algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


InsertionSortIndices, InsertionSortIndices16, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
DIPlib function reference 367

InsertionSortIndices
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip InsertionSortIndices ( data, indices, size, dataType )

FUNCTION

Sorts a list of indices rather than the data itself using the insertion sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint32 * indices Indices
dip int size Size
dip DataType dataType Data type, See DIPlib’s data types

SEE ALSO

General information about sorting


InsertionSort, InsertionSortIndices16, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
368 Chapter 2. Function reference

InsertionSortIndices16
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip InsertionSortIndices16 ( data, indices, size, dataType )

FUNCTION

Sorts a list of (16 bit) indices rather than the data itself using the insertion sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint16 * indices Indices
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


InsertionSort, InsertionSortIndices, Sort, ImageSort, SortIndices, SortIndices16,
ImageSortIndices
DIPlib function reference 369

IntegerArrayCopy
Copy an array

SYNOPSIS

dip Error dip IntegerArrayCopy ( dest, src, resources )

FUNCTION

This function copies the integer array src to dest. The array dest is created by this
function as well.

ARGUMENTS

Data type Name Description


dip IntegerArray * dest Destination array
dip IntegerArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

IntegerArrayNew, IntegerArrayFree, IntegerArrayCopy, IntegerArrayFind


IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
370 Chapter 2. Function reference

IntegerArrayFind
Find value in array

SYNOPSIS

dip Error dip IntegerArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
IntegerArrayFind will produce an error if value is not found, otherwise found obtains the
search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip IntegerArray array Array to find value in
dip int value Value to find
dip int * index Index of the found value
dip Boolean * found Value found or not

SEE ALSO

IntegerArrayNew, IntegerArrayFree, IntegerArrayCopy, IntegerArrayFind


IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
DIPlib function reference 371

IntegerArrayFree
Array free function

SYNOPSIS

dip Error dip IntegerArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip IntegerArray * array Array

SEE ALSO

IntegerArrayNew, IntegerArrayFree, IntegerArrayCopy, IntegerArrayFind


ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
372 Chapter 2. Function reference

IntegerArrayNew
Array allocation function

SYNOPSIS

dip Error dip IntegerArrayNew ( array, size, value, resources )

FUNCTION

This function allocates the size elements of a dip IntegerArray and sets the size of the
array to size. Each array element is initialized with value.

ARGUMENTS

Data type Name Description


dip IntegerArray * array Array
dip int size Size
dip int value Initial value
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

IntegerArrayNew, IntegerArrayFree, IntegerArrayCopy, IntegerArrayFind


ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
DIPlib function reference 373

Invert
logic operation

SYNOPSIS

#include "dip math.h"


dip Error dip Invert ( in, out )

DATA TYPES

binary, integer

FUNCTION

The function Invert inverts the pixel value in in1 and stores the result in out.

ARGUMENTS

Data type Name Description


dip Image in Binary input image
dip Image out Output image

SEE ALSO

And, Xor, Or
374 Chapter 2. Function reference

IsodataThreshold
Point operation

SYNOPSIS

#include "dip analysis.h"


dip Error dip IsodataThreshold ( in, out, mask, numbthresholds, values )

DATA TYPES

integer, float

FUNCTION

Thresholds in with the isodata method. Several threholds can be supplied, their value is
returned in values. The different regions are label in out with different grey-values. A
maks image mask can be given to compute the isodata only there.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image mask Mask image
dip int numbthresholds Number of Thresholds
dip FloatArray values Values

SEE ALSO

Threshold, RangeThreshold, HysteresisThreshold


DIPlib function reference 375

IsScalar
Determines whether an image is a scalar

SYNOPSIS

dip Error dip IsScalar( image, answer )

FUNCTION

Determines whether an image is of the DIP IMTP SCALAR type. If answer is not zero, the
verdict is passed in this variable. Otherwise, dip IsScalar returns an error in case image
fails to be a scalar.

ARGUMENTS

Data type Name Description


dip Image image The image under investigation
dip Boolean * answer The verdict
376 Chapter 2. Function reference

Kuwahara
Edge perserving smoothing filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip Kuwahara ( in, out, se, boundary, filterSize, shape )

DATA TYPES

binary, integer, float

FUNCTION

This function implements the kuwahara edge-preserving smoothing function. See section
9.4, “Smoothing operations”, in “Fundamentals of Image Processing” for a description of the
algorithm. However, this function does not implement the classical kuwahara filter, which
only compares the variance of four regions in the filter window, but compares the variance
of every region specified by the filter shape and size centered withing the filter window.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterSize Filter sizes
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
DIPlib function reference 377

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

GeneralisedKuwahara, VarianceFilter
378 Chapter 2. Function reference

Label
Label a binary image

SYNOPSIS

#include "dip regions.h"


dip Error dip Label ( in, out, connectivity, flags, minsize, maxsize, nol,
boundary )

DATA TYPES

binary

FUNCTION

The output is an integer image. Each object (respecting the connectivity, see The
connectivity parameter) in the input image receives a unique number. This number ranges
from 1 to the number of objects in the image. The pixels in the output image corresponding
to a given object are set to this number (label). The remaining pixels in the output image
are set to 0. The minsize and maxsize set limits on the size of the objects, if the flag
DIP LB THRESHOLD ON SIZE is set: Objects smaller than minsize or larger than maxsize do
not receive a label and the corresponding pixels in the output image are set to zero. Setting
minsize to zero implies that there is no check with respect to the minimum size of the
object, and the same holds for maxsize and the maximum size of the object. If the flag
DIP LB LABEL IS SIZE is set, the objects’ labels are set to the objects’ sizes. The boundary
conditions are generally ignored (labeling stops at the boundary). The exception is
DIP BC PERIODIC, which is the only one that makes sense for this algorithm.

ARGUMENTS

Data type Name Description


dip Image in Input binary image
dip Image out Output label image
dip int connectivity Connectivity
dip int flags 0, or a logical OR of the flags described above
dip int minsize Minimum size of the objects (0=do not check)
dip int maxsize Maximum size of the objects (0=do not check)
dip int * nol Pointer to dip int. Used for returning the number
of objects. May be set to 0.
dip BoundaryArray boundary Boundary conditions
DIPlib function reference 379

Laplace
Second order derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip Laplace ( in, out, boundary, ps, sigmas, tc, flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes the Laplace of an image using the Derivative function.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float tc Truncation of Gaussian
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx

SEE ALSO

See section 9.5, “Derivative-based operations”, in “Fundamentals of Image Processing”.


380 Chapter 2. Function reference

Derivative, GradientMagnitude, GradientDirection2D, Dgg, LaplacePlusDgg,


LaplaceMinDgg
DIPlib function reference 381

LaplaceMinDgg
Second order derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip LaplaceMinDgg ( in, out, boundary, ps, sigmas, tc, flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes Laplace - Dgg. For two-dimensional images this is equivalent to the second order
derivative in the direction perpendicular to the gradient direction.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float tc Truncation of Gaussian
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx

SEE ALSO

Derivative, GradientMagnitude, GradientDirection2D, Laplace, Dgg, LaplacePlusDgg


382 Chapter 2. Function reference

LaplacePlusDgg
Second order derivative filter

SYNOPSIS

#include "dip derivatives.h"


dip Error dip LaplacePlusDgg ( in, out, boundary, ps, sigmas, tc, flavour )

DATA TYPES

Depends on the underlying implementation, but expect:


binary, integer, float

FUNCTION

Computes the laplace and the second derivative in gradient direction of an image using the
Derivative function and adds the results. The zero-crossings of the result correspond to
the edges in the image, just as for the individual Laplace and Dgg operators. The
localization is improved by an order of magnitude with respect to the individual operators.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip BooleanArray ps Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float tc Truncation of Gaussian
dip DerivativeFlavour flavour Derivative flavour
The enumerator flavour parameter is one of:
Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx
DIPlib function reference 383

LITERATURE

Lucas J. van Vliet, “Grey-Scale Measurements in Multi-Dimensional Digitized Images”,


Delft University of Technology, 1993
P.W. Verbeek and L.J. van Vliet, “On the location error of curved edges in low-pass filtered
2-D and 3-D images”, IEEE Transactions on Pattern Analysis and Machine Intelligence,
vol. 16, no. 7, 1994, 726-733.

SEE ALSO

Derivative, GradientMagnitude, GradientDirection2D, Laplace, Dgg, LaplaceMinDgg


384 Chapter 2. Function reference

Lee
Morphological edge detector

SYNOPSIS

#include "dip morphology.h"


dip Error dip Lee ( in, out, se, boundary, filterParam, shape, edgeType,
flags )

DATA TYPES

integer, float

FUNCTION

Implements a morphological edge detector based on the minimum of two complementary


morphological operations. These can be chosen through the edgeType parameter.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip MphEdgeType edgeType Edge type
dipf LeeSign flags Lee sign flag
DIPlib function reference 385

The enumerator dip FilterShape contains the following constants:


Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The enumerator dip MphEdgeType contains the following constants:
Name Description
DIP MPH TEXTURE Response is limited to edges in texture
DIP MPH OBJECT Response is limited to object edges
DIP MPH BOTH All edges produce equal response
The enumerator dipf LeeSign contains the following constants:
Name Description
DIP LEE UNSIGNED Absolute edge strength
DIP LEE SIGNED Signed edge strength

SEE ALSO

MorphologicalGradientMagnitude, MorphologicalRange,
MultiScaleMorphologicalGradient, Tophat
386 Chapter 2. Function reference

Lesser
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip Lesser ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when for corresponding pixels in1 < in2.
This is the same as Compare with the DIP SELECT LESSER selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to a functionality similar to that of Threshold.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Equal, Greater, NotEqual, NotGreater, NotLesser, SelectValue,


NotZero
DIPlib function reference 387

Ln
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Ln ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the natural logarithm of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp, Exp2, Exp10, Log2, Log10


388 Chapter 2. Function reference

LnGamma
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip LnGamma ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the natural logarithm of the gamma function of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselY1, BesselYN, Erf, Erfc, Sinc


DIPlib function reference 389

LnNormError
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip LnNormError ( in1, in2, mask, out, order )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the order norm difference between each pixel value of in1 and in2. Optionally
the mask image can be used to exclude pixels from the calculation by setting the value of
these pixels in mask to zero.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image mask Mask
dip Image out Output
dip float order Order

SEE ALSO

MeanError, MeanSquareError, RootMeanSquareError, MeanAbsoluteError, IDivergence


390 Chapter 2. Function reference

LocalMinima
Marks local minima (or regional minima)

SYNOPSIS

#include "dip morphology.h"


dip Error dip LocalMinima ( in, mask, out, connectivity, max depth, max size,
binaryOutput )

DATA TYPES

integer, float

FUNCTION

The binary output image is true on all pixels belonging to the minima of a region (as
defined by the watershed). To find local maxima, use the inverse of the image as input to
this function (see Invert). If binaryOutput is DIP FALSE, the output is a labelled image
instead of a binary one. In this case, pixels belonging to the same local minimum are
assigned the same value.
The algorithm is based on the watershed transform, see Watershed for information on the
parameters.
Minima is a different algorithm to obtain local minima; Maxima yields the local maxima.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask Mask
dip Image out Output (binary)
dip int connectivity Connectivity
dip float max depth Maximum depth of a region that can be merged
dip int max size Maximum size of a region that can be merged
dip Boolean binaryOutput DIP FALSE if the output should be a labelled image

SEE ALSO

Watershed, SeededWatershed, UpperEnvelope, Minima, Maxima


DIPlib function reference 391

Log10
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Log10 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the base ten logarithm of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp, Exp2, Exp10, Ln, Log2


392 Chapter 2. Function reference

Log2
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Log2 ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the base two logarithm of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sqrt, Exp, Exp2, Exp10, Ln, Log10


DIPlib function reference 393

macros.h
Various macros

DESCRIPTION

The include files dip macros.h contains a number of useful macros.


Math macros
DIP ABS( x ) Absolute value of x
DIP MAX( x, y ) Maximum of x and y
DIP MIN( x, y ) Minimum of x and y
DIP FUNC( funcName, suffix ) Attaches the suffix to the function name,
and puts and underscore in between.
DIP SWAP( x, y, z ) Swaps variables x and y, using temporary
variable z. Must be followed by a trailing
“;“
Macros for handling complex numbers:
DIP REAL( x ) Real part of complex number x
DIP IMAGINARY( x ) Imaginary part of complex number x
DIP SQUARE MODULUS( x ) Square modulus of complex number x
DIP MODULUS( x ) Modulus of complex number x
DIP PHASE( x ) Phase of complex number x
Binary I/O macros
DIP BINARY MASK( mask, plane ) Computes a binary mask from the plane
value
DIP BINARY READ( in, mask ) Returns the binary value from in
DIP BINARY WRITE( out, val, mask ) Writes the value of val to out
Random access I/O macros:

DIP_PIXEL_GET( ip, pos, stride, value )


DIP_PIXEL_SET( ip, pos, stride, value )

get/set the value of the pixel at position pos from data pointer ip with strides stride.
Both pos and stride are dip IntegerArrays.

DIP_PIXEL_ADD( ip, pos, stride, value )


DIP_PIXEL_SUB( ip, pos, stride, value )
DIP_PIXEL_MUL( ip, pos, stride, value )
DIP_PIXEL_DIV( ip, pos, stride, value )

add/subtract/multlipy/divide the value with the pixel-value at position pos from data
pointer ip with strides stride. Both pos and stride are dip IntegerArrays.
394 Chapter 2. Function reference

Map
Remaps an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Map ( in, out, map, mirror )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function maps the dimensions of the output image to (different) dimensions of the
input image. The array index of map specifies the dimension of the output image, the value
of the array element of map specifies to which dimension in the input image it corresponds.
Optionally, the dimensions can be mirrored, when the value of the corrsponding array
element in mirror is set to DIP TRUE.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip IntegerArray map Map array
dip BooleanArray mirror Mirror array

SEE ALSO

Mirror
DIPlib function reference 395

Max
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Max ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function computes out = max (in1 , in2) on a pixel by pixel basis. The data types of
the in1 and in2 image may be of different types. See Information about dyadic operations
for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

MaxFloat, Min, MinFloat


396 Chapter 2. Function reference

MaxFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip MaxFloat ( in, out, constant )

DATA TYPES

binary, integer, float

FUNCTION

This function computes out = max(in , constant) on a pixel by pixel basis. The data
types of the in1 image and constant may be of different types. See Information about
dyadic operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float constant Constant

SEE ALSO

Max, Min, MinFloat


DIPlib function reference 397

Maxima
Detects local maxima

SYNOPSIS

#include "dip filtering.h"


dip Error dip Maxima ( in, mask, out, connectivity, booleanOutput )

DATA TYPES

integer, float

FUNCTION

This function detects local maxima.


The algorithm finds a connected set of pixels with identical value, an no neighbours with
higher value. This set is a local maximum and its pixels are set to 1 in the output image. If
booleanOutput is false, the output image is a labelled image.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image mask Mask image
dip Image out Binary output image
dip int connectivity Connectivity
dip Boolean booleanOutput Give a binary output image?

NOTE

If you are looking for the old version of Maxima, it is still available through the following
combination of commands:

dip_Dilation( in, out, se, boundary, filterParam, shape );


dip_Equal( in, out, out );

SEE ALSO

Minima, LocalMinima, SeededWatershed, GrowRegions


398 Chapter 2. Function reference

Maximum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Maximum ( in, mask, out, ps )

DATA TYPES

binary, integer, float

FUNCTION

Calculates the maximum of the pixel values over all those dimensions which are specified by
ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, SumModulus,
MeanSquareModulus, Minimum, Median, Percentile
DIPlib function reference 399

mBesselJ0
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselJ0 ( x )

FUNCTION

Computes the Bessel function J0 of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
400 Chapter 2. Function reference

mBesselJ1
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselJ1 ( x )

FUNCTION

Computes the Bessel function J1 of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
DIPlib function reference 401

mBesselJN
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselJN ( x, n )

FUNCTION

Computes the Bessel function J of the order n of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value
dip int n Order of Bessel function

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
402 Chapter 2. Function reference

mBesselY0
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselY0 ( x )

FUNCTION

Computes the Bessel function Y0 of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
DIPlib function reference 403

mBesselY1
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselY1 ( x )

FUNCTION

Computes the Bessel function Y1 of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
404 Chapter 2. Function reference

mBesselYN
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm BesselYN ( x, n )

FUNCTION

Computes the Bessel function Y of the order n of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value
dip int n Order of Bessel function

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
DIPlib function reference 405

Mean
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Mean ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean of the pixel values over all those dimensions which are specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Variance, StandardDeviation, MeanModulus, SumModulus, MeanSquareModulus,
Maximum, Minimum, Median, Percentile
406 Chapter 2. Function reference

MeanAbsoluteError
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip MeanAbsoluteError ( in1, in2, mask, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean absolute error difference between each pixel value of in1 and in2.
Optionally the mask image can be used to exclude pixels from the calculation by setting the
value of these pixels in mask to zero.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image mask Mask
dip Image out Output

SEE ALSO

MeanError, MeanSquareError, RootMeanSquareError, LnNormError, IDivergence


DIPlib function reference 407

MeanError
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip MeanError ( in1, in2, mask, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean error difference between all pixel values of in1 and in2. Optionally the
mask image can be used to exclude pixels from the calculation by setting the value of these
pixels in mask to zero.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image mask Mask
dip Image out Output

SEE ALSO

MeanSquareError, RootMeanSquareError, MeanAbsoluteError, LnNormError,


IDivergence
408 Chapter 2. Function reference

MeanModulus
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip MeanModulus ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean modulus of the pixel values over all those dimensions which are
specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, SumModulus, MeanSquareModulus, Maximum,
Minimum, Median, Percentile
DIPlib function reference 409

MeanSquareError
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip MeanSquareError ( in1, in2, mask, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean square error difference between all pixel values of in1 and in2.
Optionally the mask image can be used to exclude pixels from the calculation by setting the
value of these pixels in mask to zero.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image mask Mask
dip Image out Output

SEE ALSO

MeanError, RootMeanSquareError, MeanAbsoluteError, LnNormError, IDivergence


410 Chapter 2. Function reference

MeanSquareModulus
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip MeanSquareModulus ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the mean square modulus of the pixel values over all those dimensions which are
specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, SumModulus, Maximum, Minimum,
Median, Percentile
DIPlib function reference 411

Measure
Measure object features

SYNOPSIS

#include "dip measurement.h"


dip Error dip Measure ( measurement, featureID, featureParams, objectID,
objectIm, intensityIm, connectivity, physDims )

DATA TYPES

objectIm: integer intensityIm: integer, float

FUNCTION

The Measure function is the top-level function of DIPlib’s measurement library. This
function performs measurements of the objects in the specified objectIm image. The
measurements to be performed are specified by the featureID array of measurement
function IDs. If the featureParams is non-zero, its size should equal that of featureID.
Although the current implementation of Measure does not make use of this argument,
future versions will pass the data pointers of the featureParams to the corresponding
measurement functions. featureParams should be set to zero for now.
The list of object IDs on which the measurements have to be performed is specified by
objectID. If it is zero, Measure will call GetObjectLabels to obtain a list of all non-zero
values in objectIm. The objectID values should be unequal to zero.
The state of measurement should be raw (see MeasurementNew), since Measure will forge
the measurement data structure by calling MeasurementForge.
The intensityIm image defines the pixel intensity of the objects, whose shape is defined by
objectIm. If none of the measurements specified in featureID require the grey-value image,
it can be set to NULL.
The physDims parameter defines the physical dimensions of the pixel sizes and pixel
intensity. See PhysicalDimensionsNew for more information.
412 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip IntegerArray featureID Array of measurement function IDs
dip VoidPointerArray featureParams (0) Array of parameters to be passed to
each measurement feature function
dip IntegerArray objectID (0) Array of Object IDs
dip Image objectIm Image containing object IDs, i.e.
object labels
dip Image intensityIm Intensity image
dip int connectivity Connectivity of object’s contour
pixels, see The connectivity
parameter
dip PhysicalDimensions physDims Structure specifying the physical
dimensions of the image pixels

SEE ALSO

ObjectToMeasurement, MeasurementSave, FeatureSize, FeatureCenter,


FeatureGravity, FeatureMean, FeatureMass, FeatureStdDev, FeatureMaximum,
FeatureMinimum, FeatureMaxVal, FeatureMinVal, FeaturePerimeter,
FeatureSurfaceArea, FeatureFeret, FeatureInertia
DIPlib function reference 413

MeasurementFeatureConvert
Convert the data of a measurement feature

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureConvert ( in, featureID, inID, out, outID,
resources )

FUNCTION

This function convert the data of object inID in measurement in measured by feature
featureID to object outID in out.

ARGUMENTS

Data type Name Description


dip Measurement in Input measurement data structure
dip int featureID ID of the measurement feature
dip int inID ID of the object in in
dip Measurement out Output measurement data structure
dip int outID ID of the object in out
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementFree, MeasurementNew, MeasurementForge, MeasurementID,


MeasurementSetName, MeasurementGetName, MeasurementSetPhysicalDimensions,
MeasurementGetPhysicalDimensions, MeasurementNumberOfFeatures,
MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureConvert,
MeasurementFeatureDescription, MeasurementNumberOfObjects, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementFeatureFormat, MeasurementFeatureSize, MeasurementIsValid
414 Chapter 2. Function reference

MeasurementFeatureDescription
Measurement Description access function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureDescription ( measurement, featureID,
description, resources )

FUNCTION

The MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat,


MeasurementFeatureLabels, and MeasurementFeatureDescription functions provide
access to the functions that are registered by each measurement function. See also
MeasurementFeatureRegister. This function gives access to a structure containing the
name, a short description of the measurement feature, as well as the labels and units of the
data measured by the feature specified with featureID.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement feature ID
dip FeatureDescription * description Pointer to a dip FeatureDescription
structure containing a description of the
specified feature
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementObjectGetSize,
MeasurementObjects, MeasurementObjectValid, MeasurementObjectData,
MeasurementObjectValue, MeasurementObjectFormat
DIPlib function reference 415

MeasurementFeatureFormat
Feature data format convenience function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureFormat ( measurement, featureID, format )

FUNCTION

This function is a convenience function on top of MeasurementObjectValue, providing an


easy access to the data format of the measurement values of the featureID measurement
function.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dipf MeasurementValueFormat * format Pointer to measurement value data
format

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectValid,
MeasurementObjectData, MeasurementObjectValue
416 Chapter 2. Function reference

MeasurementFeatureLabels
Measurement Labels access function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureLabels ( measurement, featureID, labels,
resources )

FUNCTION

The MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat,


MeasurementFeatureLabels, and MeasurementFeatureDescription functions provide
access to the functions that are registered by each measurement function. See also
MeasurementFeatureRegister. This function gives access to an array of strings containing
labels for the measurement values of the measurement function specified with featureID.
When, for example, a measurement function produces a number of measurement values
equal to the dimemsionality of the label image (see Measure), the number of labels will be
equal to the dimensionality as well.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip StringArray * labels Pointer to an array of labels of the specified
measurement function
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectValid,
MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat
DIPlib function reference 417

MeasurementFeatureRegister
Register a measurement function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureRegister ( registry )

FUNCTION

This function registers a measurement function, specified by registry. See


dip MeasurementFeatureRegistry structure for information about its contents.

ARGUMENTS

Data type Name Description


dip MeasurementFeatureRegistry registry Registry

SEE ALSO

MsrRegistryList, MsrRegistryGet, MsrCreateFunction, MsrMeasureFunction,


MsrValueFunction, MsrConvertFunction, MsrDescriptionFunction
418 Chapter 2. Function reference

MeasurementFeatureRegistryFeatureDescription
Get the feature description of a registered measurement feature

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureRegistryFeatureDescription ( featureID,
description, resources )

FUNCTION

This function obtains the feature description information of the measurement feature
specified by featureID.

ARGUMENTS

Data type Name Description


dip int featureID Measurement feature ID
dip FeatureDescription * description pointer to a dip FeatureDescription
structure containing descriptive
information of the measurement feature.
This data can be accessed with
MsrDescriptionFunction
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFeatureRegister, MeasurementFeatureRegistryList,
MeasurementFeatureRegistryGet
DIPlib function reference 419

MeasurementFeatureRegistryGet
Get the registry information of a measurement feature

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureRegistryGet ( featureID, registry )

FUNCTION

This function obtains (a copy of) the registry structure of the measurement feature function
specified by featureID.

ARGUMENTS

Data type Name Description


dip int featureID Measurement function ID
dip MeasurementFeatureRegistry * registry Pointer to a measurement feature
registry structure

SEE ALSO

MeasurementFeatureRegister, MeasurementFeatureRegistryList,
MeasurementFeatureRegistryFeatureDescription
420 Chapter 2. Function reference

MeasurementFeatureRegistryList
Obtain a list of the registered measurement features

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureRegistryList ( featureID, resources )

FUNCTION

This functions obtains an array of registered measurement feature IDs.

ARGUMENTS

Data type Name Description


dip IntegerArray * featureID Pointer to an array of measurement feature IDs
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementFeatureRegister, MeasurementFeatureRegistryGet
DIPlib function reference 421

MeasurementFeatures
Get the measurement ID array

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatures ( measurement, featureID, resources )

FUNCTION

This function obtains an array of measurement function IDs in the measurement structure.
See MeasurementForge for a (brief) explination of the measurement data structure.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip IntegerArray * featureID pointer to an array of measurement function IDs
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectValid,
MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat,
MeasurementFeatureRegister
422 Chapter 2. Function reference

MeasurementFeatureSize
Feature data convenience function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureSize ( measurement, featureID, size )

FUNCTION

This function is a convenience function on top of MeasurementObjectValue, providing an


easy access to the number of the measurement values of the featureID measurement
function.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID ID of the measurement feature
dip int * size Number of measurement values

SEE ALSO

MeasurementFree, MeasurementNew, MeasurementForge, MeasurementID,


MeasurementSetName, MeasurementGetName, MeasurementSetPhysicalDimensions,
MeasurementGetPhysicalDimensions, MeasurementNumberOfFeatures,
MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureConvert,
MeasurementFeatureDescription, MeasurementNumberOfObjects, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementFeatureFormat, MeasurementFeatureSize, MeasurementIsValid
DIPlib function reference 423

MeasurementFeatureValid
Verify a measurement feature ID

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFeatureValid ( measurement, featureID, verdict )

FUNCTION

This function determines whether featureID is a valid measurement feature, by verifying


whether featureID equals the ID of one of the registered measurement features. If verdict
is not zero, the result (DIP TRUE or DIP FALSE) is stored in verdict, otherwise an error is
returned in case the verification fails.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement feature ID to validated
dip Boolean * verdict Pointer to the boolean verdict

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureDescription, MeasurementObjectGetSize,
MeasurementObjects, MeasurementObjectValid, MeasurementObjectData,
MeasurementObjectValue, MeasurementObjectFormat, MeasurementFeatureRegister
424 Chapter 2. Function reference

MeasurementForge
Allocate the data of a measurement data structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementForge ( measurement, featureID, objectID )

FUNCTION

This function forges a measurement data structure, that has been created with
MeasurementNew. The featureID array should contain the IDs of the features to be
performed. The vadility of these IDs is checked by comparing them with the IDs of
registered measurement functions (see MeasurementFeatureRegister). The objectID
array contains the IDs (i.e. labels) of the objects on which the features are to be performed.
(For example, the Measure function accepts as one of its arguments a label image, of which
the intensity of each individual pixel represents the ID of the object to which that pixel
belongs. These label values should in that case correspond to the values of objectID.)
The measurement structure can be regarded as a matrix spanned by the number of features
along one axis, and the number of objects along the other. MeasurementForge allocates and
initialises the internal structures to contain this matrix and the data required for each
conbimation of measurement and object ID.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement structure
dip IntegerArray featureID Array of measurement function IDs
dip IntegerArray objectID Array of Object IDs

SEE ALSO

MeasurementNew, MeasurementFree, Measure


DIPlib function reference 425

MeasurementFree
Free a measurement data structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementFree ( measurement )

FUNCTION

This function frees a Measurement data structure. After the Measurement has been freed,
the pointer measurement is set to zero.

ARGUMENTS

Data type Name Description


dip Measurement * measurement pointer to the measurement structure to be freed

SEE ALSO

MeasurementNew, MeasurementForge, Measure


426 Chapter 2. Function reference

MeasurementGetName
Get the name of a Measurement structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementGetName ( measurement, name, resources )

FUNCTION

This function gets the name of a measurement structure

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement
dip String * name Name
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementNew, MeasurementFree, Measure, MeasureSetName


DIPlib function reference 427

MeasurementGetPhysicalDimensions
Get the physical dimensions info of a measurement

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementGetPhysicalDimensions ( measurement, physDims,
resources )

FUNCTION

This function obtains a copy of the physical dimensions information associated with the
measurement data structure. The physical dimensions data structure informs measurement
features about the physical sizes and position of the pixels of the measured image.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip PhysicalDimensions * physDims Pointer to a Physical Dimensions data
structure
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

MeasurementFree, MeasurementNew, MeasurementForge, MeasurementID,


MeasurementSetName, MeasurementGetName, MeasurementSetPhysicalDimensions,
MeasurementGetPhysicalDimensions, MeasurementNumberOfFeatures,
MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureConvert,
MeasurementFeatureDescription, MeasurementNumberOfObjects, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementFeatureFormat, MeasurementFeatureSize, MeasurementIsValid
428 Chapter 2. Function reference

MeasurementID
Get the ID of a Measurement structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementID ( measurement, id )

FUNCTION

This function obtains the ID of a the measurement structure. The ID is a DIPlib wide
unique number (see GetUniqueNumber).

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement structure
dip int * id Pointer to the id

SEE ALSO

MeasurementNew, MeasurementFree, Measure


DIPlib function reference 429

MeasurementIsValid
Checks whether a measurement is valid

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementIsValid ( measurement, verdict )

FUNCTION

This function determines whether measurement is forged. If verdict is not zero, the result
(DIP TRUE or DIP FALSE) is stored in verdict, otherwise an error is returned in case the
verification fails.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip Boolean * verdict The validation verdict

SEE ALSO

MeasurementFree, MeasurementNew, MeasurementForge, MeasurementID,


MeasurementSetName, MeasurementGetName, MeasurementSetPhysicalDimensions,
MeasurementGetPhysicalDimensions, MeasurementNumberOfFeatures,
MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureConvert,
MeasurementFeatureDescription, MeasurementNumberOfObjects, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementFeatureFormat, MeasurementFeatureSize, MeasurementIsValid
430 Chapter 2. Function reference

MeasurementNew
Create new measurement data structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementNew ( measurement, resources )

FUNCTION

This function creates, by allocating and initialising it, a new Measurement data structure.
After this function has been used to create a new measurement structure, the state of it is
raw. It needs to be passed through MeasurementForge before it can be used to store
measurement results.

ARGUMENTS

Data type Name Description


dip Measurement * measurement pointer to the measurement structure to be created
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementForge, MeasurementFree, Measure


DIPlib function reference 431

MeasurementNumberOfFeatures
Get the number of measurement feature IDs

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementNumberOfFeatures ( measurement, features )

FUNCTION

This function obtains the number of measurement feature IDs in the measurement structure.
See MeasurementForge for a (brief) explination of the measurement data structure.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int * features pointer to the number of measurement feature IDs

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatures, MeasurementFeatureValid,


MeasurementFeatureDescription, MeasurementObjectGetSize, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementObjectFormat
432 Chapter 2. Function reference

MeasurementNumberOfObjects
Get the number of object IDs

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementNumberOfObjects ( measurement, objects )

FUNCTION

This function obtains the number of object IDs belonging to the featureID measurement
function ID in the measurement structure. See MeasurementForge for a (brief) explination
of the measurement data structure.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int * objects Pointer to an integer containing the number of object
IDs

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjects, MeasurementObjectValid, MeasurementObjectData,
MeasurementObjectValue, MeasurementObjectFormat
DIPlib function reference 433

MeasurementObjectData
Object data access function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementObjectData ( measurement, featureID, objectID, data,
verdict )

FUNCTION

The MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat,


MeasurementFeatureLabels, and MeasurementFeatureDescription functions provide
access to the functions that are registered by each measurement function. See also
MeasurementFeatureRegister.
The Object data is the data allocated by a measurement function for internal purposes: for
example to store intermediate results. Its format is free. Therefore, the use of this function
is only meaningful for a particular measurement function itself. To access the measurement
values of a measurement function, use MeasurementObjectValues. The verdict parameter
provides a means to test whether featureID or objectID are valid within the context of
measurement. If one of them is invalid, and verdict is not zero, *verdict is set to
DIP FALSE, otherwise its value is DIP TRUE. If verdict is zero, MeasurementObjectData
produces an error when either featureID or objectID is invalid.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID Object ID
void ** data Pointer to the internal measurement data pointer
dip Boolean * verdict Pointer to a boolean containing validation
information

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectValid,
MeasurementObjectValue, MeasurementObjectFormat
434 Chapter 2. Function reference

MeasurementObjects
Get an object ID array

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementObjects ( measurement, featureID, objectID,
resources )

FUNCTION

This function obtains an array of object IDs belonging to the featureID measurement
function in the measurement structure. See MeasurementForge for a (brief) explination of
the measurement data structure.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip IntegerArray * objectID Pointer to an object ID array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjectValid, MeasurementObjectData,
MeasurementObjectValue, MeasurementObjectFormat
DIPlib function reference 435

MeasurementObjectValid
Verify an object ID

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementObjectValid ( measurement, featureID, objectID,
verdict )

FUNCTION

This function determines whether the object ID objectID, belonging to the measurement
function ID featureID, is a valid object ID, by comparing objectID to the object IDs
belonging to the featureID in measurement. If verdict is not zero, the result (DIP TRUE or
DIP FALSE) is stored in verdict, otherwise an error is returned in case the verification fails.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID Object ID
dip Boolean * verdict Pointer to a boolean contaning the validation verdict

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectData,
MeasurementObjectValue, MeasurementObjectFormat
436 Chapter 2. Function reference

MeasurementObjectValue
Object value access function

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementObjectValue ( measurement, featureID, objectID,
data, format, resources )

FUNCTION

The MeasurementObjectData, MeasurementObjectValue, MeasurementObjectFormat,


MeasurementFeatureLabels, and MeasurementFeatureDescription functions provide
access to the functions that are registered by each measurement function. See also
MeasurementFeatureRegister.
The MeasurementObjectValue function provides access to the measurement values
produced by the featureID measurement function measured on the objectID labeled
object. The format of data is specified by format.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID Object ID
void ** data Pointer to data pointer
dipf MeasurementValueFormat * format Pointer to the data format label
dip Resources resources Resources tracking structure. See
ResourcesNew
Measurement data formats
Name Description
DIP MSR VALUE FORMAT INTEGER Integer scalar data format
DIP MSR VALUE FORMAT FLOAT Float scalar data format
DIP MSR VALUE FORMAT INTEGER ARRAY Integer array data format
DIP MSR VALUE FORMAT FLOAT ARRAY Float array data format
DIP MSR VALUE FORMAT IMAGE Data is formatted as an dip Image
DIPlib function reference 437

SEE ALSO

MeasurementNew, MeasurementForge, MeasurementFeatureGetSize,


MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureDescription,
MeasurementObjectGetSize, MeasurementObjects, MeasurementObjectValid,
MeasurementObjectData, MeasurementObjectFormat
438 Chapter 2. Function reference

MeasurementRead
Read measurement results from a file

SYNOPSIS

#include "dipio measurement.h"


dip Error dipio MeasurementRead ( measurement, filename, format,
addExtensions, recognised )

FUNCTION

This function reads measurement data from a file and puts it in measurement. measurement
must be allocated before calling this function. If format is 0, all different MeasurementRead
functions are called in sequence until the correct format has been found. If you know the
format, get the correct format ID through the registry functions.
The boolean addExtensions specifies whether MeasurementRead should try to add file
format extensions to filename, if the registered file format reader fails to recognise
filename straight away. The extensions are provided by the registered file readers.
If recognised is not zero, MeasurementRead will set it to DIP TRUE when it has been able
to read filename, and it will set it to DIP FALSE when it is not able to read the file. No
error will be generated in this case.

NOTE

There are currently no measurement reading functions, so this function will always fail.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip String filename File name to read from
dip int format ID of file format
dip Boolean addExtensions Add extensions when looking for the file
dip Boolean * recognised Set to DIP TRUE if the file was found

SEE ALSO

Measure, MeasurementWrite
DIPlib function reference 439

MeasurementSetName
Set the name of a measurement structure

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementSetName ( measurement, name )

FUNCTION

This function sets the name of measurement to name.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement
dip String name Name

SEE ALSO

MeasurementNew, MeasurementFree, Measure, MeasureGetName


440 Chapter 2. Function reference

MeasurementSetPhysicalDimensions
Set the physical dimensions info of the measurement

SYNOPSIS

#include "dip measurement.h"


dip Error dip MeasurementSetPhysicalDimensions ( measurement, physDims )

FUNCTION

This function sets the physical dimensions information for the measurement data structure.
The physical dimensions data structure informs measurement features about the physical
sizes and position of the pixels of the measured image.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip PhysicalDimensions physDims Physical Dimensions data structure

SEE ALSO

MeasurementFree, MeasurementNew, MeasurementForge, MeasurementID,


MeasurementSetName, MeasurementGetName, MeasurementSetPhysicalDimensions,
MeasurementGetPhysicalDimensions, MeasurementNumberOfFeatures,
MeasurementFeatures, MeasurementFeatureValid, MeasurementFeatureConvert,
MeasurementFeatureDescription, MeasurementNumberOfObjects, MeasurementObjects,
MeasurementObjectValid, MeasurementObjectData, MeasurementObjectValue,
MeasurementFeatureFormat, MeasurementFeatureSize, MeasurementIsValid
DIPlib function reference 441

MeasurementWrite
Write measurement results to a file

SYNOPSIS

#include "dipio measurement.h"


dip Error dipio MeasurementWrite ( measurement, filename, format, labels )

FUNCTION

This function writes measurement data to a file, overwriting any other file with the same
name. Get the format ID through the registry functions. If format is 0, CSV is used.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip String filename File name to write to
dip int format ID of file format
dip Boolean labels DIP TRUE to write labels to file

SEE ALSO

Measure, MeasurementRead, MeasurementWriteCSV, MeasurementWriteHTML,


MeasurementWriteText
442 Chapter 2. Function reference

MeasurementWriteCSV
Write measurement results to a CSV file

SYNOPSIS

#include "dipio measurement.h"


dip Error dipio MeasurementWriteCSV (measurement, filename, separator,
labels)

FUNCTION

This function writes the measurement results to a comma separated values (CSV) file,
overwriting any other file with the same name.
This function calls MeasurementWriteText with the proper settings.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip String filename File name to write to
char * separator Characters to separate values
dip Boolean labels DIP TRUE to write labels to file

SEE ALSO

Measure, MeasurementWrite, MeasurementWriteText


DIPlib function reference 443

MeasurementWriteHTML
Write measurement results to an HTML file

SYNOPSIS

#include "dipio measurement.h"


dip Error dipio MeasurementWriteHTML (measurement, filename, separator,
labels)

FUNCTION

This function writes the measurement results to a formatted HTML file, overwriting any
other file with the same name.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip String filename File name to write to
char * separator Characters to separate values
dip Boolean labels DIP TRUE to write labels to file

SEE ALSO

Measure, MeasurementWrite
444 Chapter 2. Function reference

MeasurementWriteText
Write measurement results as readable text

SYNOPSIS

#include "dipio measurement.h"


dip Error dipio MeasurementWriteText ( measurement, fp, options )

FUNCTION

This function saves/prints the results of a measurement stored in the measurement data
structure. Since it will save the results to the fp FILE pointer (which has to be opened
before this function is called, and closed afterwards), the results can be printed to a screen
(specify stdout as fp) or to a file.
The results are saved in a matrix, with a column for each measurement, and a row for each
object. The first column contains the object ID. The options structure provides a means to
adjust the formatting of the measurement data. Its separator variable specifies the column
separator character, the rows are separated by a newline. If the labelAlign variable is
DIP TRUE, the separator is repeated such that the columns are aligned. If the labels
variable is DIP TRUE, the first row contains measurement labels, and info specifies whether
or not the short description of each measurement function should be printed before the
result matrix. If results is DIP FALSE, the measurement values are not printed.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
FILE * fp FILE pointer to which the results are saved
dipio WriteTextFormat options Text formatting options
The structure dipio WriteTextFormat contains the following elements:
Data type Name Description
char * separator Column separator character
dip Boolean info Write descriptio
dip Boolean labels Write labels
dip Boolean results Write values
dip Boolean labelAlign Align columns
DIPlib function reference 445

SEE ALSO

Measure, MeasurementWrite
446 Chapter 2. Function reference

Median
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Median ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the median of the pixel values over all those dimensions which are specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, SumModulus,
MeanSquareModulus, Maximum, Minimum, Percentile
DIPlib function reference 447

MedianFilter
Non-linear smoothing filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip MedianFilter ( in, out, se, boundary, filterParam, shape )

DATA TYPES

integer, float

FUNCTION

Median filter with different structuring elements.


If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
448 Chapter 2. Function reference

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

PercentileFilter, Uniform, Sigma


DIPlib function reference 449

MemoryCopy
Copy memory blocks

SYNOPSIS

void dip MemoryCopy( in, out, number )

FUNCTION

Copy a memory block

ARGUMENTS

Data type Name Description


void * in pointer to memory source block
void * out pointer to memory destination block
dip int number number of bytes to be copied

NOTE

The behaviour of this function is undefined when the in and out blocks overlap.
450 Chapter 2. Function reference

MemoryFree
Free a chunk of memory

SYNOPSIS

dip Error dip MemoryFree( pointer )

FUNCTION

Frees a chunk of memory.

ARGUMENTS

Data type Name Description


void * pointer pointer to an allocated chunk of memory

SEE ALSO

MemoryNew, MemoryReallocate, MemoryFunctionsSet


DIPlib function reference 451

MemoryFunctionsSet
Sets memory allocation functions

SYNOPSIS

dip Error dip MemoryFunctionsSet( MemoryNewFunction,


MemoryReallocateFunction, MemoryFreeFunction )

FUNCTION

Sets the memory allocation functions used by DIPlib.

ARGUMENTS

Data type Name Description


dip MemoryNewFunction MemoryNewFunction pointer to a memory
allocation function
dip MemoryReallocateFunction MemoryReallocateFunction pointer to a memory
reallocation function
dip MemoryFreeFunction MemoryFreeFunction pointer to a memory
freeing function

NOTE

The three allocation functions are defined as follows:


typedef void* (*dip MemoryNewFunction)(size t size)
typedef void* (*dip MemoryReallocateFunction)(void *ptr, size t size)
typedef void (*dip MemoryFreeFunction)(void *ptr)
And are by default set to malloc, realloc and free.

SEE ALSO

MemoryNew, MemoryReallocate, MemoryFree


452 Chapter 2. Function reference

MemoryNew
Allocate and track memory

SYNOPSIS

dip Error dip MemoryNew( pointer, size, resources )

FUNCTION

Allocates a chunk of memory, and adds a reference to the chunk to the list of tracked
resources.

ARGUMENTS

Data type Name Description


void ** pointer pointer to the memory chunk pointer
size t size size of the memory chunk in bytes
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MemoryReallocate, MemoryFree, MemoryFunctionsSet


DIPlib function reference 453

MemoryReallocate
Reallocate a chunk of memory

SYNOPSIS

dip Error dip MemoryReallocate ( pointer, newsize, resources )

FUNCTION

Reallocates a chunk of memory, to change its size. resources must be the dip Resources
structure used in the call to MemoryNew when pointer was allocated.

ARGUMENTS

Data type Name Description


void ** pointer pointer to the memory chunk pointer
size t newsize size of the memory chunk in bytes
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

MemoryNew, MemoryFree, MemoryFunctionsSet


454 Chapter 2. Function reference

mErf
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Erf ( x )

FUNCTION

Computes the error function of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErfc,
mGammaP, mGammaQ
DIPlib function reference 455

mErfc
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Erfc ( x )

FUNCTION

Computes the complementary error function of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mGammaP, mGammaQ
456 Chapter 2. Function reference

mExp10
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Exp10 ( x )

FUNCTION

Computes the base ten exponent of the input value.

ARGUMENTS

Data type Name Description


dip float value Value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP, mGammaQ
DIPlib function reference 457

mExp2
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Exp2 ( x )

FUNCTION

Computes the base two exponent of the input value.

ARGUMENTS

Data type Name Description


dip float value Value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP, mGammaQ
458 Chapter 2. Function reference

mFraction
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Fraction ( x )

FUNCTION

Computes the fraction of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal, mBesselJ0,


mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
DIPlib function reference 459

mGammaP
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm GammaP ( a, x )

FUNCTION

Computes the incomplete gamma function of the input value.

ARGUMENTS

Data type Name Description


dip float a A
dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaQ
460 Chapter 2. Function reference

mGammaQ
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm GammaQ ( a, x )

FUNCTION

Computes the complementary incomplete gamma function of the input value.

ARGUMENTS

Data type Name Description


dip float a A
dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP
DIPlib function reference 461

Min
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Min ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function computes out = min(in1 , in2) on a pixel by pixel basis. The data types of
the in1 and in2 image may be of different types. See Information about dyadic operations
for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Max, MaxFloat, MinFloat


462 Chapter 2. Function reference

MinFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip MinFloat ( in, out, constant )

DATA TYPES

binary, integer, float

FUNCTION

This function computes out = min(in , constant) on a pixel by pixel basis. The data types
of the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float constant Constant

SEE ALSO

Max, MaxFloat, Min


DIPlib function reference 463

Minima
Detects local minima

SYNOPSIS

#include "dip filtering.h"


dip Error dip Minima ( in, mask, out, connectivity, booleanOutput )

DATA TYPES

integer, float

FUNCTION

This function detects local minima.


The algorithm finds a connected set of pixels with identical value, an no neighbours with
lower value. This set is a local minimum and its pixels are set to 1 in the output image. If
booleanOutput is false, the output image is a labelled image.
This function differs from LocalMinima in that it marks every minimum. LocalMinima is
able to filter out unimportant minima.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image mask Mask image
dip Image out Binary output image
dip int connectivity Connectivity
dip Boolean booleanOutput Give a binary output image?

NOTE

If you are looking for the old version of Minima, it is still available through the following
combination of commands:

dip_Erosion( in, out, se, boundary, filterParam, shape );


dip_Equal( in, out, out );
464 Chapter 2. Function reference

SEE ALSO

Maxima, LocalMinima, SeededWatershed, GrowRegions


DIPlib function reference 465

Minimum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Minimum ( in, mask, out, ps )

DATA TYPES

binary, integer, float

FUNCTION

Calculates the minimum of the pixel values over all those dimensions which are specified by
ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, SumModulus,
MeanSquareModulus, Maximum, Median, Percentile
466 Chapter 2. Function reference

Mirror
Mirrors an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Mirror ( in, out, mirror )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function mirrors the pixels in those dimensions of image as specified by mirror.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BooleanArray mirror Mirror flags

SEE ALSO

Map
DIPlib function reference 467

mLnGamma
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm LnGamma ( x )

FUNCTION

Computes the natural logarithm of the gamma function of the input value.

ARGUMENTS

Data type Name Description


dip float value Value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mErf, mErfc,
mGammaP, mGammaQ
468 Chapter 2. Function reference

mLog2
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Log2 ( x )

FUNCTION

Computes the base two logarithm of the input value.

ARGUMENTS

Data type Name Description


dip float value Value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP, mGammaQ
DIPlib function reference 469

mNearestInt
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm NearestInt ( x )

FUNCTION

Computes the nearest int of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal, mBesselJ0,


mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
470 Chapter 2. Function reference

Modulo
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Modulo ( in, out, period )

DATA TYPES

integer

FUNCTION

Computes the modulo of the input image values, by computing the remainder of the the
division of the input image values with period.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip int period Period

SEE ALSO

Div, DivFloat, DivComplex, Reciprocal


DIPlib function reference 471

Modulus
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Modulus ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the modulus of the input image values, and outputs a float typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Phase, Real, Imaginary


472 Chapter 2. Function reference

MonadicFrameWork
FrameWork for monadic operations

SYNOPSIS

#include "dip framework.h"


dip Error dip MonadicFrameWork ( in, out, processBoundary, processBorder,
process )

FUNCTION

This function is a frontend on the SeparableFrameWork. It provides an easier interface for


filters that only need to scan an image once. The dimension in which the image should be
scan can be specified or left to MonadicFrameWork by specifiying the dimension with
DIP MONADIC OPTIMAL DIMENSION.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Boundary processBoundary ProcessBoundary
dip int processBorder ProcessBorder
dip FrameWorkProcess process Process

SEE ALSO

SeparableFrameWork, SingleOutputFrameWork
DIPlib function reference 473

MorphologicalGradientMagnitude
Morphological edge detector

SYNOPSIS

#include "dip morphology.h"


dip Error dip MorphologicalGradientMagnitude ( in, out, se, boundary,
filterParam, shape, edgeType )

DATA TYPES

integer, float

FUNCTION

The same as MorphologicalRange.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip MphEdgeType edgeType edgeType

SEE ALSO

MorphologicalRange, Lee, MultiScaleMorphologicalGradient, Tophat


474 Chapter 2. Function reference

MorphologicalRange
Morphological edge detector

SYNOPSIS

#include "dip morphology.h"


dip Error dip MorphologicalRange ( in, out, se, boundary, filterParam, shape,
edgeType )

DATA TYPES

integer, float

FUNCTION

Implements a morphological edge detector based on the difference of two complementary


morphological operations. These can be chosen through the edgeType parameter.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip MphEdgeType edgeType edgeType
DIPlib function reference 475

The enumerator dip FilterShape contains the following constants:


Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The enumerator dip MphEdgeType contains the following constants:
Name Description
DIP MPH TEXTURE Response is limited to edges in texture
DIP MPH OBJECT Response is limited to object edges
DIP MPH BOTH All edges produce equal response

SEE ALSO

MorphologicalGradientMagnitude, Lee, MultiScaleMorphologicalGradient, Tophat


476 Chapter 2. Function reference

MorphologicalReconstruction
Morphological filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip MorphologicalReconstruction ( marker, mask, out, connectivity )

DATA TYPES

integer, float

FUNCTION

Dilation of the image marker, constrained by the image mask. out will be smaller or equal
to mask. The image is grown according to the connectivity parameter. See The
connectivity parameter for more information.

ARGUMENTS

Data type Name Description


dip Image marker Marker input image
dip Image mask Mask input image
dip Image out Output image
dip int connectivity Connectivity

LITERATURE

K. Robinson and P.F. Whelan, Efficient morphological reconstruction: a downhill filter,


Pattern Recognition Letters 25 (2004) 1759-1767.

SEE ALSO

Dilation, BinaryPropagation
DIPlib function reference 477

MorphologicalSmoothing
Morphological smoothing filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip MorphologicalSmoothing ( in, out, se, boundary, filterParam,
shape, flags )

DATA TYPES

integer, float

FUNCTION

Implements a morphological smoothing based on the sequence of two complementary


morphological operations. These can be chosen through the dipf MphSmoothing parameter.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dipf MphSmoothing flags flags
478 Chapter 2. Function reference

The enumerator dip FilterShape contains the following constants:


Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The enumerator dipf MphSmoothing contains the following constants:
Name Description
DIP MPH OPEN CLOSE First the opening, then the closing
DIP MPH CLOSE OPEN First the closing, then the opening
DIP MPH AVERAGE The average of the result of the two above

SEE ALSO

MorphologicalThreshold, Tophat
DIPlib function reference 479

MorphologicalThreshold
Morphological smoothing filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip MorphologicalThreshold ( in, out, se, boundary, filterParam,
shape, edgeType )

DATA TYPES

integer, float

FUNCTION

Implements a morphological smoothing based on the average of two complementary


morphological operations. These can be chosen through the edgeType parameter.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip MphEdgeType edgeType edgeType
480 Chapter 2. Function reference

The enumerator dip FilterShape contains the following constants:


Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The enumerator dip MphEdgeType contains the following constants:
Name Description
DIP MPH TEXTURE Response is limited to edges in texture
DIP MPH OBJECT Response is limited to object edges
DIP MPH BOTH All edges produce equal response

SEE ALSO

MorphologicalSmoothing, Tophat
DIPlib function reference 481

mReciprocal
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Reciprocal ( x )

FUNCTION

Computes the reciprocal (1/x) of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mBesselJ0,


mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
482 Chapter 2. Function reference

mSign
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Sign ( x )

FUNCTION

Computes the sign of the input value. The sign of zero is defined as zero.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mExp2, mExp10, mLog2, mSinc, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP, mGammaQ
DIPlib function reference 483

mSinc
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Sinc ( x )

FUNCTION

Computes the sinc (sin(x)/x) of the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mTruncate, mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mReciprocal,


mBesselJ0, mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf,
mErfc, mGammaP, mGammaQ
484 Chapter 2. Function reference

MsrComposeFunction
Measurement compose function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrComposeFunction) ( measurement, featureID, label,
intensity, compositeFeatureID, resources )

FUNCTION

The compose function is called to obtain a list of measurement features. These features are
than measured before the MsrMeasureFunction of this composite feature function is called.
The compose function is called after the MsrCreateFunction.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement feature function ID
dip Image label Image with pixel intensities represending
object IDs
dip Image intensity Image containing corresponding intensity
values
dip IntegerArray * compositeFeatureID Pointer to an integer array containing the
the IDs of the measurement features this
function requires
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrCreateFunction,


MsrMeasureFunction, MsrValueFunction, MsrConvertFunction,
MsrDescriptionFunction
DIPlib function reference 485

MsrConvertFunction
Measurement convert function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrConvertFunction) ( in, featureID, inID, out, outID,
resources )

FUNCTION

The convert function converts the data measurement of the feature feaureID for the
object inID in the measurement in to object outID of measurement out. for each
measurement value.

ARGUMENTS

Data type Name Description


dip Measurement in Input measurement data structure
dip int featureID Measurement function ID
dip int inID ID of the object in in
dip Measurement out Output measurement data structure
dip int outID ID of the object in out
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrCreateFunction,


MsrValueFunction, MsrMeasureFunction, MsrDescriptionFunction
486 Chapter 2. Function reference

MsrCreateFunction
Measurement create function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrCreateFunction) ( measurement, featureID, label,
intensity, params, data, resources )

FUNCTION

The create function is called to initialise the measurement function. It is meant to allocate
and initialise data for the internal use by the measurement function itself.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement feature function ID
dip Image label Image with pixel intensities represending object IDs
dip Image intensity Image containing corresponding intensity values
void * params Measurement function initialisation parameters, not
yet implemented
void ** data Pointer to a data pointer that should point to
allocated data that can be accessed using
MsrObjectData
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrMeasureFunction,


MsrValueFunction, MsrConvertFunction, MsrDescriptionFunction
DIPlib function reference 487

MsrDescriptionFunction
Measurement feature description function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrDescriptionFunction) ( measurement, featureID, physDims,
decription, resources )

FUNCTION

The description function obtains a dip FeatureDescription structure containing


descriptive of the measurement function, such as its name, a shirt description, labels for
each value measured, and units of its measurement.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip FeatureDescription * description pointer to a dip FeatureDescription
structure containing descriptive
information of the measurement feature
function. This data can be accessed with
MsrDescriptionFunction
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrCreateFunction,


MsrValueFunction, MsrMeasureFunction, MsrConvertFunction
488 Chapter 2. Function reference

MsrMeasureFunction
Measurement measure function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrLineMsrFunction) ( measurement, featureID,
label,intensity, size, objectID, dim, iterations )
dip Error (*dip MsrImageMsrFunction) ( measurement, featureID, label,
intensity, objectID, iterations )
dip Error (*dip MsrChainCodeMsrFunction) ( measurement, featureID, objectID,
chaincode, iterations )
dip Error (*dip MsrCompositeMsrFunction) ( measurement, featureID, objectID,
composite, iterations )

FUNCTION

The union dip MsrMeasureFunction contains the following elements:

dip_MsrLineMsrFunction line;
dip_MsrImageMsrFunction image;
dip_MsrChainCodeMsrFunction chaincode;
dip_MsrCompositeMsrFunction composite;

The measure function is the function that performs the actual measurement. It The four
different measurement functions line, image, chaincode and composite differ in the way
the object label, shape and intensity information is provided.
The line measure function obtains two arrays (label and intensity) with label and
intensity information of the to be measured objects. The line measurement function is
called for every (X-) line in the image. Since label can contain more than one different
labels, line itself is responsible for storing the measurement results for the appropriate
object (using, for example, MsrObjectData). The object ID array label can contain values
that are not present in objectID. These labels should be ignored.
The image measurement function is meant for measurement operation that need
neighborhood or global object shape information for its operation (e.g. the MsrSurfaceArea
function needs to evaluate the 6 connected neighborhood of each boundary voxel). The
object ID image label can contain values that are not present in objectID. These labels
should be ignored.
DIPlib function reference 489

The chaincode measure function is meant for 2-D measurement functions that only require
information on the shape of the object’s contour, e.g. MsrPerimeter. The chaincode
function is called for each object seperately, with the contour of that object stored in
chaincode.
The composite measure function is meant for measurement function that derive their
measurement function from the results of other measurement functions. The measurement
functions this function is based on is obtained by calling the MsrComposeFunction callback
function. The composite measure function obtains the results of these measurements
through its composite function parameter (type: dip Measurement). The composite
function is therefore able to obtain these measurement results (e.g. by using
dip MeasurementObjectValue).

ARGUMENTS

The argumenents of these functions are:


line:
Data type Name Description
dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip sint32 * label Pointer to a list (image line) of object IDs
dip float * intensity Pointer to a list of corresponding intensity values
dip int size Size of the label and intensity list
dip IntegerArray objectID Array of objectIDs to be measured
dip int dim Dimension of the line, see ScanFrameWork
dip int iterations Number of iterations the measure function needs to
scan the data
image:
Data type Name Description
dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip Image label Image with pixel intensities represending object IDs
dip Image intensity Image containing corresponding intensity values
dip IntegerArray objectID Array of objectIDs to be measured
dip int iterations Number of iterations the measure function needs to
scan the data
chaincode:
490 Chapter 2. Function reference

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID ID of the object to be measured
dip ChainCode chaincode Chaincode data structure encoding the object’s
contour
dip int iterations Number of iterations the measure function needs to
scan the data
composite:
Data type Name Description
dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID ID of the object to be measured
dip Measurement composite Measurement structure containing the measurement
data this function is based on
dip int iterations Number of iterations the measure function needs to
scan the data

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrCreateFunction,


MsrValueFunction, MsrConvertFunction, MsrDescriptionFunction,
MsrComposeFunction
DIPlib function reference 491

MsrValueFunction
Measurement value function

WARNING: this documentation page is outdated!

SYNOPSIS

#include "dip measurement.h"


dip Error (*dip MsrValueFunction) ( measurement, featureID, objectID, data,
format, resources )

FUNCTION

The value function give access to the measurement values produced by the measurement
function.

ARGUMENTS

Data type Name Description


dip Measurement measurement Measurement data structure
dip int featureID Measurement function ID
dip int objectID ID of the object to be measured
void ** data pointer to a data pointer that points
to allocated data that can be
accessed using
MeasurementObjectValue
dipf MeasurementValueFormat * format pointer to a data format label, See
MeasurementObjectValue
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

dip MsrRegistry structure MeasurementFeatureRegister, MsrCreateFunction,


MsrValueFunction, MsrConvertFunction, MsrDescriptionFunction
492 Chapter 2. Function reference

mTruncate
mathematical function

SYNOPSIS

#include "dip math.h"


dip float dipm Truncate ( x )

FUNCTION

Truncates the input value.

ARGUMENTS

Data type Name Description


dip float x Input value

SEE ALSO

mFraction, mNearestInt, mSign, mExp2, mExp10, mLog2, mSinc, mReciprocal, mBesselJ0,


mBesselJ1, mBesselJN, mBesselY0, mBesselY1, mBesselYN, mLnGamma, mErf, mErfc,
mGammaP, mGammaQ
DIPlib function reference 493

Mul
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Mul ( in1, in2, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in1 * in2 on a pixel by pixel basis. The data types of the
in1 and in2 image may be of different types. See Information about dyadic operations for
more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, MulFloat, MulComplex, Div,


DivFloat, DivComplex
494 Chapter 2. Function reference

MulComplex
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip MulComplex ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in * constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip complex constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulFloat, Div, DivFloat,
DivComplex
DIPlib function reference 495

MulFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip MulFloat ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in * constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip float constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, SubComplex, Mul, MulComplex, Div, DivFloat,
DivComplex
496 Chapter 2. Function reference

MultiScaleMorphologicalGradient
Morphological edge detector

SYNOPSIS

#include "dip morphology.h"


dip Error dip MultiScaleMorphologicalGradient ( in, out, se, boundary,
upperSize, lowerSize, shape )

DATA TYPES

integer, float

FUNCTION

This function computes the average morphological gradient over a range of scales bounded
by upperSize and lowerSize. The morphological gradient is computed as the difference of
the dilation and erosion of the input image at a particular scale, eroded by an erosion of one
size smaller. At the lowest scale, the size of the structuring element is 2 * upperSize + 1.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).
DIPlib function reference 497

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip int upperSize Upper size of structuring element
dip int lowerSize Lower size of structuring element
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

LITERATURE

D. Wang, Pattern Recognition, 30(12), pp. 2043-2052, 1997

SEE ALSO

Lee, MorphologicalGradientMagnitude, MorphologicalRange, Tophat


498 Chapter 2. Function reference

NearestInt
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip NearestInt ( in, out )

DATA TYPES

binary, integer, float, complex binary, integer, float

FUNCTION

Computes the nearest integer value of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Ceil, Floor, Sign, Truncate, Fraction


DIPlib function reference 499

NeighbourIndicesListMake
Get indices to direct neighbours

SYNOPSIS

#include "dip neighbourlist.h"


dip Error dip NeighbourIndicesListMake ( stride, connectivity, indices,
resources )

FUNCTION

A list indices is created with the relative indices to the direct neighbours of a pixel in an
image whose strides are given by stride. How many direct neighbours are returned is
controlled by connectivity, see The connectivity parameter for the available values and
their meaning.
indices is allocated and tracked in resources.

ARGUMENTS

Data type Name Description


dip IntegerArray stride Stride array
dip int connectivity Connectivity
dip IntegerArray * indices Output neighbour indices
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

NeighbourListMake, NeighbourListMakeChamfer, NeighbourListMakeImage,


NeighbourListToIndices, NeighbourIndicesListMake
500 Chapter 2. Function reference

NeighbourListMake
Get list of direct neighbours

SYNOPSIS

#include "dip neighbourlist.h"


dip Error dip NeighbourListMake ( ndims, connectivity, coords, resources )

FUNCTION

A list coords is created with the relative coordinates to the direct neighbours of a pixel in
an ndims-dimensional image. How many direct neighbours are returned is controlled by
connectivity, see The connectivity parameter for the available values and their meaning.
coords is allocated and tracked in resources.

ARGUMENTS

Data type Name Description


dip int ndims Image dimensionality
dip int connectivity Connectivity
dip CoordinateArray * coords Output neighbour coordinates
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

NeighbourListMake, NeighbourListMakeChamfer, NeighbourListMakeImage,


NeighbourListToIndices, NeighbourIndicesListMake
DIPlib function reference 501

NeighbourListMakeChamfer
Get list of neighbours based on Chamfer metric

SYNOPSIS

#include "dip neighbourlist.h"


dip Error dip NeighbourListMakeChamfer ( pixelsize, maxdistance, coords,
distance, resources )

FUNCTION

A list coords is created with the relative coordinates to the neighbours of a pixel in an
pixelsize->size-dimensional image. Here, neighbours are all pixels within a maxdistance
distance. pixelsize gives the size of a pixel, and hence controls the size of the
neighbourhood with maxdistance. Anisotropic pixel grids are supported. distance
contains the distance to each of the neighbours in coords.
Distances between two pixels are taken to be the Euclidean distance. There are better
metrics described in the literature for small neighbourhoods, that yield a more isotropic
measure when compounded over longer distances. These are not implemented in this
function.
coords and distance are allocated and tracked in resources.

ARGUMENTS

Data type Name Description


dip FloatArray pixelsize Physical dimensions of the pixels
dip int maxdistance Maximum distance to which select neighbours
dip CoordinateArray * coords Output neighbour coordinates
dip FloatArray * distance Output distances to neighbours
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

NeighbourListMake, NeighbourListMakeChamfer, NeighbourListMakeImage,


NeighbourListToIndices, NeighbourIndicesListMake
502 Chapter 2. Function reference

NeighbourListMakeImage
Get list of neighbours based on metric in image

SYNOPSIS

#include "dip neighbourlist.h"


dip Error dip NeighbourListMakeImage ( metric, coords, distance, resources )

FUNCTION

A list coords is created with the relative coordinates to the neighbours of a pixel in an
image, with dimensionality as in metric. metric is an image that specifies the distance to
each of the neighbours. This image must be odd in size, the centre pixel is the origin of the
neighbourhood. Any pixel with value 0 is not considered part of the neighbourhood.
distance contains the distance to each of the neighbours in coords.
Distances between two pixels are taken to be the Euclidean distance. There are better
metrics described in the literature for small neighbourhoods, that yield a more isotropic
measure when compounded over longer distances. These are not implemented in this
function.
coords and distance are allocated and tracked in resources.

ARGUMENTS

Data type Name Description


dip Image metric Image whose pixel values indicate the neighbour
distance
dip CoordinateArray * coords Output neighbour coordinates
dip FloatArray * distance Output distances to neighbours
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

NeighbourListMake, NeighbourListMakeChamfer, NeighbourListMakeImage,


NeighbourListToIndices, NeighbourIndicesListMake
DIPlib function reference 503

NeighbourListToIndices
Get indices to neighbours

SYNOPSIS

#include "dip neighbourlist.h"


dip Error dip NeighbourListToIndices ( coords, stride, indices, resources )

FUNCTION

This function translates the relative coordinates in coords into relative indices into an
image with strides given by stride.
indices is allocated and tracked in resources.

ARGUMENTS

Data type Name Description


dip CoordinateArray coords Input neighbour coordinates
dip IntegerArray stride Stride array
dip IntegerArray * indices Output neighbour indices
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

NeighbourListMake, NeighbourListMakeChamfer, NeighbourListMakeImage,


NeighbourListToIndices, NeighbourIndicesListMake
504 Chapter 2. Function reference

NormaliseSum
Normalise the sum of the pixel values

SYNOPSIS

#include "dip math.h" #include "dip manipulation.h"


dip Error dip NormaliseSum ( in, out, newSum )

DATA TYPES

binary, integer, float

FUNCTION

This function normalizes the sum of the pixel values in in to newSum, and puts the result in
out.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float newSum New sum
DIPlib function reference 505

NotEqual
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip NotEqual ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when corresponding pixels in in1 and in2 are
different. This is the same as Compare with the DIP SELECT NOT EQUAL selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to the functionality of NotZero, but with more options.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Equal, Greater, Lesser, NotGreater, NotLesser, SelectValue,


NotZero
506 Chapter 2. Function reference

NotGreater
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip NotGreater ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when for corresponding pixels in1 <= in2.
This is the same as Compare with the DIP SELECT LESSER EQUAL selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to a functionality similar to that of Threshold.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Equal, Greater, Lesser, NotEqual, NotLesser, SelectValue,


NotZero
DIPlib function reference 507

NotLesser
Compare grey values in two images

SYNOPSIS

#include "dip math.h"


dip Error dip NotLesser ( in1, in2, out )

DATA TYPES

binary, integer, float

FUNCTION

This function sets each pixel in out to “true” when for corresponding pixels in1 >= in2.
This is the same as Compare with the DIP SELECT GREATER EQUAL selector flag.
in2 can be a 0D image for comparison of pixel values with a single scalar value. This leads
to a functionality similar to that of Threshold.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Compare, Threshold, Equal, Greater, Lesser, NotEqual, NotGreater, SelectValue,


NotZero
508 Chapter 2. Function reference

NotZero
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip NotZero ( in, out )

DATA TYPES

integer, float

FUNCTION

This function returns a binary image with value 1 where in != 0 and value 0 elsewhere.
The opposite can be accomplished with SelectValue: dip SelectValue(in,out,0);.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image

SEE ALSO

Threshold, SelectValue, Compare, RangeThreshold


DIPlib function reference 509

ObjectToMeasurement
Convert object label value to measurement value

SYNOPSIS

#include "dip measurement.h"


dip Error dip ObjectToMeasurement ( object, intensity, out, connectivity,
objectID, featureID, measurementDim )

DATA TYPES

objectIm: integer intensityIm: integer, float

FUNCTION

This function produces an output image which pixel intensities are equal to the
measurement value that the featureID measurement function measured on the object who
label is defined by the pixel intensity of the corresponding pixel in object. This function is
therefore useful to select (i.e. threshold) objects on basis of a measurement perfomed on the
object. intensity provides pixel intensity information for measurements that require pixel
intensity information of the objects, whose shape is defined by object.
The list of object IDs on which the measurements have to be performed is specified by
objectID. If it is zero, ObjectToMeasurement will call GetObjectLabels to obtain a list of
all non-zero values in objectIm.
If the featureID measurement function produces an array of measurement values,
measurementDim will be used to select the desired array element.

ARGUMENTS

Data type Name Description


dip Image object Object label image
dip Image intensity Object intensity image
dip Image out Output image
dip int connectivity Connectivity of object’s contour pixels, see The
connectivity parameter
dip IntegerArray objectID Array of Object IDs
dip int featureID Measurement function ID
dip int measurementDim Measurement results array index
510 Chapter 2. Function reference

SEE ALSO

Measure, SmallObjectsRemove, FeatureSize, FeatureCenter, FeatureGravity,


FeatureMean, FeatureMass, FeatureStdDev, FeatureMaximum, FeatureMinimum,
FeatureMaxVal, FeatureMinVal, FeaturePerimeter, FeatureSurfaceArea,
FeatureFeret, FeatureInertia
DIPlib function reference 511

OneDimensionalSearch
Numerical algorithm

SYNOPSIS

#include "dip numerical.h"


dip Error dip OneDimensionalSearch ( result, min, max, tol, func, dfunc,
data, searchfor )

FUNCTION

This function implements a numerical line-search for either the minimum or zero-crossing of
a function. The obejctive is searched for in the range specified by min and man with a
tolerance of tol. The search methods are based on Brent’s algorithm. The dfunc parameter
is preparation for support of search algorithms using derivative information. This is not
supported in the current implementation, and dfunc should be set to zero.

ARGUMENTS

Data type Name Description


dip float * result Result value
dip float min Minimum value of search domain
dip float max Maximum value of search domain
dip float tol Tolerance
dip OneDimensionalSearchFunction func Function
dip OneDimensionalSearchFunction dfunc Derivative function
void * data User-supplied Data passed to func
and dfunc
dipf OneDimensionSearch searchfor Search for minimum of
zero-crossing
512 Chapter 2. Function reference

Opening
Morphological opening operation

SYNOPSIS

#include "dip morphology.h"


dip Error dip Opening ( in, out, se, boundary, filterParam, shape )

DATA TYPES

integer, float, binary

FUNCTION

Grey-value opening with different structuring elements.


The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
DIPlib function reference 513

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

SEE ALSO

Closing, Dilation, Erosion


514 Chapter 2. Function reference

Or
logic operation

SYNOPSIS

#include "dip math.h"


dip Error dip Or ( in1, in2, out )

DATA TYPES

binary, integer

FUNCTION

The function Or performs the logic OR operation between the corresponding pixels in in1
and in2, and stores the result in out.

ARGUMENTS

Data type Name Description


dip Image in1 First binary input image
dip Image in2 Second binary input image
dip Image out Output image

SEE ALSO

And, Xor, Invert


DIPlib function reference 515

ovl.h
Call an overloaded function

SYNOPSIS

dip_DataType ovlDataType = [current data type];


[#define DIP_OVL_ASSIGN [assignment target]]
#define DIP_OVL_FUNC [function base name]
#define DIP_OVL_ARGS [argument list]
#define DIP_OVL_ALLOW [type identifiers]
#include "dip_ovl.h"

FUNCTION

Call a type specific function based on the data type stored in the ovlDataType variable. The
base name of the function is passed to dip ovl.h by defining DIP OVL FUNC. The argument
list is passed by defining DIP OVL ARGS. By defining DIP OVL ALLOW the list of data types for
which overloading is possible can be controlled. If DIP OVL ALLOW is not defined, all data
types are allowed. The list is specified by a logical OR of identifier and identifier group
flags, see the table at DIPlib’s data types. The code executed by dip ovl.h is the following:

/* if ovlDataType is in the list specified by DIP_OVL_ALLOW */


DIPXJ( DIP_FUNC(DIP_OVL_FUNC,ovlDataType’s extension) DIP_OVL_ARGS );
/* if ovlDataType is not in the list specified by DIP_OVL_ALLOW */
DIPSJ( DIP_E_DATA_TYPE_NOT_SUPPORTED );

DIP FUNC is described in macros.h. Note that there are no brackets around DIP OVL ARGS,
so they must be included in DIP OVL ARGS itself. If ovlDataType is one of the binary types,
DIP OVL BINARY ARGS can be defined to override DIP OVL ARGS.
If DIP OVL ASSIGN is defined, the following code will be executed by dip ovl.h instead of
the code shown above:

DIP_OVL_ASSIGN DIP_FUNC(DIP_OVL_FUNC,ovlDataType’s extension) DIP_OVL_ARGS;

Note that to actually perform an assignment the “=“ operator must be included in the
definition of DIP OVL ASSIGN itself. DIP OVL BINARY ASSIGN overrides DIP OVL ASSIGN if
ovlDataType is one of the binary data types.

SEE ALSO

DIPlib’s data types


516 Chapter 2. Function reference

DataTypeGetInfo, tpi.h
DIPlib function reference 517

PaintBox
Paint a box

SYNOPSIS

#include "dip paint.h"


dip Error dip PaintBox ( im, length, orign, amplitude )

DATA TYPES

binary, integer, float, complex

FUNCTION

Paints an box object in the image by replacing the values of the pixels in im that lie within
the box (as specified by length and origin) with amplitude, and leaving the other pixel
values untouched.

ARGUMENTS

Data type Name Description


dip Image im Image
dip FloatArray length Length array
dip FloatArray origin Origin array
dip float amplitude Pixel value of the painted ellips

SEE ALSO

PaintEllipsoid, PaintDiamond
518 Chapter 2. Function reference

PaintDiamond
Paint a diamond-shaped object

SYNOPSIS

#include "dip paint.h"


dip Error dip PaintDiamond ( im, length, orign, amplitude )

DATA TYPES

binary, integer, float, complex

FUNCTION

Paints a diamond-shaped object in the image by replacing the values of the pixels in im that
lie within the diamond (as specified by length and origin) with amplitude, and leaving
the other pixel values untouched.

ARGUMENTS

Data type Name Description


dip Image im Image
dip FloatArray length Length array
dip FloatArray origin Origin array
dip float amplitude Pixel value of the painted ellips

SEE ALSO

PaintEllipsoid, PaintBox
DIPlib function reference 519

PaintEllipsoid
Paint an ellipsoid

SYNOPSIS

#include "dip paint.h"


dip Error dip PaintEllipsoid ( im, radius, orign, scale, amplitude )

DATA TYPES

binary, integer, float, complex

FUNCTION

Paints an elliptical object in the image by replacing the values of the pixels in im that lie
within the ellips (as specified by diameter and origin) with amplitude, and leaving the
other pixel values untouched.

ARGUMENTS

Data type Name Description


dip Image im Image
dip FloatArray radius Diameter array
dip FloatArray origin Origin array
dip float amplitude Pixel value of the painted ellips

SEE ALSO

PaintDiamond, PaintBox
520 Chapter 2. Function reference

PairCorrelation
Compute the pair correlation function

SYNOPSIS

#include "dip analysis.h"


dip Error dip PairCorrelation ( object, mask, dist, probes, length, sampling,
covariance )

DATA TYPES

binary, integer

FUNCTION

This function computes the pair correlation function of the different phases in object. If
object is a binary image, the image is a regarded as a two phase image. In case object is
of the integer type, the image is regarded as a labeled image, with each integer value
encoding a phase. Optionally a mask image can be provided so select which pixels in object
should be used to compute the pair correlation. The probes variable specifies how many
random point pairs should be drawn to compute the function. Length specifies the
maximum correlation length. The correlation function can be computed using a random of
grid method, as specified by sampling. Finally covariance determines whether only the
correlations ( DIP FALSE) or the covarianances (DIP TRUE) has to be computed.

ARGUMENTS

Data type Name Description


dip Image object Object image
dip Image mask Mask image
dip Distribution dist Ouput distribution
dip int probes Number of probes
dip int length Maximum correlation Length
dipf CorrelationEstimator sampling Samplings method
dip Boolean covariance Compute covariance

SEE ALSO

ChordLength, ProbabilisticPairCorrelation
DIPlib function reference 521

Percentile
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Percentile ( in, mask, out, percentile, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the perc percentile of the pixel values over all those dimensions which are
specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip float perc Percentile
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, SumModulus,
MeanSquareModulus, Maximum, Minimum, Median
522 Chapter 2. Function reference

PercentileFilter
Rank-order filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip PercentileFilter ( in, out, se, boundary, filterParam, shape,
percentile )

DATA TYPES

integer, float

FUNCTION

Rank-order or percentile filter with different filter shapes.


If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip float percentile Percentile (%)
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
DIPlib function reference 523

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

MedianFilter
524 Chapter 2. Function reference

Phase
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Phase ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the phase of the input image values, and outputs a float typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Modulus, Real, Imaginary


DIPlib function reference 525

PhysicalDimensionsCopy
Copy a Physical Dimensions

SYNOPSIS

#include "dip support.h"


dip Error dip PhysicalDimensionsCopy ( newPhysDims, src, resources )

FUNCTION

This function makes a copy of a PhysicalDimensions data structure.

ARGUMENTS

Data type Name Description


dip PhysicalDimensions * newPhysDims New Physical Dimensions data structure
dip PhysicalDimensions src source data structure
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

PhysicalDimensionsNew, PhysicalDimensionsFree, PhysicalDimensionsIsIsotropic


526 Chapter 2. Function reference

PhysicalDimensionsFree
Free a Physical Dimensions data structure

SYNOPSIS

#include "dip support.h"


dip Error dip PhysicalDimensionsFree ( physDims )

FUNCTION

This function free the Physical Dimensions physDims structure.

ARGUMENTS

Data type Name Description


dip PhysicalDimensions * physDims Physical Dimensions data structure

SEE ALSO

PhysicalDimensionsNew, PhysicalDimensionsCopy, PhysicalDimensionsIsIsotropic


DIPlib function reference 527

PhysicalDimensionsIsIsotropic
Checks if the Physical Dimensions are isotropic

SYNOPSIS

#include "dip support.h"


dip Error dip PhysicalDimensionsIsIsotropic ( physDims, verdict )

FUNCTION

This function checks whether the physical dimensions physDims are isotropic by checking
that all its pixel dimensions and dimension units are equal to each other. If verdict is not
zero, the result (DIP TRUE or DIP FALSE) is stored in verdict, otherwise an error is
returned in case the verification fails.

ARGUMENTS

Data type Name Description


dip PhysicalDimensions physDims Physical Dimensions data structure
dip Boolean * verdict Verdict of the test

SEE ALSO

PhysicalDimensionsNew, PhysicalDimensionsFree, PhysicalDimensionsCopy


528 Chapter 2. Function reference

PhysicalDimensionsNew
Allocates a new Physical Dimensions structure

SYNOPSIS

#include "dip support.h"


dip Error dip PhysicalDimensionsNew ( newPhysDims, dimensionality, dims,
orig, dimUnit, intensity, offset, intensUnit, resources )

FUNCTION

This function allocates a new Physical Dimensions structure.


A physical dimensions structure contains information about the physical dimensions of the
data (of dimensionality dimension) in an image. It describes the position (orig) and size
(dims) of a pixel in world coordinates and physical units (dimUnits), as well as the scaling
(intensity) and offset (offset) of the pixel intensity in physical units (intensUnit).
Note that the initial values assigned by this function assume an isotropic pixel size. These
values can be changed within the structure generated if this is not the case.

ARGUMENTS

Data type Name Description


dip PhysicalDimensions * newPhysDims Pointer to a new Physical Dimensions
data structure
dip int dimensionality Dimensionality of the image
dip float dims Initial value for dimensions along all
axes
dip float orig Initial value for origin along all axes
char * dimUnit Initial value for dimensionUnits along
all axes
dip float intensity Initial value for intensity
dip float offset Initial value for offset
char * intensUnit Initial value for intensityUnit
dip Resources resources Resources tracking structure. See
ResourcesNew
The structure dip PhysicalDimensions contains the following elements:
DIPlib function reference 529

Data type Name Description


dip FloatArray dimensions Dimensions of a pixel along each grid axis
dip FloatArray origin Coordinates of the origin in physical units
dip StringArray dimensionUnits Units for dimensions and origin
dip float intensity Intensity scaling in physical units
dip float offset Offset for intensity in physical units
dip String intensityUnit Units for intensity and offset
dip Resources resources Resource tracking; all elements within this
structure are tracked here

SEE ALSO

PhysicalDimensionsFree, PhysicalDimensionsCopy, PhysicalDimensionsIsIsotropic


530 Chapter 2. Function reference

PixelHeapFree
Destroy heap structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelHeapFree ( heap )

FUNCTION

Frees all data associated to heap and sets heap to 0.

ARGUMENTS

Data type Name Description


dip PixelHeap * heap The heap structure

SEE ALSO

PixelHeapNew, StablePixelHeapNew, PixelQueueNew, PixelHeapPush, PixelHeapPop,


PixelHeapIsEmpty
DIPlib function reference 531

PixelHeapIsEmpty
Query heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelHeapIsEmpty ( heap, result )

FUNCTION

Checks to see if there are any items on the heap. See PixelHeapNew for information on the
heap data structure.

ARGUMENTS

Data type Name Description


dip PixelHeap heap The heap structure
dip Boolean * result Set to true if there are no items in the heap

SEE ALSO

PixelHeapNew, StablePixelHeapNew, PixelQueueNew, PixelHeapFree, PixelHeapPush,


PixelHeapPop
532 Chapter 2. Function reference

PixelHeapNew
Create a new heap structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelHeapNew ( heap, ndims, blocksize, order, resources )

FUNCTION

This function allocates space for a new dip PixelHeap structure. Memory allocated is
tracked in resources. The heap is dimensioned to hold pixels from an ndims-dimensional
image, and initially enough space is allocated for blocksize elements. The heap will be
expanded as necessary when used.
The heap stores the coordinates, the value and the pointer to a pixel in an image. Note that
the value does not need to equal the data pointed to by the pointer. ndims can be set to
zero, in which case no coordinates are stored; this does not affect the function of the value
and the pointer.
A heap is a priority queue data structure. Just like a queue, items can be added (pushed)
and subtracted (popped). However, in the priority queue the item popped is always the
higherst priority one: either the one with the highest-valued item (order is
DIP GVSO HIGH FIRST) or lowest-valued item (order is DIP GVSO LOW FIRST). However,
identically-valued items are stored on the heap in unpredictable order. If this order is
important (such as for the GrowRegions algorithm with integer-valued pixels, use a
dip StablePixelHeap instead. See StablePixelHeapNew for information on the stable heap
structure.

ARGUMENTS

Data type Name Description


dip PixelHeap * heap The newly allocated heap structure
dip int ndims Image dimensionality
dip int blocksize Size of each allocation block
dipf GreyValueSortOrder order Determines the heap’s sort order
dip Resources resources Resources tracking structure. See
ResourcesNew
The dipf GreyValueSortOrder enumeration consists of the following values:
Name Description
DIP GVSO HIGH FIRST Process the pixels from high grey-value to low grey-value.
DIP GVSO LOW FIRST Process the pixels from low grey-value to high grey-value.
DIPlib function reference 533

IMPLEMENTATION

When the heap grows beyond its initial size, its capacity is doubled in size by reallocating
the data blocks. However, when removing pixels from the queue, the heap is not shrunk. It
is assumed that the dip PixelHeap structure will be destroyed as soon as the algorithm
using it terminates. Reducing the memory footprint of the heap therefore has no benefit.

SEE ALSO

StablePixelHeapNew, PixelQueueNew, PixelHeapFree, PixelHeapPush, PixelHeapPop,


PixelHeapIsEmpty
534 Chapter 2. Function reference

PixelHeapPop
Pop item onto heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelHeapPop ( heap, coords, pointer, value )

FUNCTION

Pops the next pixel from the heap. See PixelHeapNew for information on the heap data
structure. coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
If the stack was created with ndims set to 0, the coords pointer is ignored. coords,
pointer and value can be NULL if you are not interested in either those values.

ARGUMENTS

Data type Name Description


dip PixelHeap heap The heap structure
dip int * coords Receives the coordinates of the popped item
void ** pointer Receives the pointer of the popped item
dip sfloat * value Receives the value of the popped item

SEE ALSO

PixelHeapNew, StablePixelHeapNew, PixelQueueNew, PixelHeapFree, PixelHeapPush,


PixelHeapIsEmpty
DIPlib function reference 535

PixelHeapPush
Push item onto heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelHeapPush ( heap, coords, pointer, value )

FUNCTION

Pushes a pixel onto the heap. See PixelHeapNew for information on the heap data
structure. All 3 values coords, pointer and value are stored, except if the heap was
created with ndims set to 0, in which case the coords pointer is ignored.
coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
pointer is a pointer to any memory location, and value is the value to be used when
sorting.

ARGUMENTS

Data type Name Description


dip PixelHeap heap The heap structure
dip int * coords Coordinates to be pushed
void * pointer Pointer to be pushed
dip sfloat value Value to be pushed

SEE ALSO

PixelHeapNew, StablePixelHeapNew, PixelQueueNew, PixelHeapFree, PixelHeapPop,


PixelHeapIsEmpty
536 Chapter 2. Function reference

PixelQueueFree
Destroy queue structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelQueueFree ( queue )

FUNCTION

Frees all data associated to queue and sets queue to 0.

ARGUMENTS

Data type Name Description


dip PixelQueue * queue The queue structure

SEE ALSO

PixelQueueNew, PixelHeapNew, StablePixelHeapNew, PixelQueuePush, PixelQueuePop,


PixelQueueIsEmpty
DIPlib function reference 537

PixelQueueIsEmpty
Query queue

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelQueueIsEmpty ( queue, result )

FUNCTION

Checks to see if there are any items on the queue. See PixelQueueNew for information on
the queue data structure.

ARGUMENTS

Data type Name Description


dip PixelQueue queue The queue structure
dip Boolean * result Set to true if there are no items in the queue

SEE ALSO

PixelQueueNew, PixelHeapNew, StablePixelHeapNew, PixelQueueFree, PixelQueuePush,


PixelQueuePop
538 Chapter 2. Function reference

PixelQueueNew
Create a new queue structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelQueueNew ( queue, ndims, blocksize, resources )

FUNCTION

This function allocates space for a new dip PixelQueue structure. Memory allocated is
tracked in resources. The queue is dimensioned to hold pixels from an ndims-dimensional
image, and initially enough space is allocated for blocksize elements. The queue will be
expanded as necessary when used.
The queue stores the coordinates, and the pointer to a pixel in an image. ndims can be set
to zero, in which case no coordinates are stored; this does not affect the function of the
pointer.
A queue is a data structure to which items can be added (pushed) to the back, and
subtracted (popped) from the front (FIFO - First In, First Out).

ARGUMENTS

Data type Name Description


dip PixelQueue * queue The newly allocated queue structure
dip int ndims Image dimensionality
dip int blocksize Size of each allocation block
dip Resources resources Resources tracking structure. See ResourcesNew

IMPLEMENTATION

The queue is stored in an array whose size can be incresed at will. This is accomplished by
a linked list of blocks, each one holds blocksize elements. When more space is needed, a
new block is simply allocated. No data needs to be moved as would be necessary when using
realloc to change the size of the array. Blocks on the front of the queue that become
empty are freed.
DIPlib function reference 539

SEE ALSO

PixelHeapNew, StablePixelHeapNew, PixelQueueFree, PixelQueuePush, PixelQueuePop,


PixelQueueIsEmpty
540 Chapter 2. Function reference

PixelQueuePop
Pop item from queue

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelQueuePop ( queue, coords, pointer, newiteration )

FUNCTION

Pops the next pixel from the queue. See PixelQueueNew for information on the queue data
structure. coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
If the queue was created with ndims set to 0, the coords pointer is ignored. coords and
pointer can be NULL if you are not interested in either those values.
newiteration, when not NULL, will be set to DIP TRUE if the pixel being popped is the first
one in an iteration, or DIP FALSE otherwise. When a new iteration starts, all pixels pushed
onto the queue afterwards belong to the next iteration. This is useful in routines that use
the queue for propagating boundaries, such as GrowRegions. First all boundary pixels are
pushed onto the queue. The first iteration will need to process only these pixels, while at
the same time push new pixels onto the queue for the second iteration. So after pushing all
the initial boundary pixels onto the queue, the first iteration is started by popping the first
pixel. All pixels pushed while processing this and the rest of the pixels will be pushed
behind the “new iteration” marker. When the first pixel after this marker is popped, the
newiteration boolean is set, so the program knows that the second iteration is starting.
Also, the “new iteration” marker is moved to the end of the queue, so that pixels pushed
subsequently will belong to iteration number 3.

ARGUMENTS

Data type Name Description


dip PixelQueue queue The queue structure
dip int * coords Receives the coordinates of the popped item
void ** pointer Receives the pointer of the popped item
dip Boolean * newiteration Set to true when the first item from an iteration is
popped
DIPlib function reference 541

SEE ALSO

PixelQueueNew, PixelHeapNew, StablePixelHeapNew, PixelQueueFree, PixelQueuePush,


PixelQueueIsEmpty
542 Chapter 2. Function reference

PixelQueuePush
Push item onto queue

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip PixelQueuePush ( queue, coords, pointer )

FUNCTION

Pushes a pixel onto the queue. See PixelQueueNew for information on the queue data
structure. Both coords and pointer are stored, except if the stack was created with ndims
set to 0, in which case the coords values are ignored.
coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
pointer is a pointer to any memory location.

ARGUMENTS

Data type Name Description


dip PixelQueue queue The queue structure
dip int * coords Coordinates to be pushed
void * pointer Pointer to be pushed

SEE ALSO

PixelQueueNew, PixelHeapNew, StablePixelHeapNew, PixelQueueFree, PixelQueuePop,


PixelQueueIsEmpty
DIPlib function reference 543

PixelTableAddRun
Add a new run to a pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableAddRun ( table, coordinate, length )

FUNCTION

Adds a new run to a pixel table. The new run is appended to the existing runs in the pixel
table.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip IntegerArray coordinate Coordinate of the run
dip int length Length of the run

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableGetRuns,
PixelTableGetDimensionality, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
544 Chapter 2. Function reference

PixelTableCreateFilter
Create a pixel table from a filter shape

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableCreateFilter ( table, filterSize, filterShape, se,
resources)

FUNCTION

This function allocates and creates a new pixel table data structure. The shape and
dimensionality of the pixel table is specified by the filterSize, filterShape and se
parameters.

ARGUMENTS

Data type Name Description


dip PixelTable * table Pointer to a pixel table
dip FloatArray filterSize Filter size
dip FilterShape filterShape Filter shape
dip Image se Structuring element
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


BinaryImageToPixelTable, PixelTableToBinaryImage
DIPlib function reference 545

PixelTableFrameWork
FrameWork for PixelTable filters

SYNOPSIS

#include "dip framework.h" #include "dip tprunlength.h"


dip Error dip PixelTableFrameWork ( in, out, boundary, process, table )

FUNCTION

Thsi function provides a framework for filters that code the shape of their filter in a pixel
table (runlengths). See SeparableFrameWork for details.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BoundaryArray boundary Boundary conditions
dip FrameWorkProcess process Process
dip PixelTable table Pixel table

SEE ALSO

SeparableFrameWork
546 Chapter 2. Function reference

PixelTableGetDimensionality
Get the dimensionality of a pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetDimensionality ( table, dimension )

FUNCTION

Gets the dimensionality of the binary object that is encoded by the pixel table table.

ARGUMENTS

Data type Name Description


dip PixelTable table pixel table
dip int * dimension pointer to a dimensionality variable

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetRuns, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
DIPlib function reference 547

PixelTableGetDimensions
Get the dimemsions of a pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetDimensions ( table, dimensions, resources )

FUNCTION

This functions gets the dimensions of the bounding box of the binary object that is encoded
by the pixel table table.

ARGUMENTS

Data type Name Description


dip PixelTable * table Pixel table
dip IntegerArray * dimensions Pointer to a dimensions array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetRuns, PixelTableGetDimensionality, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
548 Chapter 2. Function reference

PixelTableGetOffsetAndLength
Converts the pixel table’s runs

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetOffsetAndLength ( table, stride, offset, length,
resources )

FUNCTION

This functions converts the linked-list of runs in the pixel table table to two arrays of
offsets and lengths. The length of these arrays equals the number of runs. The offsets are
calculated by multiplying each coordinate of a run with the stride of that dimension. This
function is useful when an image needs to be filtered with a filter that is encoded by a pixel
table. Before processing the image. See also PixelTableFrameWork.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip IntegerArray stride Stride array
dip IntegerArray * offset Pointer to offset array
dip IntegerArray * length Pointer to length array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableGetOffsetAndLength, PixelTableCreateFilter,
PixelTableFrameWork
DIPlib function reference 549

PixelTableGetOrigin
Get the origin of the pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetOrigin ( table, origin, resources )

FUNCTION

This function gets the origin of the pixel table table. All coordinates of the pixel table
runs are defined relative to this origin.

ARGUMENTS

Data type Name Description


dip PixelTable * table Pixel table
dip IntegerArray * origin Pointer to a origin array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetRuns, PixelTableGetDimensionality, PixelTableGetDimensions,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
550 Chapter 2. Function reference

PixelTableGetPixelCount
Get the number of pixels encoded in the pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetPixelCount ( table, count )

FUNCTION

Gets the total number of pixels of the binary object that is encoded by the Pixel table
table.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip int * count pointer to count

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetRuns, PixelTableGetDimensionality, PixelTableGetDimensions,
PixelTableGetOrigin, PixelTableGetSize, PixelTableGetOffsetAndLength
DIPlib function reference 551

PixelTableGetRun
Get the contents of a pixel table run

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetRun ( table, run, coordinate, length )

FUNCTION

This functions get the the coordinate and length parameters of the runth run of the pixel
table table.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip int run The run to be initialised
dip IntegerArray coordinate Coordinate of the run
dip int * length Length of the run

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableAddRun, PixelTableGetRuns,
PixelTableGetDimensionality, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
552 Chapter 2. Function reference

PixelTableGetRuns
Get the number of runs in a pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetRuns ( table, numberOfRuns )

FUNCTION

Gets the number of runs in a pixel table.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip int * numberOfRuns Point to the NumberOfRuns

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetDimensionality, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
DIPlib function reference 553

PixelTableGetSize
The number of pixels in the pixel table’s bounding box

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableGetSize ( table, size )

FUNCTION

Gets the number of pixels in the bounding box of the pixel table table.

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip int * size pointer to size

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableSetRun, PixelTableGetRun, PixelTableAddRun,
PixelTableGetRuns, PixelTableGetDimensionality, PixelTableGetDimensions,
PixelTableGetOrigin, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
554 Chapter 2. Function reference

PixelTableNew
Allocate a new pixel table

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableNew ( table, size, runs, resources)

FUNCTION

Allocates a new pixel table table. The size array specifies the dimensionality of the
coordinates in each run, and the sizes of the bounding box of the pixel table. The runs
parameter specifies the number of runs in the pixel table.

ARGUMENTS

Data type Name Description


dip PixelTable * table Pixel table
dip IntegerArray size Size
dip int runs Number of pixel table runs
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableSetRun, PixelTableGetRun, PixelTableAddRun, PixelTableGetRuns,
PixelTableGetDimensionality, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
DIPlib function reference 555

PixelTableSetRun
Initialises a pixel table run

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableSetRun ( table, run, coordinate, length )

FUNCTION

This function initialises the runth run of the pixel table table, by setting the run’s
coordinate to coordinate and its length to length. The pixel table must at least consist of
run number of runs ans has to be allocated (using PixelTableNew).

ARGUMENTS

Data type Name Description


dip PixelTable table Pixel table
dip int run The run to be initialised
dip IntegerArray coordinate Coordinate of the run
dip int length Length of the run

SEE ALSO

Description of DIPlib’s pixel tables


PixelTableNew, PixelTableGetRun, PixelTableAddRun, PixelTableGetRuns,
PixelTableGetDimensionality, PixelTableGetDimensions, PixelTableGetOrigin,
PixelTableGetSize, PixelTableGetPixelCount, PixelTableGetOffsetAndLength
556 Chapter 2. Function reference

PixelTableToBinaryImage
Convert a pixel table to a binary image

SYNOPSIS

#include "dip pixel table.h"


dip Error dip PixelTableToBinaryImage ( table, im)

DATA TYPES

binary

FUNCTION

Converts the pixel table table to a binary image. The size of the image is set to the size of
the bounding box of the pixel table.

ARGUMENTS

Data type Name Description


dip PixelTable * table Pixel table
dip Image im Binary image

SEE ALSO

Description of DIPlib’s pixel tables


BinaryImageToPixelTable, PixelTableCreateFilter
DIPlib function reference 557

PoissonNoise
Generate an image disturbed by Poisson noise

SYNOPSIS

#include "dip noise.h"


dip Error dip PoissonNoise ( in, out, conversion, random )

DATA TYPES

integer, float

FUNCTION

Generate a Poisson noise disturbed image. The intensities of the input image divided by the
conversion variable are used as mean value for the Poisson distribution. The conversion
factor can be used to relate the pixel values with the number of counts. For example, the
simulate a photon limited image acquired by a CCD camera, the conversion factor specifies
the relation between the number of photons recorded and the pixel value it is represented by.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float conversion Conversion factor (photon/ADU)
dip Random * random random

EXAMPLE

Get a Poisson disturbed image as follows:

dip_Image in, out;


dip_float conversion;
dip_Random random;

conversion = 2.0;
DIPXX( dip_PoissonNoise(in, out, conversion, &random ));
558 Chapter 2. Function reference

SEE ALSO

RandomVariable, RandomSeed, UniformNoise, GaussianNoise, BinaryNoise


DIPlib function reference 559

PoissonRandomVariable
Poisson random variable generator

SYNOPSIS

#include "dip noise.h"


dip Error dip PoissonRandomVariable ( random, input, output )

FUNCTION

dip PoissonRandomVariable uses the algorithm as described in “Numerical Recipes in C,


2nd edition”, section 7.3. The define DIP NOISE POISSON APPROXIMATE (default 30) in
dip noise.h determines the minimum value of the mean for which the rejection method is
used. Setting this value higher will result in variables whose distribution is a slightly better
approximation of the true Poisson distribution, but at the expense of a significantly higher
computational effort.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip float input Input value
dip float * output Poisson distributed output value

EXAMPLE

Get a Poisson random variable as follows:

dip_Random random;
dip_float mean, value;

mean = 23.0;
DIPXX( dip_PoissonRandomVariable( &random, mean, &value));

LITERATURE

Press, W.H., Teukolsky, S.A., Vetterling, W.T., and Flannery, B.P. Numerical Recipes in C,
2nd edition, Cambridge University Press, Cambridge, 1992.
560 Chapter 2. Function reference

SEE ALSO

RandomVariable, RandomSeed, UniformRandomVariable, GaussianRandomVariable,


BinaryRandomVariable
DIPlib function reference 561

ProbabilisticPairCorrelation
Compute the probabilistic pair correlation function

SYNOPSIS

#include "dip analysis.h"


dip Error dip ProbabilisticPairCorrelation ( object, mask, dist, probes,
length, sampling, covariance )

DATA TYPES

float

FUNCTION

This function computes the probabilistic pair correlation function of the different phases in
object. Each image in the image array phases is treated as a separate phase. The function
assumes, but does not check, that the values in these images are with the [0 1] range.
Optionally a mask image can be provided so select which pixels in object should be used to
compute the pair correlation. The probes variable specifies how many random point pairs
should be drawn to compute the function. Length specifies the maximum correlation length.
The correlation function can be computed using a random of grid method, as specified by
sampling. Finally covariance determines whether only the correlations ( DIP FALSE) or
the covarianances (DIP TRUE) has to be computed.

ARGUMENTS

Data type Name Description


dip ImageArray phases Phase image array
dip Image mask Mask image
dip Distribution dist Ouput distribution
dip int probes Number of probes
dip int length Maximum chord length
dipf CorrelationEstimator sampling Samplings method
dip Boolean covariance Compute covariance

SEE ALSO

PairCorrelation, ChordLength
562 Chapter 2. Function reference

PseudoInverse
Image restoration filter

SYNOPSIS

#include "dip restoration.h"


dip Error dip PseudoInverse ( in, psf, out, threshold, flags )

FUNCTION

This function performs a basic, very noise sensitive image restoration operation by inverse
filtering the image with a clipped point spread function. Each frequency in the output for
which the response of the PSF is smaller than threshold is set to zero.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image psf Point spread function image
dip Image out Output image
dip float threshold Threshold value
dipf Restoration flags Restoration flags

LITERATURE

G.M.P. van Kempen, Image Restoration in FLuorescence Microscopy, Ph.D. Thesis, Delft
University of Technology, 1999

SEE ALSO

Wiener, TikhonovMiller
DIPlib function reference 563

PutLine
Put a line in an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip PutLine ( in, out, cor, dimension )

DATA TYPES

binary, integer, float, complex

FUNCTION

Put a line in an image. Put a line orthogonally in an image. The position of the line in the
image is specified by the coordinates at which its left most pixel (cor) is be placed and on
which dimension of the image, the dimension of the line maps (dimension). If in has a
different type than out, it will be converted to the type of out.

ARGUMENTS

Data type Name Description


dip Image in Input Line Image
dip Image out Output Image
dip IntegerArray cor Coordinate in the image of the left most pixel of the
line
dip int dimension Dimension of the image on which the line’s dimension
maps

SEE ALSO

GetSlice, PutSlice, GetLine


564 Chapter 2. Function reference

PutSlice
Put a slice in an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip PutSlice ( in, out, cor, dim1, dim2 )

DATA TYPES

binary, integer, float, complex

FUNCTION

Put a slice orthogonally in an image. The position of the slice in the image is specified by
the coordinates at which its upper left corner (cor) should be placed and on which
dimensions of the image, the dimensions of the slice map (dim1, dim2). If in has a different
type than out, it will be converted to the type of out.

ARGUMENTS

Data type Name Description


dip Image in 2D Input Image
dip Image out 3D Output Image
dip IntegerArray cor Coordinate in out where the upper left corner of in is
placed
dip int dim1 Dimension of in on which the slice’s first dimension maps
dip int dim2 Dimension of in on which the slice’s second
dimensionmaps

SEE ALSO

PutSlice, GetLine, PutLine


DIPlib function reference 565

QuickSort
Sort a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip QuickSort ( data, size, dataType )

FUNCTION

Sorts a block of data (of size size and data type dataType ) using the quick sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


QuickSortIndices, QuickSortIndices16, Sort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
566 Chapter 2. Function reference

QuickSortAnything
Sort data of any type

SYNOPSIS

#include "dip sort.h"


dip Error dip QuickSortAnything ( data, size, compareFunction, swapFunction,
tmpData )

FUNCTION

Sorts a block of data (of size size) using the quick sort algorithm. This routine requires the
user to write two functions in order to fully implement the sorting procedure. These are
SortCompareFunction and SortSwapFunction.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip SortCompareFunction compareFunction Function for comparing two data
points
dip SortSwapFunction swapFunction Function for swapping two data points,
or copying one to the other
void * tmpData Pointer to a variable of the same type
as the data, used as temporary space
by some of the algorithms

SEE ALSO

General information about sorting


SortAnything, SortCompareFunction, SortSwapFunction
DIPlib function reference 567

QuickSortIndices
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip QuickSortIndices ( data, indices, size, dataType )

FUNCTION

Sort a list of indices rather than the data itself using the quick sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint32 * indices Indices
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


QuickSort, QuickSortIndices16, Sort, ImageSort, SortIndices, SortIndices16,
ImageSortIndices
568 Chapter 2. Function reference

QuickSortIndices16
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip QuickSortIndices16 ( data, indices, size, dataType )

FUNCTION

Sorts a list of (16 bit) indices rather than the data itself using the quick sort algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint16 * indices Indices
dip int size Size
dip DataType dataType Data type. See DIPlib’s data types

SEE ALSO

General information about sorting


QuickSort, QuickSortIndices, Sort, ImageSort, SortIndices, SortIndices16,
ImageSortIndices
DIPlib function reference 569

RadialMaximum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip RadialMaximum ( in, out, ps, binSize, innerRadius )

DATA TYPES

binary, integer, float

FUNCTION

This function computes the radial projection of the maximum of the pixel intensities of in.
The radial projection is performed for the dimensions specified by ps. If the radial distance
of a pixel to the center of the image is r, than the maximum of the intensities of all pixels
with n * binSize <= r < (n + 1) * binSize is stored at position n in the radial
dimension of out. The radial dimension is the first dimension to be processed (as specified
by ps). If innerRadius is set to DIP TRUE, the maximum radius that is projected is equal
to the the smallest dimension of the to be projected dimensions. Otherwise, the maximum
radius is set equal to the diagonal length of the dimensions to be processed.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BooleanArray ps Dimensions to project
dip float binSize Size of radial bins
dip Boolean innerRadius Maximum radius

SEE ALSO

RadialSum, RadialMean, RadialMinimum, Sum, Mean, Maximum, Minimum


570 Chapter 2. Function reference

RadialMean
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip RadialMean ( in, out, ps, binSize, innerRadius )

DATA TYPES

binary, integer, float

FUNCTION

This function computes the radial projection of the mean of the pixel intensities of in.
The radial projection is performed for the dimensions specified by ps. If the radial distance
of a pixel to the center of the image is r, than the mean of the intensities of all pixels with n
* binSize <= r < (n + 1) * binSize is stored at position n in the radial dimension of
out. The radial dimension is the first dimension to be processed (as specified by ps). If
innerRadius is set to DIP TRUE, the maximum radius that is projected is equal to the the
smallest dimension of the to be projected dimensions. Otherwise, the maximum radius is set
equal to the diagonal length of the dimensions to be processed.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BooleanArray ps Dimensions to project
dip float binSize Size of radial bins
dip Boolean innerRadius Maximum radius

SEE ALSO

RadialSum, RadialMaximum, RadialMinimum, Sum, Mean, Maximum, Minimum


DIPlib function reference 571

RadialMinimum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip RadialMinimum ( in, out, ps, binSize, innerRadius )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes the radial projection of the sum of the pixel intensities of in.
The radial projection is performed for the dimensions specified by ps. If the radial distance
of a pixel to the center of the image is r, than the minimum of the intensities of all pixels
with n * binSize <= r < (n + 1) * binSize is stored at position n in the radial
dimension of out. The radial dimension is the first dimension to be processed (as specified
by ps). If innerRadius is set to DIP TRUE, the maximum radius that is projected is equal
to the the smallest dimension of the to be projected dimensions. Otherwise, the maximum
radius is set equal to the diagonal length of the dimensions to be processed.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BooleanArray ps Dimensions to project
dip float binSize Size of radial bins
dip Boolean innerRadius Maximum radius

SEE ALSO

RadialSum, RadialMean, RadialMaximum, Sum, Mean, Maximum, Minimum


572 Chapter 2. Function reference

RadialSum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip RadialSum ( in, out, ps, binSize, innerRadius )

DATA TYPES

binary, integer, float

FUNCTION

This function computes the radial projection of the sum of the pixel intensities of in.
The radial projection is performed for the dimensions specified by ps. If the radial distance
of a pixel to the center of the image is r, than the sum of the intensities of all pixels with n
* binSize <= r < (n + 1) * binSize is stored at position n in the radial dimension of
out. The radial dimension is the first dimension to be processed (as specified by ps). If
innerRadius is set to DIP TRUE, the maximum radius that is projected is equal to the the
smallest dimension of the to be projected dimensions. Otherwise, the maximum radius is set
equal to the diagonal length of the dimensions to be processed.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BooleanArray ps Dimensions to project
dip float binSize Size of radial bins
dip Boolean innerRadius Maximum radius

SEE ALSO

RadialMean, RadialMaximum, RadialMinimum, Sum, Mean, Maximum, Minimum


DIPlib function reference 573

RandomSeed
Random seed function

SYNOPSIS

#include "dip noise.h"


dip Error dip RandomSeed ( random, seedval )

FUNCTION

Initializes a dip Random structure with a given seed value.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip uint32 seedval Seed value

EXAMPLE

Initialize a dip Random structure as follows:

dip_Random random;
dip_uint32 seed;

seed = 123758;
DIPXX(dip_RandomSeed( &random, seed ));

SEE ALSO

RandomVariable, UniformRandomVariable, GaussianRandomVariable,


PoissonRandomVariable, BinaryRandomVariable
574 Chapter 2. Function reference

RandomVariable
Random number generator

SYNOPSIS

include "dip noise.h"


dip Error dip RandomVariable ( random, value )

FUNCTION

Generates a random number between zero and one.


This function is based on the Numerical Recipes’ RAN1 function. The dip Random
structure can be initialized with the function dip RandomSeed. If the supplied dip Random
structure is not initialized, dip RandomVariable will initialize the dip Random structure
with a seed equal to zero. To guarantee the (psuedo) randomness between variables
obtained with subsequent calls to dip RandomVariable (or to functions that use this
function to obtain a random variable), a pointer to the same dip Random structure has to
supplied when calling dip RandomVariable.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip float * value value

EXAMPLE

Obtain a random number as follows:

dip_Random random;
dip_float val;

DIPXX(dip_RandomVariable( &random, &val));

SEE ALSO

RandomSeed, UniformRandomVariable, GaussianRandomVariable,


PoissonRandomVariable, BinaryRandomVariable
DIPlib function reference 575

RangeThreshold
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip RangeThreshold ( in, out, lowerBound, upperBound, foreground,
background, binaryOutput )

DATA TYPES

integer, float

FUNCTION

out = ( lowerBound <= in <= upperBound ? foreground : background) If the boolean


binaryOutput is true, RangeThreshold will produce a binary image. Otherwise an image of
the same type as the input image is produced, with the pixels set to either foreground or
background.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float lowerBound Lower bound
dip float upperBound Upper bound
dip float foreground Foreground value
dip float background Background value
dip Boolean binaryOutput Convert output image to binary

SEE ALSO

Threshold, HysteresisThreshold, IsodataThreshold


576 Chapter 2. Function reference

Real
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Real ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the real part of the input image values, and outputs a float typed image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Modulus, Phase, Imaginary


DIPlib function reference 577

Reciprocal
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Reciprocal ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the reciprocal (1/x) of the input image values. If pixel values of in are zero, the
corresponding pixels in out is set to zero.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Div, DivFloat, DivComplex, Modulo


578 Chapter 2. Function reference

Register
Generic registry function

SYNOPSIS

#include "dip registry.h"


dip Error dip Register ( register )

FUNCTION

The Registry functions Register, Unregister, RegisterClass, RegistryList,


RegistryGet RegistryValid and RegistryArrayNew are the access functions for DIPlib’s
generic registry framework. These functions control the access to a registry containing
information of items that are registered at run-time. Each item belongs to a certain class
and is identified with an ID that is unique within the item’s class.
DIPlib’s Registry classes are registered at run-time as well (using RegisterClass) and
should be registered before and item of that class can registered.
Although the generic Registry functions can be used to register, and obtain the data of
registered items of a specific clas, it is more userfriendly to use class specific Registry
functions like MsrRegister and companions.
The dip Register function accepts one argument, a dip Registry structure, which
contains the ID and class of the to be registered data and registry, a pointer to
class-specific data. Note that this pointer, registry, is freed when the (global) registry
information is freed.
The following code gives an example of a class-specific register function:

dip_Error dip_MsrRegister
(
dip_MsrRegistry registry
)
{
DIP_FN_DECLARE("dip_MsrRegister");
dip_Registry globalRegistry;
void *data;
dip_MsrRegistry *reg;

switch( registry.type )
{
default:
DIPSJ( DIP_E_REGISTRY_INCOMPLETE_REGISTRY );
break;
DIPlib function reference 579

case DIP_MSR_FUNCTION_LINE_BASED:
DIPTS( ! ( registry.create &&
registry.measure.line &&
registry.value &&
registry.labels &&
registry.description ),
DIP_E_REGISTRY_INCOMPLETE_REGISTRY );
break;

case DIP_MSR_FUNCTION_IMAGE_BASED:
DIPTS( ! ( registry.create &&
registry.measure.image &&
registry.value &&
registry.labels &&
registry.description ),
DIP_E_REGISTRY_INCOMPLETE_REGISTRY );
break;

case DIP_MSR_FUNCTION_CHAINCODE_BASED:
DIPTS( ! ( registry.create &&
registry.measure.chaincode &&
registry.value &&
registry.labels &&
registry.description ),
DIP_E_REGISTRY_INCOMPLETE_REGISTRY );
break;
}
/* copy the Msr specific registry info */
DIPXJ( dip_MemoryNew( &data, sizeof( dip_MsrRegistry ), 0 ));
reg = data;
*reg = registry;

globalRegistry.id = registry.id;
globalRegistry.class = DIP_REGISTRY_CLASS_MEASUREMENT;
globalRegistry.registry = reg;

/* register this measurement registry data */


DIPXJ( dip_Register( globalRegistry ));

dip_error:
DIP_FN_EXIT;
}
580 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


dip Registry registry Generic registry structure

SEE ALSO

Unregister, RegisterClass, RegistryList, RegistryGet, RegistryValid,


RegistryArrayNew
DIPlib function reference 581

RegisterClass
Register a registry class

SYNOPSIS

#include "dip registry.h"


dip Error dip RegisterClass ( class )

FUNCTION

This function registers a Registry class. See Register for more information about DIPlib’s
Registry.

ARGUMENTS

Data type Name Description


dip int class Registry class ID

SEE ALSO

Register, Unregister, RegistryValid, RegistryList, RegistryGet, RegistryArrayNew


582 Chapter 2. Function reference

RegistryArrayNew
Allocate a registry array

SYNOPSIS

#include "dip registry.h"


dip Error dip RegistryArrayNew ( array, size, resources )

FUNCTION

This function allocates an array of dip Registry structures.

ARGUMENTS

Data type Name Description


dip RegistryArray * array Pointer to the allocated array
dip int size Array size
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Register, RegistryList, RegistryGet


DIPlib function reference 583

RegistryGet
Get a registry item

SYNOPSIS

#include "dip registry.h"


dip Error dip RegistryGet ( id, class, registry )

FUNCTION

This function obtains the Registry information of the ID of the Registry class class. See
Register for more information about DIPlib’s Registry.
The following code gives an example of a class-specific register list function:

dip_Error dip_MsrRegistryGet
(
dip_int id,
dip_MsrRegistry *registry
)
{
DIP_FN_DECLARE("dip_MsrRegistryGet");
dip_MsrRegistry *reg;
void *data;

DIPXJ( dip_RegistryGet ( id, DIP_REGISTRY_CLASS_MEASUREMENT, &data ));


reg = data;
*registry = *reg;

dip_error:
DIP_FN_EXIT;
}

ARGUMENTS

Data type Name Description


dip int id Registry ID
dip int class Registry class
dip void ** registry Pointer to registered data
584 Chapter 2. Function reference

SEE ALSO

Register, Unregister, RegisterClass, RegistryList, RegistryValid,


RegistryArrayNew
DIPlib function reference 585

RegistryList
Get an array of registry IDs

SYNOPSIS

#include "dip registry.h"


dip Error dip RegistryList ( id, class, resources )

FUNCTION

This function obtains an array of the registered IDs of the Registry class class. See
Register for more information about DIPlib’s Registry.
The following code gives an example of a class-specific register list function:

dip_Error dip_MsrRegistryList
(
dip_IntegerArray *measurement,
dip_Resources resources
)
{
DIP_FN_DECLARE("dip_MsrRegistryList");

DIPXJ( dip_RegistryList( measurement,


DIP_REGISTRY_CLASS_MEASUREMENT, resources ));

dip_error:
DIP_FN_EXIT;
}

ARGUMENTS

Data type Name Description


dip IntegerArray * id Pointer to an array of Registry IDs
dip int class Registry class
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

Register, Unregister, RegisterClass, RegistryGet, RegistryValid, RegistryArrayNew


586 Chapter 2. Function reference

RegistryValid
Validate an registry item

SYNOPSIS

#include "dip registry.h"


dip Error dip RegistryValid ( id, class, verdict )

FUNCTION

This function checks whether id has been registered in the Registry in the Registry class
class. If verdict is not zero, the validation information (DIP FALSE or DIP TRUE) is copied
to verdict. Otherwise an error is returned in case the validation fails.
See Register for more information about DIPlib’s Registry.

ARGUMENTS

Data type Name Description


dip int id Registry ID
dip int class Registry class
dip Boolean * verdict Pointer to a boolean containing the validation data

SEE ALSO

Register, Unregister, RegisterClass, RegistryList, RegistryGet, RegistryArrayNew


DIPlib function reference 587

Resampling
Interpolation function

SYNOPSIS

#include "dip interpolation.h"


dip Error dip Resampling ( in, out, zoom, shift, method )

DATA TYPES

binary, integer, float

FUNCTION

This function resmaples the input image in to out using various interpolation methods.
Both a (subpixel) shift and a zoom factor are supported. The size of the output image is
zoom times the size of in. If shift is zero, a shift of zero is assumed. If zoom is zero, a
zoom of 1.0 is assumed.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip FloatArray zoom Zoom factor
dip FloatArray shift Shift
dipf Interpolation method Interpolation method
The dipf Interpolation enumaration consists of the following constants:
Name Description
DIP INTERPOLATION DEFAULT Default interpolation method
DIP INTERPOLATION BSPLINE B-Spline interpolation
DIP INTERPOLATION FOURTH ORDER CUBIC Forth order cubic interpolation
DIP INTERPOLATION THIRD ORDER CUBIC Third order cubic interpolation
DIP INTERPOLATION LINEAR Linear interpolation
DIP INTERPOLATION ZERO ORDER HOLD Zero order hold interpolation

SEE ALSO

Subsampling
588 Chapter 2. Function reference

ResourcesFree
Free resources

SYNOPSIS

dip Error dip ResourcesFree( resources, flags )

FUNCTION

Free all resources registers in the resource tracking structure, as well as the resource tracking
structure itself. To prevent errors, the resource tracking structure is set to 0. Passing a null
pointer instead of a pointer to a dip Resources structure is allowed and silently ignored.

ARGUMENTS

Data type Name Description


dip Resources * resources The tracking structure which was used to register
the resources that must be freed. Note the double
pointer, allowing this routine to set your pointer to 0
dipf ResourcesFree flags When set to DIP RMRF DONT FREE,
dip ResourcesFree only frees the dip Resources
structure itself, not the resources associated with it

SEE ALSO

ResourcesNew, ResourcesMerge, ResourceSubscribe, ResourceUnsubscribe


DIPlib function reference 589

ResourcesMerge
Add one resource list to another

SYNOPSIS

dip Error dip ResourcesMerge( resources, mergee )

FUNCTION

Adds one resource list to another. This function is very useful when writing functions that
will support a dip Resources parameter. Typically you want to allocate a number of
resources and only add these to the user-supplied dip Resources when all these allocations
have been successful. This is where ResourcesMerge comes in. Allocate a local
dip Resources structure and register all resources with it. When no errors occured the
local dip Resources structure can be merged with the user-supplied dip Resources
structure. If an error did occur, simply free all local resources by calling ResourcesFree. In
addition it is the convention that functions supporting resource tracking also accept a zero
indicating that no tracking should be performed. When resources in dip ResourcesMerge
is 0, the mergee tracking structure is freed, but the resources it contains are not. In this
way you get support for the “resources = 0 means no tracking” convention for free.

ARGUMENTS

Data type Name Description


dip Resources resources The dip Resources structure with which the additional
resources much be merged
dip Resources * mergee A pointer to the dip Resources structure containing
the additional resources to be merged. After the merge,
mergee is set to 0.

SEE ALSO

ResourcesNew, ResourcesFree, ResourceSubscribe, ResourceUnsubscribe


590 Chapter 2. Function reference

ResourcesNew
Allocate a resource tracking structure

SYNOPSIS

dip Error dip ResourcesNew( resources, noItems )

FUNCTION

This function allocates a dip Resources structure. The resource structure can be used to
register various resources as they are allocated, provided that the allocating function allows
you to register the resource. All resources allocated in this manner can be freed with a
single call to ResourcesFree. Examples of functions supporting this registration scheme are
ImageNew and special versions of the memory allocation routines.
Some operations consist of an initialization and a cleanup stage. These stages are often
performed by separate routines to allow the user to execute his/her own operations in
between. In DIPlib there usually is no directly callable cleanup function. Instead the
initialization routine registers its cleanup routine with a dip Resources structure provided
by the user. The cleanup operation is invoked through ResourcesFree.
All functions that support the registration leave you the choice not to register the resource.
This is indicated by supplying a zero instead of a resource tracking structure, unless
documented otherwise. The noItems parameters can be used to give the routine a hint
about the number of resources you will register. The structure grows automagically
whenever more resources are registered than indicated by the hint parameter.

ARGUMENTS

Data type Name Description


dip Resources * resources This will be used to return a dip Resources structure
dip int noItems A hint about the number of resources you are planning
to allocate. This parameter must be >= 2 or 0 to
indicate you want the default value. By the way, don’t
worry too much about this parameter, because when
the structure turns out to be too small, it will
automatically be expanded

SEE ALSO

ResourcesFree, ResourcesMerge, ResourceSubscribe, ResourceUnsubscribe, MemoryNew


DIPlib function reference 591

ResourceSubscribe
Track a resource

SYNOPSIS

dip Error dip ResourceSubscribe( resource, freeResourceHandler, resources )

FUNCTION

Track a resource. The resource must be represented by a void *. A handler function to free
the resource must be given. This function will be called through dip ResourcesFree with the
resource as its only parameter. If dip ResourceSubscribe fails, the resource is not
registered. It is allowed to pass a zero instead of a dip Resources structure, in which case
dip ResourceSubscribe returns silently.

ARGUMENTS

Data type Name Description


void * resource The resource that must be
registered
dip ResourcesFreeHandler freeResourceHandler The handler function that will be
invoked by dip ResourcesFree
to free the resource
dip Resources resources dip Resources structure to
register the resource with

SEE ALSO

ResourcesNew, ResourcesFree, ResourcesMerge, ResourceUnsubscribe


592 Chapter 2. Function reference

ResourceUnsubscribe
Stop tracking a resource

SYNOPSIS

dip Error dip ResourceUnsubscribe( resource, resources )

FUNCTION

Stop tracking a resource. It will be removed from the dip Resources structure. The
resource itself will not be freed. If a zero is passed instead of a resource or the
dip Resources structure, dip ResourceUnsubscribe returns silently.

ARGUMENTS

Data type Name Description


void * resource The resource that should no longer be tracked
dip Resources resources dip Resources structure to remove the resource from

SEE ALSO

ResourcesNew, ResourcesFree, ResourcesMerge, ResourceSubscribe


DIPlib function reference 593

RootMeanSquareError
difference measure

SYNOPSIS

#include "dip math.h"


dip Error dip RootMeanSquareError ( in1, in2, mask, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the root mean square difference between each pixel value of in1 and in2.
Optionally the mask image can be used to exclude pixels from the calculation by setting the
value of these pixels in mask to zero.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image mask Mask
dip Image out Output

SEE ALSO

MeanError, MeanSquareError, MeanAbsoluteError, LnNormError, IDivergence


594 Chapter 2. Function reference

Rotation
Interpolation function

SYNOPSIS

#include "dip interpolation.h"


dip Error dip Rotation ( in, out, angle, method, bgval )

DATA TYPES

binary, integer, float

FUNCTION

This function rotates an 2-D image in over angle to out using three skews. The function
implements the rotation in the mathmetical sense, but note the Y-axis is positive
downwards! The rotation is over the centre of the image.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float angle (radians) Rotation angle
dipf Interpolation method Interpolation method
dip BackgroundValue bgval Background value
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The dip BackgroundValue enumaration consists of the following flags:
DIPlib function reference 595

Name Description
DIP BGV DEFAULT Default: fill with zeros
DIP BGV ZERO Fill with zeros
DIP BGV MAX VALUE Fill with maximum value for data type
DIP BGV MIN VALUE Fill with minimum value for data type

KNOWN BUGS

This function is only implemented for 2D images.

SEE ALSO

Skewing
596 Chapter 2. Function reference

Rotation3d
Interpolation function

SYNOPSIS

#include "dip interpolation.h"


dip Error dip Rotation3d ( in, out, alpha, beta, gamma, method, bgval )

DATA TYPES

binary, integer, float

FUNCTION

This function rotates an 3-D image in via the three Euler angles alpha, beta, gamma to out
using nine skews. The first rotation is about alpha around the initial 3-axis. The second
about beta around the intermediate 2-axis and the last about gamma around the final 3-axis.
The function implements the rotation in the mathmetical sense, but note the Y-axis is
positive downwards! The rotation is over the centre of the image.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float alpha (radians) Euler angle
dip float beta (radians) Euler angle
dip float gamma (radians) Euler angle
dipf Interpolation method Interpolation method
dip BackgroundValue bgval Background value
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
DIPlib function reference 597

The dip BackgroundValue enumaration consists of the following flags:


Name Description
DIP BGV DEFAULT Default: fill with zeros
DIP BGV ZERO Fill with zeros
DIP BGV MAX VALUE Fill with maximum value for data type
DIP BGV MIN VALUE Fill with minimum value for data type

KNOWN BUGS

This function is only implemented for 3D images.

SEE ALSO

Skewing, Rotation3dAxis
598 Chapter 2. Function reference

Rotation3d Axis
Interpolation function

SYNOPSIS

#include "dip interpolation.h"


dip Error dip Rotation3d Axis ( in, out, angle, axis, method, bgval )

DATA TYPES

binary, integer, float

FUNCTION

This function rotates an 3-D image in over angle around axis to out using three skews.
The rotation axis is 0 (x), 1 (y) or 2 (z). The function implements the rotation in the
mathmetical sense, but note the Y-axis is positive downwards! The rotation is over the
centre of the image.
For backwards compatability, the macro Rotation3dAxis calls the function
Rotation3d Axis but uses 1, 2 and 3 to select the axis of rotation.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float angle (radians) Rotation angle
dip int axis Rotation axis
dipf Interpolation method Interpolation method
dip BackgroundValue bgval Background value
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
DIPlib function reference 599

The dip BackgroundValue enumaration consists of the following flags:


Name Description
DIP BGV DEFAULT Default: fill with zeros
DIP BGV ZERO Fill with zeros
DIP BGV MAX VALUE Fill with maximum value for data type
DIP BGV MIN VALUE Fill with minimum value for data type

KNOWN BUGS

This function is only implemented for 3D images.

SEE ALSO

Skewing, Rotation3d
600 Chapter 2. Function reference

ScalarImageNew
Allocate a scalar image

SYNOPSIS

dip Error dip ScalarImageNew( newImage, dataType, dimensions, resources )

FUNCTION

Allocate and forge a dip Image structure of the DIP IMTP SCALAR type.

ARGUMENTS

Data type Name Description


dip Image * newImage Used to return a pointer to your brand new
dip Image structure
dip DataType dataType Data type. See DIPlib’s data types
dip IntegerArray dimensions Dimensions
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

ImageNew, ImageFree
DIPlib function reference 601

ScanFrameWork
FrameWork for scanning multiple images

SYNOPSIS

#include "dip framework.h"


dip Error dip ScanFrameWork ( in, out, process, boundary, border, inBuffer,
outBuffer, outImage )

FUNCTION

This function provides a framework for scanning nofin input images and nofout output
images in one dimension of the images. The dimension in which the image should be scan
can be specified or left to ScanFrameWork by specifiying the dimension with
DIP MONADIC OPTIMAL DIMENSION. See SeparableFrameWork for details.

ARGUMENTS

Data type Name Description


dip ImageArray in Array of input images
dip ImageArray out Array of output images
dip FrameWorkProcess process Process
dip BoundaryArray boundary Boundary conditions
dip BorderArray border Border Array
dip DataTypeArray inBuffer Array of dip DataType of the input buffer
dip DataTypeArray outBuffer Array of dip DataType of each output buffer
dip DataTypeArray outImage Array of dip DataType of each output image

SEE ALSO

DIPlib’s data types SeparableFrameWork, PixelTableFrameWork


602 Chapter 2. Function reference

SeededWatershed
Morphological segmentation

SYNOPSIS

#include "dip morphology.h"


dip Error dip SeededWatershed ( seeds, in, mask, out, connectivity, order,
max depth, max size, binaryOutput )

DATA TYPES

integer, float

FUNCTION

Watershed segmentation with built-in region merging. max depth and max size control the
merging procedure. Any region with max size or less pixels and with max depth grey-value
difference or less will be merged to neighbouring regions when they touch (as opposed to
build a watershed). max size equal to 0 means that the size of the region is not tested when
merging. To avoid merging of seeds with no grey-value difference between them, set
max size to a negative value. The regions are grown according to the connectivity
parameter. See The connectivity parameter for more information. The output is either a
labelled image where the pixels belonging to a catchment basin are labelled, or a binary
image where the watershed pixels are 1 and the rest is 0. This is controlled by
binaryOutput.
As opposed to Watershed, this function takes a seeds input image, and grows the
catchment basins from there. The output image, when binaryOutput is DIP TRUE, will have
label values as given by the seed image.
If mask is not 0, only the pixels within mask will be considered. All the other pixels will be
untouched.
DIPlib function reference 603

ARGUMENTS

Data type Name Description


dip Image seeds Binary or labelled input image
dip Image in Grey-value input image
dip Image mask Mask image
dip Image out Output
dip int connectivity Connectivity
dipf GreyValueSortOrder order Whether to grow from low to high or high
to low
dip float max depth Maximum depth of a region that can be
merged
dip int max size Maximum size of a region that can be
merged
dip Boolean binaryOutput DIP FALSE if the output should be a
labelled image
The dipf GreyValueSortOrder enumeration consists of the following values:
Name Description
DIP GVSO HIGH FIRST Process the pixels from high grey-value to low grey-value.
DIP GVSO LOW FIRST Process the pixels from low grey-value to high grey-value.

SEE ALSO

Watershed, LocalMinima, Minima, Maxima, GrowRegions


604 Chapter 2. Function reference

Select
Configurable selection function

SYNOPSIS

#include "dip math.h"


dip Error dip Select ( in1, in2, in3, in4, out, selector )

DATA TYPES

binary, integer, float

FUNCTION

This function can perform various pixel-by-pixel comparisons (smaller, smaller- equal, equal,
not equal, greater-equal, greater) between in1 ans in2. If the result of the comparison is
true, the corresponding pixel value of in3 is copied to out, otherwise it is copied from in4.
In short the following operation is performed for each pixel in the five images:

out = in1 selector in2 ? in3 : in4

The images in2, in3 and in4 can be 0-D images acting as constants.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image in3 Third input
dip Image in4 Fourth input
dip Image out Output
dipf Select selector Select flag
Name Description
DIP SELECT LESSER <, Lesser than
DIP SELECT LESSER EQUAL <=, Lesser or equal
DIP SELECT NOT EQUAL !=, Unequal
DIP SELECT EQUAL ==, Equal
DIP SELECT GREATER EQUAL >=, Greater or equal
DIP SELECT GREATER >, Greater
DIPlib function reference 605

SEE ALSO

Compare, Max, Min


606 Chapter 2. Function reference

SelectValue
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip SelectValue ( in, out, value )

DATA TYPES

integer, float

FUNCTION

This function returns a binary image with value 1 where in == value and value 0 elsewhere.

ARGUMENTS

Data type Name Description


dip Image in out
Output image dip float

SEE ALSO

Threshold, NotZero, Compare, RangeThreshold


DIPlib function reference 607

SeparableConvolution
FrameWork for separable convolution filters

SYNOPSIS

#include "dip linear.h"


dip Error dip SeparableConvolution ( in, out, filters, bc, process )

DATA TYPES

integer, float

FUNCTION

This function is a frontend to the lower level Convolve1d function. Each dimension can be
processed by a different filter.
process may be zero, indicating that all dimensions should be processed.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip SeparableConvolutionFilter * filters Filters
dip BoundaryArray bc Boundary conditions
dip BooleanArray process (0) Dimensions to process

SEE ALSO

General information about convolution


SeparableFrameWork, Convolve1d
608 Chapter 2. Function reference

SeparableFrameWork
FrameWork for separable filters

SYNOPSIS

#include "dip framework.h"


dip Error dip SeparableFrameWork (in, out, boundary, border, process )

FUNCTION

The dip SeparableFrameWork function is a framework for separable filters. This function
takes care of all the “administrative work” involved when processing a n-D dimensional
DIPlib Image n times with a 1-D filter. In short, using this function, one has only to create
an one dimension filter function and dip SeparableFrameWork takes care of the other stuff.
The in DIPlib Image is filtered nrOfProcesses times using the information in each element
of the process array. If nrOfProcesses is zero, only the first element of process is used to
filter in in all its dimensions.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip BoundaryArray boundary Boundary conditions
dip IntegerArray border Border array
dip FrameWorkProcessArray process Array of dip FrameWorkProcess structures

NOTE

The dip FrameWorkProcess structure contains the following members:


DIPlib function reference 609

Data type Name Description


dip Boolean process flags specifying to do processing
or not
dipf FrameWorkMethod frameWorkMethod flags specifying the method of how
dip SeparableFrameWork should
transport data from in to out
dipf FrameWorkOperation frameWorkOperation flags specifying requirements of
the 1-D filter function
dip int processDimension dimension of in to be processed
dip int roiOrigin ignored in current implementation
dip int roiSize ignored in current implementation
dipf FrameWorkFilter FrameWorkFilterType specifying the type of 1-D filter
function
dip FrameWorkFilter FrameWorkFilter pointer to the 1-D filter function
void * functionParameters parameters of the 1-D filter
function, for all dimensions
dip DataType inputBufferType data type of input buffer
dip DataType outputBufferType data type of output buffer
dip DataType suggestedOutputType data type of output image
The dipf FrameWorkMethod enum contains the following elements:
Name Description
DIP FRAMEWORK DEFAULT METHOD use dip SeparableFrameWorks most optimal method
DIP FRAMEWORK CLASSICAL use a classical method
DIP FRAMEWORK DOUBLE STRIPE use two buffers to store temporary results
It is strongly advised to use the DIP FRAEMWORK DEFAULT METHOD method.
The dipf FrameWorkOperation enum contains the following elements:
Name Description
DIP FRAMEWORK DEFAULT OPERATION default operation
DIP FRAMEWORK IN PLACE filtering operation can be performed in-place. It is
up to dip SeparableFrameWork whether the
actual filtering is done in-place
DIP FRAMEWORK NO IN BORDER the 1-D filter does not need border extension of
the input data
DIP FRAMEWORK OUT BORDER the 1-D filter needs border extension of the output
data
DIP FRAMEWORK WRITE INPUT the 1-D filter needs to write in the input data
DIP FRAMEWORK USE BUFFER TYPES made the input and output buffers of the
inputBufferType and outputBufferType data
type
DIP FRAMEWORK NO BUFFER STRIDE Create input and outpub buffers with a stride of
one
DIP FRAMEWORK DO NOT ADJUST Do not adjust the output image, just check it
DIP FRAMEWORK USE OUTPUT TYPE Adjust output image to the suggestedOutputType
data type
610 Chapter 2. Function reference

The dipf FrameWorkFilter enum contains the following elements:


Name Description
DIP FRAMEWORK SEPARABLE FILTER default filter type, process one line at
the time
DIP FRAMEWORK TWO LINES SEPARABLE FILTER process two lines in one go
DIP FRAMEWORK SINGLE OUTPUT FILTER this filter only needs an output buffer
The union dip FrameWorkFunction consists of the types
Name Description
dip SeparableFilter one line filter function
dip TwoLinesSeparableFilter two lines filter function
dip SingleOutputFilter single output image filter
The functions have the following arguments: dip SeparableFilter
Data type Name Description
void * inData pointer to the input data
void * outData pointer to the output data
dip int elements number of pixels in the inData array
dip SeparableFilterParameters params parameter structure for the filter
function
and dip SeparableTwoLinesFilter
Data type Name Description
void * inFirstLineData pointer to the data
of the first input
line
void * inSecondLineData pointer to the data
of the second input
line
void * outFirstLineData pointer to the data
of the first output
line
void * outSecondLineData pointer to the data
of the second
output line
dip int elements number of pixels in
the
inFirstLineData
array
dip TwoLinesSeparableFilterParameters params parameter structure
for the two lines
filter function
The inData, inFirstLineData and inSecondLineData will always point to the first pixel of
the line of in that is processed. Therefore, the 1-D filter can access pixels with indices
ranging from -border[dimension] up to elements + border[dimension]. If the flag
DIP FRAMEWORK OUT BOUNDARY is specified, the same holds for the output data pointers.
DIPlib function reference 611

The structure dip SeparableFilterParameters contains the following elements:


Data type Name Description
void * functionParameters parameters of the 1-D filter function per
dimension
dip int dimension the dimension in which direction the input
buffer is taken from the input image
dip int processNumber number of times dip SeparableFrameWork
has already filtered in with an 1-D filter
including current filtering
dip DataType inType dip DataType of the input buffer
dip int inStride stride of the elements in the input array
dip int inPlane plane number in case in is a binary image
dip DataType outType dip DataType of the output buffer
dip int outStride stride of the elements in the output array
dip int outPlane plane number in case out is a binary image
dip int outDimension the dimension in which direction the output
buffer is taken from the output image
dip IntegerArray position coordinate of the first pixel of the input
buffer in the input image
The structure dip TwoLinesSeparableFilterParameters contains the following elements:
Data type Name Description
void * functionParameters parameters of the 1-D filter function per
dimension
dip int dimension the dimension in which direction the input
buffer is taken from the input image
dip int processNumber number of times dip SeparableFrameWork
has already filtered in with an 1-D filter
including current filtering
dip DataType inType dip DataType of the input buffer
dip int inStride stride of the elements in the input array
dip int inPlane plane number in case in is a binary image
dip DataType outType dip DataType of the output buffer
dip int outStride stride of the elements in the output array
dip int outPlane plane number in case out is a binary image
dip int outDimension the dimension in which direction the output
buffer is taken from the output image
dip IntegerArray position coordinate of the first pixel of the input
buffer in the input image
The structure dip SingleOutputFilterParameters contains the following elements:
612 Chapter 2. Function reference

Data type Name Description


void * functionParameters parameters of the 1-D filter function per
dimension
dip int dimension the dimension in which direction the input
buffer is taken from the input image
dip int processNumber number of times dip SeparableFrameWork
has already filtered in with an 1-D filter
including current filtering
dip DataType type dip DataType of the input buffer
dip int stride stride of the elements in the input array
dip int plane plane number in case in is a binary image
dip IntegerArray position coordinate of the first pixel of the input
buffer in the input image

SEE ALSO

DIPlib’s data types SeparableConvolution, MonadicFrameWork, SingleOutputFrameWork,


PixelTableFrameWork, ScanFrameWork
DIPlib function reference 613

Set
the value of a pixel

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Set ( out, const, cor, adjust )

FUNCTION

This function set a value of a pixel at position cor in the image out to the value const.

ARGUMENTS

Data type Name Description


dip Image out Output image
dip Image constImage 0-D image
dip IntegerArray cor Pixel coordinate
dip Boolean adjust Adjust data type of output image

SEE ALSO

SetInteger, SetFloat, SetComplex, dip PixelSetInteger, dip PixelSetFloat, Get


614 Chapter 2. Function reference

SetComplex
Set a pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip SetComplex ( out, constant, cor, adjust )

FUNCTION

This function set a value of a pixel at position cor in the image out to the value constant.

ARGUMENTS

Data type Name Description


dip Image out Output
dip complex constant Constant
dip IntegerArray cor Pixel coordinate
dip Boolean adjust Adjust data type of output image

SEE ALSO

Set, SetInteger, SetFloat, dip PixelSetInteger, dip PixelSetFloat, Get


DIPlib function reference 615

SetFloat
Set a pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip SetFloat ( out, constant, cor, adjust )

FUNCTION

This function set a value of a pixel at position cor in the image out to the value constant.

ARGUMENTS

Data type Name Description


dip Image out Output
dip float constant Constant
dip IntegerArray cor Pixel coordinate
dip Boolean adjust Adjust data type of output image

SEE ALSO

Set, SetInteger, SetComplex, dip PixelSetInteger, dip PixelSetFloat, Get


616 Chapter 2. Function reference

SetInteger
Set a pixel value

SYNOPSIS

#include "dip manipulation.h"


dip Error dip SetInteger ( out, constant, cor, adjust )

FUNCTION

This function set a value of a pixel at position cor in the image out to the value constant.

ARGUMENTS

Data type Name Description


dip Image out Output
dip int constant Constant
dip IntegerArray cor Pixel coordinate
dip Boolean adjust Adjust data type of output image

SEE ALSO

Set, SetFloat, SetComplex, dip PixelSetInteger, dip PixelSetFloat, Get


DIPlib function reference 617

Sharpen
Enhance an image

SYNOPSIS

#include "dip derivatives.h"


dip Error dip Sharpen ( in, out, weight, bc, ps, sigmas, tc, flavour )

DATA TYPES

See Laplace

FUNCTION

This function enhances the high frequencies (“sharpens”) of the input image in by
subtracting a Laplace filtered version of in from it. The weight parameter determines by
which amount the laplace information is subtracted from the original: output = input -
weight * laplace( input ) The sigmas are the Gaussian smoothing parameters of the
Laplace operation, and determine how strongly the high-frequency noise in in is suppressed.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float weight Laplacian weight
dip BoundaryArray boundary Boundary conditions
dip BooleanArray process (0) Dimensions to process
dip FloatArray sigmas Sigma of Gaussian
dip float truncation (<0) Truncation of Gaussian
dip DerivativeFlavour flavour Derivative Flavour

SEE ALSO

Laplace
618 Chapter 2. Function reference

Shift
an image manipulation function

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Shift ( in, out, shift, killNy )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function shifts an image in the Fourier Domain. All frequiencies larger than the
Nyquist frequency are set to zero if killNy is true. It performs:

out = Real(InverseFourierTransform(GeneratePhase(shift) * FourierTransform( in ))

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip FloatArray shift Shift array
dip Boolean killNy set frequencies > Nyquist to zero?

SEE ALSO

Crop, Wrap, FourierTransform, Real


DIPlib function reference 619

Sigma
Adaptive uniform smoothing filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip Sigma ( in, out, se, boundary, filterSize, shape, sigma,
outputCount )

DATA TYPES

integer, float

FUNCTION

The Sigma filter is an adaptive Uniform smoothing filter. The value of the pixel
underinvestigation is replaced by the average of the pixelvalues in the filter region (as
specified by filterSize, shape and se) which lie in the interval +/- 2 sigma from the
value of the pixel that is filtered. If outputCount is DIP TRUE, the output values represent
the number of pixel over which the average has been calculated. When threshold is
DIP TRUE, the pixel intensities are being thresholded at +/- 2 sigma, when it is set to
DIP FALSE, the intensities are weighted with the Gaussian difference with the intensity of
the central pixel.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterSize Filter sizes
dip FilterShape shape Filter shape
dip float sigma Sigma
dip Boolean outputCount Output the Count
The enumerator dip FilterShape contains the following constants:
620 Chapter 2. Function reference

Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

LITERATURE

John-Sen Lee, Digital Image Smoothing and the Sigma Filter, Computer Vision, Graphics
and Image Processing, 24, 255-269, 1983

SEE ALSO

BiasedSigma, GaussianSigma, Uniform


DIPlib function reference 621

Sign
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Sign ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the sign of the input image values, and outputs a signed integer typed image.
The sign of zero is defined as zero.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Ceil, Floor, Truncate, Fraction, NearestInt


622 Chapter 2. Function reference

SimulatedAttenuation
Simulation of the attenuation process

SYNOPSIS

#include "dip microscopy.h"


dip Error dip SimulatedAttenuation ( in, out, fAttenuation, bAttenuation, NA,
refIndex, zxratio, oversample, rayStep )

DATA TYPES

binary, integer, float

FUNCTION

This function simulates an attenuation based on the model of a CSLM, using a ray tracing
method.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float fAttenuation Forward attenuation factor
dip float bAttenuation Backward attenuation factor
dip float NA Numerical aperture
dip float refIndex Refractive index
dip float zxratio Z/X sampling ratio
dip int oversample Ray casting oversampling
dip float rayStep Ray step

LITERATURE

K.C. Strasters, H.T.M. van der Voort, J.M. Geusebroek, and A.W.M. Smeulders, Fast
attenuation correction in fluorescence confocal imaging: a recursive approach, BioImaging,
vol. 2, no. 2, 1994, 78-92.
DIPlib function reference 623

AUTHOR

Karel Strasters, adapted to DIPlib by Geert van Kempen.

SEE ALSO

AttenuationCorrection, ExponentialFitCorrection
624 Chapter 2. Function reference

Sin
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Sin ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the sine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh


DIPlib function reference 625

Sinc
mathematical function

SYNOPSIS

#include "dip math.h"


dip Error dip Sinc ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the sinc (sin(x)/x) of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

BesselJ0, BesselJ1, BesselJN, BesselY0, BesselY1, BesselYN, LnGamma, Erf, Erfc


626 Chapter 2. Function reference

SingleOutputFrameWork
FrameWork for generation functions

SYNOPSIS

#include "dip framework.h"


dip Error dip SingleOutputFrameWork ( out, processBoundary, processBorder,
process )

FUNCTION

This function is a frontend on the SeparableFrameWork. It provides an easier interface for


filters that only need to scan an single output image. The dimension in which the image
should be scan can be specified or left to SingleOutputFrameWork by specifiying the
dimension with DIP MONADIC OPTIMAL DIMENSION.

ARGUMENTS

Data type Name Description


dip Image out Output
dip Boundary processBoundary ProcessBoundary
dip int processBorder ProcessBorder
dip FrameWorkProcess process Process

SEE ALSO

SeparableFrameWork, MonadicFrameWork, PixelTableFrameWork, ScanFrameWork


DIPlib function reference 627

SingularValueDecomposition
Singular value decomposition

SYNOPSIS

#include "dip svd.h"


dip Error dip SingularValueDecomposition ( in, sz, u, s, d )

DATA TYPES

float, dfloat

FUNCTION

Computes the SVD of the ImageArray in, such that in = u * s * transpose(t), with s being
diagonal. The size of the in matrix is passed to the function via the IntegerArray sz. If the
input is of size m x n, then the outputs must be u: n x m, s: n x n; d: n x n.

ARGUMENTS

Data type Name Description


dip ImageArray in Input
dip IntegerArray sz Matrix size of Input
dip ImageArray u Output
dip ImageArray s Output
dip ImageArray d Output
628 Chapter 2. Function reference

Sinh
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Sinh ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the hyperbolic sine of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Cosh, Tanh


DIPlib function reference 629

Skewing
Interpolation function

SYNOPSIS

#include "dip math.h" #include "dip interpolation.h"


dip Error dip Skewing ( in, out, shear, skew, axis, method, bgval,
periodicSkew )

DATA TYPES

binary, integer, float

FUNCTION

This function skews the axis axis of in over an angle angle to out using the interpolation
method method. The skew is over the centre of the image. If periodicSkew is set to
DIP TRUE, the output image will be of the same size as the input image, and its pixels in the
skew dimension wrapped around the image boundaries. bgval is not used in this case.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float shear (radians) Shear angle
dip int skew Skew dimension
dip int axis Skew axis
dipf Interpolation method Interpolation method
dip BackgroundValue bgval Background value
dip Boolean periodicSkew Skew using periodic image boundaries
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
630 Chapter 2. Function reference

The dip BackgroundValue enumaration consists of the following flags:


Name Description
DIP BGV DEFAULT Default: fill with zeros
DIP BGV ZERO Fill with zeros
DIP BGV MAX VALUE Fill with maximum value for data type
DIP BGV MIN VALUE Fill with minimum value for data type

SEE ALSO

Rotation, Rotation3d, Rotation3dAxis


DIPlib function reference 631

SmallObjectsRemove
Remove small objects from an image

SYNOPSIS

#include "dip measurement.h" #include "dip point.h"


dip Error dip SmallObjectsRemove ( in, out, threshold )

DATA TYPES

integer

FUNCTION

This function removes from the labeled image in those objects whose size (measured in the
number of pixels) is smaller than threshold.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip int threshold Minimum object size

SEE ALSO

Measure, ObjectToMeasurement, Label


632 Chapter 2. Function reference

SobelGradient
A linear gradient filter

SYNOPSIS

#include "dip linear.h"


dip Error dip SobelGradient ( in, out, boundary, processDim )

DATA TYPES

binary, integer, float, complex

FUNCTION

The SobelGradient filter computes a finite difference gradient (1 0 -1)/2 in the processDim,
and performs a local (1 2 1)/4 smoothing in the other dimensions. Note that in 2D, this
differs by a multiplication factor of 1/8 to the original definition by Sobel.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip BoundaryArray boundary Boundary conditions
dip int processDim ProcessDim

SEE ALSO

General information about convolution


FiniteDifference, Uniform, Gauss, SeparableConvolution, Convolve1d, Derivative
DIPlib function reference 633

Sort
Sort a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip Sort ( data, size, algorithm, dataType )

FUNCTION

Sorts a block of data (of size size and data type dataType ) using the algorithm specified
by algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip Sort algorithm Sort algorithm
dip DataType dataType Data type. See DIPlib’s data types
The sortType parameter is one of:
Name Description
DIP SORT DEFAULT Default sort algorithm
DIP SORT QUICK SORT Quick sort
DIP SORT DISTRIBUTION SORT Distribution sort
DIP SORT INSERTION SORT Insertion sort

SEE ALSO

General information about sorting


DistributionSort, InsertionSort, QuickSort, ImageSort, SortIndices,
SortIndices16, ImageSortIndices
634 Chapter 2. Function reference

SortAnything
Sort data of any type

SYNOPSIS

#include "dip sort.h"


dip Error dip SortAnything ( data, size, compareFunction, swapFunction,
tmpData, algorithm )

FUNCTION

Sorts a block of data (of size size) using the algorithm specified by algorithm. This
routine requires the user to write two functions in order to fully implement the sorting
procedure. These are SortCompareFunction and SortSwapFunction.

ARGUMENTS

Data type Name Description


void * data Data
dip int size Size
dip SortCompareFunction compareFunction Function for comparing two data
points
dip SortSwapFunction swapFunction Function for swapping two data points,
or copying one to the other
void * tmpData Pointer to a variable of the same type
as the data, used as temporary space
by some of the algorithms
dip Sort algorithm Sort algorithm

SEE ALSO

General information about sorting


QuickSortAnything, SortCompareFunction, SortSwapFunction
DIPlib function reference 635

SortCompareFunction
Typedef for comparison function (sorting)

SYNOPSIS

#include "dip sort.h"


dip Boolean (*dip SortCompareFunction) ( data1, index1, data2, index2 )

FUNCTION

A function of this type must be supplied to the sorting algorithms for data of arbitrary
type. It should return DIP TRUE if data1[index1] > data2[index2].
Example:

dip_Boolean MyComplexCompare( void *data1, dip_int index1, void *data2, dip_int index2 )
{
dip_complex *cmplx1, *cmplx2;
dip_float magnitude1, magnitude2;

cmplx1 = data1;
cmplx2 = data2;
cmplx1 += index1;
cmplx2 += index2;
magnitude1 = sqrt( cmplx1->re * cmplx1->re + cmplx1->im * cmplx1->im );
magnitude2 = sqrt( cmplx2->re * cmplx2->re + cmplx2->im * cmplx2->im );
if ( magnitude1 > magnitude2 )
{
return( DIP_TRUE );
}
else
{
return( DIP_FALSE );
}
}
636 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


void * data1 Pointer to first data array
dip int index1 Index to element in first data array
void * data2 Pointer to second data array
dip int index2 Index to element in second data array

SEE ALSO

General information about sorting


SortAnything, QuickSortAnything, SortSwapFunction
DIPlib function reference 637

SortIndices
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip SortIndices ( data, indices, size, algorithm, dataType,
indexType )

FUNCTION

Sorts a list of indices rather than the data itself using the algorithm specified by algorithm.

ARGUMENTS

Data type Name Description


void * data Data
void * indices Indices
dip int size Size
dip Sort algorithm Sort algorithm
dip DataType dataType Data type. See DIPlib’s data types
dip DataType indexType Data type of the index array. Must be either
DIP DT SINT32 or DIP DT SINT16.
The sortType parameter is one of:
Name Description
DIP SORT DEFAULT Default sort algorithm
DIP SORT QUICK SORT Quick sort
DIP SORT DISTRIBUTION SORT Distribution sort
DIP SORT INSERTION SORT Insertion sort

SEE ALSO

General information about sorting


DistributionSort, InsertionSort, QuickSort, Sort, ImageSort, SortIndices16,
ImageSortIndices
638 Chapter 2. Function reference

SortIndices16
Sort indices to a block of data

SYNOPSIS

#include "dip sort.h"


dip Error dip SortIndices16 ( data, indices, size, algorithm, dataType )

FUNCTION

Sorts a list of (16 bit) indices rather than the data itself using the algorithm specified by
algorithm.

ARGUMENTS

Data type Name Description


void * data Data
dip sint16 * indices Indices
dip int size Size
dip Sort algorithm Sort algorithm
dip DataType dataType Data type. See DIPlib’s data types
The sortType parameter is one of:
Name Description
DIP SORT DEFAULT Default sort algorithm
DIP SORT QUICK SORT Quick sort
DIP SORT DISTRIBUTION SORT Distribution sort
DIP SORT INSERTION SORT Insertion sort

SEE ALSO

General information about sorting


DistributionSort, InsertionSort, QuickSort, Sort, ImageSort, SortIndices,
ImageSortIndices
DIPlib function reference 639

SortSwapFunction
Typedef for swap and copy function (sorting)

SYNOPSIS

#include "dip sort.h"


void (*dip SortSwapFunction) ( data1, index1, data2, index2, copy )

FUNCTION

A function of this type must be supplied to the sorting algorithms for data of arbitrary
type. It should swap data1[index1] and data2[index2] if copy = DIP FALSE, and copy
data1[index1] to data2[index2] if copy = DIP TRUE.
Example:

void dip_MyComplexSwap( void *data1, dip_int index1, void *data2, dip_int index2, dip_Boolean
{
dip_complex *cmplx1, *cmplx2, tmpValue;

cmplx1 = data1;
cmplx2 = data2;
cmplx1 += index1;
cmplx2 += index2;
if ( copy == DIP_TRUE )
{
cmplx2->re = cmplx1->re;
cmplx2->im = cmplx1->im;
}
else
{
tmpValue.re = cmplx2->re;
tmpValue.im = cmplx2->im;
cmplx2->re = cmplx1->re;
cmplx2->im = cmplx1->im;
cmplx1->re = tmpValue.re;
cmplx1->im = tmpValue.im;
}
return;
}
640 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


void * data1 Pointer to first data array
dip int index1 Index to element in first data array
void * data2 Pointer to second data array
dip int index2 Index to element in second data array
dip Boolean copy if DIP FALSE, swap data. if DIP TRUE copy data from data1 to
data2

SEE ALSO

General information about sorting


SortAnything, QuickSortAnything, SortCompareFunction
DIPlib function reference 641

Sqrt
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Sqrt ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the square root of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Exp, Exp2, Exp10, Ln, Log2, Log10


642 Chapter 2. Function reference

StablePixelHeapFree
Destroy heap structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip StablePixelHeapFree ( heap )

FUNCTION

Frees all data associated to heap and sets heap to 0.

ARGUMENTS

Data type Name Description


dip StablePixelHeap * heap The heap structure

SEE ALSO

StablePixelHeapNew, PixelHeapNew, PixelQueueNew, StablePixelHeapPush,


StablePixelHeapPop, StablePixelHeapIsEmpty
DIPlib function reference 643

StablePixelHeapIsEmpty
Query heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip StablePixelHeapIsEmpty ( heap, result )

FUNCTION

Checks to see if there are any items on the heap. See StablePixelHeapNew for information
on the heap data structure.

ARGUMENTS

Data type Name Description


dip StablePixelHeap heap The heap structure
dip Boolean * result Set to true if there are no items in the heap

SEE ALSO

StablePixelHeapNew, PixelHeapNew, PixelQueueNew, StablePixelHeapFree,


StablePixelHeapPush, StablePixelHeapPop
644 Chapter 2. Function reference

StablePixelHeapNew
Create a new heap structure

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip StablePixelHeapNew ( heap, ndims, blocksize, order, resources )

FUNCTION

This function allocates space for a new dip StablePixelHeap structure. Memory allocated
is tracked in resources. The heap is dimensioned to hold pixels from an ndims-dimensional
image, and initially enough space is allocated for blocksize elements. The heap will be
expanded as necessary when used.
The heap stores the coordinates, the value and the pointer to a pixel in an image. Note that
the value does not need to equal the data pointed to by the pointer. ndims can be set to
zero, in which case no coordinates are stored; this does not affect the function of the value
and the pointer.
A heap is a priority queue data structure. Just like a queue, items can be added (pushed)
and subtracted (popped). However, in the priority queue the item popped is always the
higherst priority one: either the one with the highest-valued item (order is
DIP GVSO HIGH FIRST) or lowest-valued item (order is DIP GVSO LOW FIRST). When various
identically-valued items are stored on the heap, they will be extracted in the same order as
they were insterted (FIFO - first in, first out). If this order is unimportant (such as for the
GrowRegionsWeighted algorithm, use the more efficient dip PixelHeap instead. See
PixelHeapNew for information on the unstable heap structure.

ARGUMENTS

Data type Name Description


dip StablePixelHeap * heap The newly allocated heap structure
dip int ndims Image dimensionality
dip int blocksize Size of each allocation block
dipf GreyValueSortOrder order Determines the heap’s sort order
dip Resources resources Resources tracking structure. See
ResourcesNew
The dipf GreyValueSortOrder enumeration consists of the following values:
Name Description
DIP GVSO HIGH FIRST Process the pixels from high grey-value to low grey-value.
DIP GVSO LOW FIRST Process the pixels from low grey-value to high grey-value.
DIPlib function reference 645

IMPLEMENTATION

This data structure is implemented identically to PixelHeapNew (see that function’s


description for details), but an insertion order value is attached to each pixel pushed onto
the heap. This is used to maintain stability.

SEE ALSO

PixelHeapNew, PixelQueueNew, StablePixelHeapFree, StablePixelHeapPush,


StablePixelHeapPop, StablePixelHeapIsEmpty
646 Chapter 2. Function reference

StablePixelHeapPop
Pop item onto heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip StablePixelHeapPop ( heap, coords, pointer, value )

FUNCTION

Pops the next pixel from the heap. See StablePixelHeapNew for information on the heap
data structure. coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
If the stack was created with ndims set to 0, the coords pointer is ignored. coords,
pointer and value can be NULL if you are not interested in either those values.

ARGUMENTS

Data type Name Description


dip StablePixelHeap heap The heap structure
dip int * coords Receives the coordinates of the popped item
void ** pointer Receives the pointer of the popped item
dip sfloat * value Receives the value of the popped item

SEE ALSO

StablePixelHeapNew, PixelHeapNew, PixelQueueNew, StablePixelHeapFree,


StablePixelHeapPush, StablePixelHeapIsEmpty
DIPlib function reference 647

StablePixelHeapPush
Push item onto heap

SYNOPSIS

#include "dip pixelqueue.h"


dip Error dip StablePixelHeapPush ( heap, coords, pointer, value )

FUNCTION

Pushes a pixel onto the heap. See StablePixelHeapNew for information on the heap data
structure. All 3 values coords, pointer and value are stored, except if the heap was
created with ndims set to 0, in which case the coords pointer is ignored.
coords is a pointer to an array of dip ints, such as that obtained with
dip IntegerArray->array. It should have as many elements as the image dimensionality.
pointer is a pointer to any memory location, and value is the value to be used when
sorting.

ARGUMENTS

Data type Name Description


dip StablePixelHeap heap The heap structure
dip int * coords Coordinates to be pushed
void * pointer Pointer to be pushed
dip sfloat value Value to be pushed

SEE ALSO

StablePixelHeapNew, PixelHeapNew, PixelQueueNew, StablePixelHeapFree,


StablePixelHeapPop, StablePixelHeapIsEmpty
648 Chapter 2. Function reference

StandardDeviation
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip StandardDeviation ( in, mask, out, ps )

DATA TYPES

binary, integer, float

FUNCTION

Calculates the standard deviation of the pixel values over all those dimensions which are
specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, MeanModulus, SumModulus, MeanSquareModulus, Maximum, Minimum,
Median, Percentile
DIPlib function reference 649

StringAppend
Append a string to another

SYNOPSIS

#include "dip string.h"


dip Error dip StringAppend ( str1, str2, cstr )

FUNCTION

Concatenates str1 and str2 and puts the result in str1, which is increased in size if
necessary. If str2 is 0, cstr is used instead.

ARGUMENTS

Data type Name Description


dip String str1 First string
dip String str2 Second string
char * cstr Second string

SEE ALSO

StringCat, StringCompare, StringCompareCaseInsensitive, StringCopy, StringCrop,


StringNew, StringReplace, UnderscoreSpaces
650 Chapter 2. Function reference

StringArrayCopy
Copy a string array

SYNOPSIS

#include "dip string.h"


dip Error dip StringArrayCopy ( new, src, resources )

FUNCTION

This function copies the complete src string array to new.

ARGUMENTS

Data type Name Description


dip StringArray * new Pointer to the destination dip StringArray structure
dip StringArray src Source string array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

StringArrayNew, StringArrayFree
IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
DIPlib function reference 651

StringArrayFree
Array free function

SYNOPSIS

dip Error dip StringArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip ImageArray * array string array

SEE ALSO

StringArrayNew, StringArrayCopy
ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
652 Chapter 2. Function reference

StringArrayNew
Allocate an array of strings

SYNOPSIS

#include "dip string.h"


dip Error dip StringArrayNew ( array, size, stringSize, init, resources )

FUNCTION

This function allocates an array of strings. size specifies the size of the array, stringSize
the size of the individual strings, which are allocated too. If StringSize is zero, and init
is not, the strings in the array are initialised with init (in size and content). If both
stringSize and init are zero, strings of zero length are created. (see StringNew).

ARGUMENTS

Data type Name Description


dip StringArray * array Pointer to the array
dip int size Size of the array
dip int stringSize Size of the strings
char * init Initialisation string
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

StringArrayFree, StringArrayCopy
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
DIPlib function reference 653

StringCat
Concatenate two strings

SYNOPSIS

#include "dip string.h"


dip Error dip StringCat ( newStr, str1, str2, cstr, resources )

FUNCTION

Concatenates str1 and str2 and puts the result in newStr, which is allocated. If str2 is 0,
cstr is used instead.

ARGUMENTS

Data type Name Description


dip String * newStr Destination
dip String str1 First string
dip String str2 Second string
char * cstr Second string
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

StringAppend, StringCompare, StringCompareCaseInsensitive, StringCopy,


StringCrop, StringNew, StringReplace, UnderscoreSpaces
654 Chapter 2. Function reference

StringCompare
Compare two strings

SYNOPSIS

#include "dip string.h"


dip Error dip StringCompare ( orig, copy, verdict )

FUNCTION

This function uses the strcmp function to compare orig and copy. If the strings are
different, an error is generated, or verdict obtains the value DIP FALSE, if it is not zero.

ARGUMENTS

Data type Name Description


dip String orig The original string
dip String copy The fake (or not) string
dip Boolean * verdict Verdict of the comparison

SEE ALSO

StringAppend, StringCat, StringCompareCaseInsensitive, StringCopy, StringCrop,


StringNew, StringReplace, UnderscoreSpaces
DIPlib function reference 655

StringCompareCaseInsensitive
Compare two strings without minding case

SYNOPSIS

#include "dip string.h"


dip Error dip StringCompareCaseInsensitive ( orig, copy, verdict )

FUNCTION

This function uses the strcasecmp (or stricmp) function to compare orig and copy. If the
strings are different, an error is generated, or verdict obtains the value DIP FALSE, if it is
not zero.

ARGUMENTS

Data type Name Description


dip String orig The original string
dip String copy The fake (or not) string
dip Boolean * verdict Verdict of the comparison

SEE ALSO

StringAppend, StringCat, StringCompare, StringCopy, StringCrop, StringNew,


StringReplace, UnderscoreSpaces
656 Chapter 2. Function reference

StringCopy
Copy a String

SYNOPSIS

#include "dip string.h"


dip Error dip StringCopy ( new, src, resources )

FUNCTION

Thsi function copies string src to new.

ARGUMENTS

Data type Name Description


dip String * new Pointer to a destination dip String strcture
dip String src Source string
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

StringAppend, StringCat, StringCompare, StringCompareCaseInsensitive,


StringCrop, StringNew, StringReplace, UnderscoreSpaces
DIPlib function reference 657

StringCrop
Crop a string

SYNOPSIS

#include "dip string.h"


dip Error dip StringCrop ( str, length )

FUNCTION

Crops str to length characters.

ARGUMENTS

Data type Name Description


dip String str String to be cropped
dip int length New string length

SEE ALSO

StringAppend, StringCat, StringCompare, StringCompareCaseInsensitive,


StringCopy, StringNew, StringReplace, UnderscoreSpaces
658 Chapter 2. Function reference

StringFree
Free a string

SYNOPSIS

#include "dip string.h"


dip Error dip StringFree ( void )

FUNCTION

This function frees a string data structure that has been allocated using StringNew.

ARGUMENTS

Data type Name Description


dip String * string Pointer to the string to be freed

SEE ALSO

StringNew
DIPlib function reference 659

StringNew
Allocate a string

SYNOPSIS

#include "dip string.h"


dip Error dip StringNew ( string, size, init, resources )

FUNCTION

This function allocates a string of size size. If init is not zero, its contents is copied into
the new string. If size is zero, and init is not, the size of string is made equal to init
plus one.

ARGUMENTS

Data type Name Description


dip String * string Pointer to the new string
dip int size Size of the string
char * init Initialisation string
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

StringArrayNew, StringAppend, StringCat, StringCompare,


StringCompareCaseInsensitive, StringCopy, StringCrop, StringReplace,
UnderscoreSpaces
660 Chapter 2. Function reference

StringReplace
Replace the contents of one string with that of another

SYNOPSIS

#include "dip string.h"


dip Error dip StringReplace ( str1, str2, cstr )

FUNCTION

Replaces the content of str1 with str2. str1 is increased in size if necessary. If str2 is 0,
cstr is used instead.

ARGUMENTS

Data type Name Description


dip String str1 Destination string
dip String str2 Source string
char * cstr Source string

SEE ALSO

StringAppend, StringCat, StringCompare, StringCompareCaseInsensitive,


StringCopy, StringCrop, StringNew, UnderscoreSpaces
DIPlib function reference 661

StructureTensor2D
Two dimensional Structure Tensor

SYNOPSIS

#include "dip structure.h"


dip Error dip StructureTensor2D( in, mask, orientation, energy, l1, l2,
anisotropy1, anisotropy2, boundary, gradSpec, gradSigmas, tensorSpec,
tensorSigmas )

DATA TYPES

integer,float

FUNCTION

This function computes the Structure Tensor (ST) at each point in the image. For a
description of this technique see the references. There are two stages in the computation.
The first stage computes the gradient vector at each point, using Derivative with
parameters gradSpec and gradSigmas. The second stage, the tensor smoothing, is also
performed using Derivative (with order = 0). The parameters used are tensorSpec and
tensorSigmas.
If a mask image is given, a technique called normalised convolution (see references) is used
to “fill in” the missing data.
The routine has a number of output images. Each of these can be set to zero. If set to zero,
the corresponding result will not be computed. The following quantities are computed by
this routine:
orientation Orientation. Lies in the interval
(-pi/2,pi/2).
energy Sum of the two eigenvalues l1 and l2.
l1 The largest eigenvalue.
l2 The smallest eigenvalue.
anisotropy1 Measure for local anisotropy: ( l1 - l2 )
/ ( l1 + l2 ).
anisotropy2 Measure for local anisotropy: 1 - l2 /
l1.
662 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask Mask image (0=missing data)
dip Image orientation Orientation
dip Image energy Energy (l1+l2)
dip Image l1 Largest eigenvalue
dip Image l2 Smallest eigenvalue
dip Image anisotropy1 Local anisotropy: (l1-l2)/(l1+l2)
dip Image anisotropy2 Local anisotropy: 1-l2/l1
dip BoundaryArray boundary Boundary conditions
dip DerivativeSpec gradSpec Parameters for derivative to compute gradient
(see DerivativeSpec data structure)
dip FloatArray gradSigmas Sigmas of derivative to compute gradient
Sigma of derivative to compute gradient
dip DerivativeSpec tensorSpec Parameters for Gaussian for tensor smoothing
(see DerivativeSpec data structure)
dip FloatArray tensorSigmas Sigmas of Gaussian for tensor smoothing
Sigma of Gaussian for tensor smoothing

LITERATURE

Bernd Jahne, Practical Handbook on Image Processing for Scientific Applications, chapter
13, CRC Press, 1997
L.J. van Vliet and P.W. Verbeek, Estimators for Orientation and Anisotropy in Digitized
Images, in: J. van Katwijk, J.J. Gerbrands, M.R. van Steen, J.F.M. Tonino (eds.), ASCI’95,
Proc. First Annual Conference of the Advanced School for Computing and Imaging (Heijen,
NL, May 16-18), ASCI, Delft, 1995, pp. 442-450.
C.F. Westin, A Tensor Framework for Multidimensional Signal Processing, PhD thesis,
Linkoping University, Sweden, 1994

SEE ALSO

Derivative
DIPlib function reference 663

Sub
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Sub ( in1, in2, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in1 - in2 on a pixel by pixel basis. The data types of the
in1 and in2 image may be of different types. See Information about dyadic operations for
more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, SubFloat, SubComplex, Mul, MulFloat, MulComplex, Div,


DivFloat, DivComplex
664 Chapter 2. Function reference

SubComplex
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip SubComplex ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in - constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip complex constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubFloat, Mul, MulFloat, MulComplex, Div, DivFloat,
DivComplex
DIPlib function reference 665

SubFloat
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip SubFloat ( in, out, constant )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function computes out = in - constant on a pixel by pixel basis. The data types of
the in1 image and constant may be of different types. See Information about dyadic
operations for more information about what the type of the output will be.

ARGUMENTS

Data type Name Description


dip Image in Input
dip float constant Constant
dip Image out Output

SEE ALSO

Add, AddFloat, AddComplex, Sub, SubComplex, Mul, MulFloat, MulComplex, Div, DivFloat,
DivComplex
666 Chapter 2. Function reference

Subsampling
Interpolation function

SYNOPSIS

#include "dip interpolation.h"


dip Error dip Subsampling ( in, out, sample )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function subsamples in by copying each sampleth pixel to out.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip IntegerArray sample Sample spacing

SEE ALSO

Resampling
DIPlib function reference 667

Sum
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Sum ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the sum of the pixel values over all those dimensions which are specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Mean, Variance, StandardDeviation, MeanModulus, SumModulus, MeanSquareModulus,
Maximum, Minimum, Median, Percentile
668 Chapter 2. Function reference

SumModulus
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip SumModulus ( in, mask, out, ps )

DATA TYPES

binary, integer, float, complex

FUNCTION

Calculates the sum of the modulus the pixel values over all those dimensions which are
specified by ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, Variance, StandardDeviation, MeanModulus, MeanSquareModulus, Maximum,
Minimum, Median, Percentile
DIPlib function reference 669

Tan
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Tan ( in, out )

DATA TYPES

binary, integer, float, complex

FUNCTION

Computes the tangent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Sinh, Cosh, Tanh
670 Chapter 2. Function reference

Tanh
trigonometric function

SYNOPSIS

#include "dip math.h"


dip Error dip Tanh ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the hyperbolic tangent of the input image values.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Sinh, Cosh


DIPlib function reference 671

TestObjectAddNoise
TestObject generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip TestObjectAddNoise ( object, noisy, background, backvalue,
gaussianNoise, poissonNoise, snr, conversion, variance, random )

DATA TYPES

binary, integer, float

FUNCTION

This function adds a mixture of Gaussian and Poisson noise to a testobject at a specified
signal-to-noise ratio. The SNR is defined as the average object energy divided by the
average noise power.

ARGUMENTS

Data type Name Description


dip Image object Input Object Image
dip Image noisy Output Image
dip Image background Background Image
dip float backvalue Constant Background Value
dip float gaussianNoise Relative Amount of Gaussian Noise
dip float poissonNoise Relative Amount of Poisson Noise
dip float snr Signal to Noise Ratio
dip float * conversion (0) Pointer to the Poisson Conversion Factor
dip float * variance (0) Pointer to the Gaussian Variance
dip Random * random Pointer to a random value structure

SEE ALSO

TestObjectCreate, TestObjectModulate, TestObjectBlur


672 Chapter 2. Function reference

TestObjectBlur
TestObject generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip TestObjectBlur ( object, psf, convolved, xNyquist, testPSF )

DATA TYPES

binary, integer, float

FUNCTION

This function blurs a testobject with a Gaussian psf, with a two dimensional in focus
diffraction limited incoherent PSF or with an user-supplied PSF. The xNyquist parameter
specifies the oversampling factor of the incoherent PSF and Gaussian PSF. The sigma of the
Gaussian PSF is equal to 0.9 * xNyquist.

ARGUMENTS

Data type Name Description


dip Image object Input Object Image
dip Image psf User supplied PSF
dip Image convolved Output Image
dip float xNyquist Oversampling Factor
dipf TestPSF testPSF TestPSF
The dipf TestPSF enumaration consists of the following flags:
Name Description
DIP TEST PSF GAUSSIAN Gaussian PSF
DIP TEST PSF INCOHERENT OTF in-focus, diffraction limited, incoherent PSF
DIP TEST PSF USER SUPPLIED User supplied PSF with the psf image
DIP TEST PSF NONE no blurring

SEE ALSO

TestObjectCreate, TestObjectModulate, TestObjectAddNoise


DIPlib function reference 673

TestObjectCreate
TestObject generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip TestObjectCreate ( object, testObject, objectHeight,
objectRadius, scale, scaleRadius, scaleAmplitude, objSigma, position, random
)

DATA TYPES

Output: sfloat

FUNCTION

This function can generate an aliasing free object (ellips, box, ellipsoid shell, box shell) or
uses an user-supplied object. The generated objects have their origin at the center in the
image, but can be generated with a sub-pixel random shift around the center, to average out
dicretization effects over several instances of the same generated object. Optinally the
generated object can be convolved with an isotropic Gaussian with a width specified by
objSigma. Elliptical objects are only supported for images with a dimsnionality equal or
less than three. The position boolean variable specifies whether a subpixel random shift
should be applied to the object. This can be used to average out digitisation error over a
repetition of the generation of the same object.

ARGUMENTS

Data type Name Description


dip Image object Output Object Image
dipf TestObject testObject Type of Test Object
dip float objectHeight Object Height
dip float objectRadius Object Radius
dip FloatArray scale Relative Radii for each dimension
dip float scaleRadius ScaleRadius
dip float scaleAmplitude ScaleAmplitude
dip float objSigma Sigma of Gaussian Object Blur
dip Boolean position Random Subpixel Position Shift
dip Random * random Pointer to a random value structure
674 Chapter 2. Function reference

SEE ALSO

TestObjectModulate, TestObjectBlur, TestObjectAddNoise


DIPlib function reference 675

TestObjectModulate
TestObject generation function

SYNOPSIS

#include "dip generation.h"


dip Error dip TestObjectModulate ( in, out, modulation, modulationDepth )

DATA TYPES

Output: sfloat

FUNCTION

This function adds a sine modulation to a test object, with modulation the modulation
frequency and modulationDepth the modulation depth.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip FloatArray modulation Modulation Frequency
dip float modulationDepth ModulationDepth

SEE ALSO

TestObjectCreate, TestObjectBlur, TestObjectAddNoise


676 Chapter 2. Function reference

Threshold
Point Operation

SYNOPSIS

#include "dip point.h"


dip Error dip Threshold ( in, out, threshold, foreground, background,
binaryOutput )

DATA TYPES

integer, float

FUNCTION

This function thresholds an image at the threshold value. If the boolean binaryOutput is
true, Threshold will produce a binary image. Otherwise an image of the same type as the
input image is produced, with the pixels set to either foreground or background. In other
words: out = ( in >= threshold ? foreground : background)

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip float threshold Threshold value
dip float foreground Foreground value
dip float background Background value
dip Boolean binaryOutput Convert output image to binary

SEE ALSO

See section 10.3, “Segmentation”, in “Fundamentals of Image Processing”.


RangeThreshold, SelectValue, NotZero, Compare, HysteresisThreshold,
IsodataThreshold, Clip
DIPlib function reference 677

TikhonovMiller
Image restoration filter

SYNOPSIS

#include "dip restoration.h" #include "dip transform.h"


dip Error dip TikhonovMiller ( in, psf, out, reg, background, method, var,
lambda, flags )

FUNCTION

The TikhonovMiller restoration filter is a linear least squares restoration algorithm.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image psf Point spread function image
dip Image out Output image
dip Image reg Regularisation filter image
dip Image background (0) Background image
dipf RegularizationParameter method Method used to determine the
regularisation parameter
dip float var Noise variance
dip float * lambda Regularisation parameter
dipf ImageRestoration flags Restoration flags

LITERATURE

G.M.P. van Kempen, Image Restoration in FLuorescence Microscopy, Ph.D. Thesis, Delft
University of Technology, 1999

SEE ALSO

Wiener, TikhonovRegularizationParameter
678 Chapter 2. Function reference

TikhonovRegularizationParameter
Determine the value of the regularisation parameter

SYNOPSIS

#include "dip restoration.h"


dip Error dip TikhonovRegularizationParameter ( in, psf, reg, background,
max, min, lambda, method, var, flags )

FUNCTION

This function implements different methods to estimate the value of the regularistion
parameter lambda of the TikhonovMiller restoration filter.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image psf Point spread function image
dip Image reg Regularisation filter rimage
dip Image background (0) Background image
dip float max Maximum value of lambda
dip float min Minimum value of lambda
dip float * lambda pointer to the regularisation
parameter
dipf RegularizationParameter method Method used to determine lambda
dip float var Noise variance
dipf ImageRestoration flags Restoration flags

LITERATURE

G.M.P. van Kempen, Image Restoration in FLuorescence Microscopy, Ph.D. Thesis, Delft
University of Technology, 1999

SEE ALSO

TikhonovRegularizationParameter
DIPlib function reference 679

TimerGet
Timing functions

SYNOPSIS

#include "dip timer.h"


dip Error dip TimerGet ( timer )

FUNCTION

This function get four Timer values elapsed since the last call to TimerSet. The elapsed
clock time is measured in a low (1 second) resolution, and in a high (microseconds)
resolution. However, this latter timer can only produce reliable results within 36 minutes
after the first (!) call to TimerSet has been made. The other two timer measure the amount
of system and user time used by the program since the last call to TimerSet.

ARGUMENTS

Data type Name Description


dip Timer * timer Pointer to a dip Timer struct

SEE ALSO

TimerSet
680 Chapter 2. Function reference

TimerSet
Timing functions

SYNOPSIS

#include "dip timer.h"


dip Error dip TimerSet ( timer )

FUNCTION

This function resets four timers that can be obtained by TimerGet.

ARGUMENTS

Data type Name Description


dip Timer * timer pointer to a dip Timer structure

SEE ALSO

TimerGet
DIPlib function reference 681

Tophat
Morphological high-pass filter

SYNOPSIS

#include "dip morphology.h"


dip Error dip Tophat ( in, out, se, boundary, filterParam, shape, edgeType,
polarity )

DATA TYPES

integer, float

FUNCTION

The top-hat is the difference between a morphological operation and the original image,
comparable to a high-pass filter. Which operation is used can be chosen through the
dip MphEdgeType and dip MphTophatPolarity parameters.
The rectangular, elliptic and diamond structuring elements are “flat”, i.e. these structuring
elements have a constant value. For these structuring elements, filterParam determines
the sizes of the structuring elements. When shape is set to DIP FLT SHAPE PARABOLIC,
filterParams specifies the curvature of the parabola. When shape is set to
DIP FLT SHAPE STRUCTURING ELEMENT, se is used as structuring element. It can be either a
binary or a grey-value image, but be careful: it is converted to the same data type as the
input image, and might therefore be clipped or loose precision. It is required (in the current
implementation) that the structuring element be odd in size. Its origin is the center.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).
682 Chapter 2. Function reference

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
dip MphEdgeType edgeType edgeType
dip MphTophatPolarity polarity polarity
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
The enumerator dip MphEdgeType contains the following constants:
Name Description
DIP MPH TEXTURE Response is limited to edges in texture
DIP MPH OBJECT Response is limited to object edges
DIP MPH BOTH All edges produce equal response
The enumerator dip MphTophatPolarity contains the following constants:
Name Description
DIP MPH TEXTURE Response is limited to edges in texture
DIP MPH OBJECT Response is limited to object edges
DIP MPH BOTH All edges produce equal response

SEE ALSO

Lee, MorphologicalGradientMagnitude, MorphologicalRange,


MultiScaleMorphologicalGradient, MorphologicalSmoothing,
MorphologicalThreshold
DIPlib function reference 683

tpi.h
Type iterator

SYNOPSIS

#include "dip tpi.h"

FUNCTION

Type iterator. For each data type specified by the define DIP TPI ALLOW, dip tpi.h will
include the file specified by the define DIP TPI FILE. If DIP TPI ALLOW is not defined the file
will be included for all data types. DIP TPI TYPES must be defined as a logical OR of
identifier flags and identifier group flags, as given in DIPlib’s data types and the table
below. During each “iteration” the main symbols defined by dip tpi.h are DIP TPI,
DIP TPI DATA TYPE, DIP TPI IDENTIFIER and DIP TPI EXTENSION. The following table
shows how these are defined for each data type:
DIP TPI DIP TPI DATA TYPE DIP TPI EXTENSION
DIP TPI IDENTIFIER
dip bin8 DIP DT BIN8 DIP DTID BIN8 b8
dip bin16 DIP DT BIN16 DIP DTID BIN16 b16
dip bin32 DIP DT BIN32 DIP DTID BIN32 b32
dip uint8 DIP DT UINT8 DIP DTID UINT8 u8
dip uint16 DIP DT UINT16 DIP DTID UINT16 u16
dip uint32 DIP DT UINT32 DIP DTID UINT32 u32
dip sint8 DIP DT SINT8 DIP DTID SINT8 s8
dip sint16 DIP DT SINT16 DIP DTID SINT16 s16
dip sint32 DIP DT SINT32 DIP DTID SINT32 s32
dip sfloat DIP DT SFLOAT DIP DTID SFLOAT sfl
dip dfloat DIP DT DFLOAT DIP DTID DFLOAT dfl
dip scomplex DIP DT SCOMPLEX DIP DTID SCOMPLEX scx
dip dcomplex DIP DT DCOMPLEX DIP DTID DCOMPLEX dcx
Using this include file it is possible to compile source code for different data types. We
recommend that instead of splitting your code into two files, one for generic code and one
for type specific code, that you use dip tpi.h to let the source file include itself. This also
prevents dependency problems with makefiles. A source file that includes itself through
dip tpi.h should have the following format:

contents of example.c:
#ifndef DIP_TPI

#include "diplib.h"
684 Chapter 2. Function reference

#define DIP_TPI_FILE "example.c"


#include "dip_tpi.h"

/* This is where the generic code should be */

#else

/* This is where the type specific code should be */

#endif

In addition to the main defines as described above, there are a number of macro’s that are
defined by dip tpi.h:
DIP TPI FUNC ( function name ) attaches the current type suffix to the
function name.
DIP TPI DEFINE ( function name ) equivalent to: dip Error DIP TPI FUNC(
function name ) useful for function
definitions.
DIP TPI DECLARE ( function name ) equivalent to: dip Error DIP TPI FUNC(
function name ) useful for function
declarations. Don’t forget the trailing “;“.
DIP TPI NAME ( function name ) attaches the current type suffix to the
function name and puts double quotes
around the result, thus creating a string.
There are also a couple of defines that are only available for some of the data types:
When DIP TPI is
dip sfloat DIP TPI CAST R2C is defined as
dip scomplex
dip dfloat DIP TPI CAST R2C is defined as
dip dcomplex
dip scomplex DIP TPI CAST C2R is defined as dip sfloat
dip dcomplex DIP TPI CAST C2R is defined as dip dfloat
Other type iterators may be created by making a copy of the dip tpi.h file and replacing
DIP TPI throughout the file by a different name for the new type iterator.

ARGUMENTS

Name Description
DIP TPI ALLOW logical OR of data type identifier and identifier group flags to indicate
for which data types the file should be included
DIP TPI FILE Name of the file to be included by dip tpi.h
DIPlib function reference 685

SEE ALSO

DIPlib’s data types


DataTypeGetInfo, ovl.h
686 Chapter 2. Function reference

Truncate
Arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip Truncate ( in, out )

DATA TYPES

binary, integer, float

FUNCTION

Computes the truncation of the input image values, and outputs a signed integer typed
image.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output

SEE ALSO

Abs, Ceil, Floor, Sign, Fraction, NearestInt


DIPlib function reference 687

UnderscoreSpaces
Replace spaces with underscores

SYNOPSIS

#include "dip string.h"


dip Error dip UnderscoreSpaces ( string )

FUNCTION

This function replaces spaces in string with underscores. This function works in-place.

ARGUMENTS

Data type Name Description


dip String string String to be examined

SEE ALSO

StringAppend, StringCat, StringCompare, StringCompareCaseInsensitive,


StringCopy, StringCrop, StringNew, StringReplace
688 Chapter 2. Function reference

Uniform
Uniform filter

SYNOPSIS

#include "dip linear.h"


dip Error dip Uniform ( in, out, se, boundary, filterParam, shape )

DATA TYPES

binary, integer, float, complex

FUNCTION

This functions implements an uniform convolution filter with support for various filter
shapes.
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterParam Filter parameters
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
DIPlib function reference 689

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

General information about convolution


Gauss
690 Chapter 2. Function reference

UniformNoise
Generate an image disturbed by uniform noise

SYNOPSIS

#include "dip noise.h"


dip Error dip UniformNoise ( in, out, lowerBound, upperBound, random )

DATA TYPES

integer, float

FUNCTION

Generate an image disturbed by additive uniform noise.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip float lowerBound Lower bound of the uniform distribution the noise is
drawn from
dip float upperBound Upper bound of the uniform distribution the noise is
drawn from
dip Random * random Pointer to a random value structure

EXAMPLE

Get a image with additive uniform noise as follows:

dip_Image in, out;


dip_float lower, upper;
dip_Random random;

lower = 1.0;
upper = 10.0;
DIPXX(dip_UniformNoise(in, out, lower, upper, &random ));
DIPlib function reference 691

SEE ALSO

RandomVariable, RandomSeed, GaussianNoise, PoissonNoise, BinaryNoise


692 Chapter 2. Function reference

UniformRandomVariable
Uniform random variable generator

SYNOPSIS

#include "dip noise.h"


dip Error dip UniformRandomVariable ( random, lowerBound, upperBound, output)

FUNCTION

Generate an uniform distributed random variable.

ARGUMENTS

Data type Name Description


dip Random * random Pointer to a random value structure
dip float lowerBound Lower bound of the uniform distribution the variable is
drawn from
dip float upperBound Upper bound of the uniform distribution the variable is
drawn from
dip float* output output

EXAMPLE

Get a uniform random variable as follows:

dip_Random random;
dip_float lower, upper, value;

lower = -1.0;
upper = 1.0;
DIPXX( dip_UniformRandomVariable( &random, lower, upper, &value));

SEE ALSO

RandomVariable, RandomSeed, GaussianRandomVariable, PoissonRandomVariable,


BinaryRandomVariable
DIPlib function reference 693

Unregister
Remove a registry item

SYNOPSIS

#include "dip registry.h"


dip Error dip Unregister ( id, class )

FUNCTION

This function removes the Registry information of the ID of the Registry class class. See
Register for more information about DIPlib’s Registry.

ARGUMENTS

Data type Name Description


dip int id Registry ID
dip int class Registry class

SEE ALSO

Register, RegistryList, RegistryGet, RegistryArrayNew


694 Chapter 2. Function reference

UpperEnvelope
Upper envelope transform (a flooding and an algebraic closing)

SYNOPSIS

#include "dip morphology.h"


dip Error dip UpperEnvelope ( in, out, bottom, labels, connectivity,
max depth, max size )

DATA TYPES

integer, float

FUNCTION

The Upper envelope transform produces a flooding of the input image (which is an algebraic
closing). See any article by F. Meyer for further explanations.
The Upper envelope is based on the watershed transform, each region being filled up to the
level where it meets a neighbouring region. See Watershed for information on the
parameters.
The bottom image is a second output image that contains the whole watershed region
painted with the lowest value in it. It is useful for stretching the input image: ( out - in ) /
( in - bottom ) . labels returns the label image used during region growing.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image bottom Optional output
dip Image labels Optional output
dip int connectivity Connectivity
dip float max depth Maximum depth of a region that can be merged
dip int max size Maximum size of a region that can be merged

SEE ALSO

Watershed, LocalMinima
DIPlib function reference 695

Variance
statistics function

SYNOPSIS

#include "dip math.h"


dip Error dip Variance ( in, mask, out, ps )

DATA TYPES

binary, integer, float

FUNCTION

Calculates the variance of the pixel values over all those dimensions which are specified by
ps.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask (0) Mask
dip Image out Output
dip BooleanArray ps (0) Dimensions to project

SEE ALSO

From images to scalars


Sum, Mean, StandardDeviation, MeanModulus, SumModulus, MeanSquareModulus, Maximum,
Minimum, Median, Percentile
696 Chapter 2. Function reference

VarianceFilter
Sample Variance Filter

SYNOPSIS

#include "dip filtering.h"


dip Error dip VarianceFilter ( in, out, se, boundary, filterSize, shape )

DATA TYPES

binary, integer, float

FUNCTION

This function calculates for every pixel the sample variance of the pixels in the filter window
(it size specifiied by filterSize).
If shape is not equal to DIP FLT SHAPE STRUCTURING ELEMENT, se is allowed to be set to
zero. When shape is set to DIP FLT SHAPE STRUCTURING ELEMENT, filterParam is ignored,
(and can be set to zero).

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image out Output
dip Image se Structuring element
dip BoundaryArray boundary Boundary conditions
dip FloatArray filterSize Filter sizes
dip FilterShape shape Filter shape
The enumerator dip FilterShape contains the following constants:
Name Description
DIP FLT SHAPE DEFAULT default structuring element, same as
DIP FLT SHAPE RECTANGULAR
DIP FLT SHAPE RECTANGULAR rectangular structuring element
DIP FLT SHAPE ELLIPTIC elliptic structuring element
DIP FLT SHAPE DIAMOND diamond shaped structuring element
DIP FLT SHAPE PARABOLIC parabolic structuring element
DIP FLT SHAPE STRUCTURING ELEMENT use se as structuring element
DIPlib function reference 697

NOTE

The filter shape DIP FLT SHAPE PARABOLIC, as well as custom grey-value shapes, are not
supported.

SEE ALSO

Kuwahara
698 Chapter 2. Function reference

VectorDistanceTransform
Euclidean vector distance transform

SYNOPSIS

#include "dip distance.h"


dip Error dip VectorDistanceTransform ( in, outx, outy, outz, distance,
border, method )

DATA TYPES

binary

FUNCTION

This function produces the vector components of the Euclidean distance transform. These
are stored in the output images, one for each dimension of the input image. See the
EuclideanDistanceTransform for detailed information about the parameters.
To compute the Euclidean distance from the vector compoments produced by this function,
one needs to multiply each componemt with the sampling distance, square the result, sum
the results for all components and take the square root of the sum.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip ImageArray out Output images
dip FloatArray distance Sampling distances
dip Boolean border Image border type
dipf DistanceTransform method Transform method
dipf DistanceTransform defines the following distance transform types:
Name Description
DIP EDT FAST fastest, but most errors
DIP EDT TIES slower, but fewer errors
DIP EDT TRUE slow, uses lots of memory, but is “error free”
DIP EDT BRUTE FORCE gives a result from which errors are calculated for the other
methods. This method is extremly slow and should only be used
for testing purposes.
DIPlib function reference 699

LITERATURE

See EuclideanDistanceTransform

KNOWN BUGS

See EuclideanDistanceTransform

AUTHOR

James C. Mullikin, adapted to DIPlib by Geert M.P. van Kempen

SEE ALSO

EuclideanDistanceTransform, GreyWeightedDistanceTransform
700 Chapter 2. Function reference

VoidPointerArrayCopy
Copy an array

SYNOPSIS

dip Error dip VoidPointerArrayCopy ( dest, src, resources )

FUNCTION

This function copies the void pointer array src to dest. The array dest is created by this
function as well.

ARGUMENTS

Data type Name Description


dip IntegerArray * dest Destination array
dip IntegerArray src Source array
dip Resources resources Resources tracking structure. See ResourcesNew

SEE ALSO

VoidPointerArrayNew, VoidPointerArrayFree, VoidPointerArrayCopy,


VoidPointerArrayFind
IntegerArrayCopy, FloatArrayCopy, ComplexArrayCopy, DataTypeArrayCopy,
BooleanArrayCopy, VoidPointerArrayCopy, StringArrayCopy
DIPlib function reference 701

VoidPointerArrayFind
Find value in array

SYNOPSIS

dip Error dip VoidPointerArrayFind ( array, value, index, found )

FUNCTION

Finds a value in an array and “returns” its index in the array. If found is zero,
VoidPointerArrayFind will produce an error if value is not found, otherwise found
obtains the search result (DIP FALSE if value is not found).

ARGUMENTS

Data type Name Description


dip VoidPointerArray array Array to find value in
void * value Value to find
dip int * index Index of the found value
dip VoidPointer * found Value found or not

SEE ALSO

VoidPointerArrayNew, VoidPointerArrayFree, VoidPointerArrayCopy,


VoidPointerArrayFind
IntegerArrayFind, FloatArrayFind, ComplexArrayFind, DataTypeArrayFind,
BooleanArrayFind, VoidPointerArrayFind
702 Chapter 2. Function reference

VoidPointerArrayFree
Array free function

SYNOPSIS

dip Error dip VoidPointerArrayFree ( array )

FUNCTION

This function frees *array, and sets array to zero.

ARGUMENTS

Data type Name Description


dip VoidPointerArray * array Array

SEE ALSO

BooleanArrayNew, BooleanArrayFree, BooleanArrayCopy, BooleanArrayFind


ArrayFree, IntegerArrayFree, FloatArrayFree, ComplexArrayFree,
BoundaryArrayFree, FrameWorkProcessArrayFree, DataTypeArrayFree, ImageArrayFree,
BooleanArrayFree, VoidPointerArrayFree, StringArrayFree, CoordinateArrayFree
DIPlib function reference 703

VoidPointerArrayNew
Array allocation function

SYNOPSIS

dip Error dip VoidPointerArrayNew ( array, size, resources )

FUNCTION

This function allocates the size elements of a dip VoidPointerArrayNew and sets the size
of the array to size.

ARGUMENTS

Data type Name Description


dip VoidPointerArray * array Array
dip int size Size
dip Resources resources Resources tracking structure. See
ResourcesNew

SEE ALSO

VoidPointerArrayNew, VoidPointerArrayFree, VoidPointerArrayCopy,


VoidPointerArrayFind
ArrayNew, IntegerArrayNew, FloatArrayNew, ComplexArrayNew, BoundaryArrayNew,
FrameWorkProcessArrayNew, DataTypeArrayNew, ImageArrayNew, BooleanArrayNew,
VoidPointerArrayNew, StringArrayNew, CoordinateArrayNew
704 Chapter 2. Function reference

Watershed
Morphological segmentation

SYNOPSIS

#include "dip morphology.h"


dip Error dip Watershed ( in, mask, out, connectivity, max depth, max size,
binaryOutput )

DATA TYPES

integer, float

FUNCTION

Watershed segmentation with built-in region merging. max depth and max size control the
merging procedure. Any region with max size or less pixels and with max depth grey-value
difference or less will be merged to neighbouring regions when they touch (as opposed to
build a watershed). max size equal to 0 means that the size of the region is not tested when
merging. The regions are grown according to the connectivity parameter. See The
connectivity parameter for more information. The output is either a labelled image where
the pixels belonging to a catchment basin are labelled, or a binary image where the
watershed pixels are 1 and the rest is 0. This is controlled by binaryOutput.
If mask is not 0, only the pixels within mask will be considered. All the other pixels will be
marked as watershed pixels.

ARGUMENTS

Data type Name Description


dip Image in Input
dip Image mask Mask
dip Image out Output
dip int connectivity Connectivity
dip float max depth Maximum depth of a region that can be merged
dip int max size Maximum size of a region that can be merged
dip Boolean binaryOutput DIP FALSE if the output should be a labelled image

SEE ALSO

SeededWatershed, UpperEnvelope, LocalMinima, GrowRegions


DIPlib function reference 705

WeightedAdd
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip WeightedAdd ( in1, in2, out, weight )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function calculates out = in1 + weight * in2;

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output
dip float weight Weight

SEE ALSO

WeightedMul, WeightedSub, WeightedDiv


706 Chapter 2. Function reference

WeightedDiv
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip WeightedDiv ( in1, in2, out, weight )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function calculates out = in1 / weight * in2; If (weight * in2) is zero, out will be
set to zero as well.

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output
dip float weight Weight

SEE ALSO

WeightedAdd, WeightedMul, WeightedSub


DIPlib function reference 707

WeightedMul
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip WeightedMul ( in1, in2, out, weight )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function calculates out = in1 * weight * in2;

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output
dip float weight Weight

SEE ALSO

WeightedAdd, WeightedSub, WeightedDiv


708 Chapter 2. Function reference

WeightedSub
arithmetic function

SYNOPSIS

#include "dip math.h"


dip Error dip WeightedSub ( in1, in2, out, weight )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function calculates out = in1 - weight * in2;

ARGUMENTS

Data type Name Description


dip Image in1 First input
dip Image in2 Second input
dip Image out Output
dip float weight Weight

SEE ALSO

WeightedAdd, WeightedMul, WeightedDiv


DIPlib function reference 709

Wiener
Image Restoration Filter

SYNOPSIS

#include "dip restoration.h"


dip Error dip Wiener ( in, psf, signalPower, noisePower, out, flags )

FUNCTION

This function performs an image restoration using the Wiener filter. The Wiener filter is the
linear restoration filter that is optimal in mean square error sense.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image psf Point spread function image
dip Image signalPower SignalPower image
dip Image noisePower NoisePower image
dip Image out Output image
dipf Restoration flags Restoration flags

LITERATURE

G.M.P. van Kempen, Image Restoration in FLuorescence Microscopy, Ph.D. Thesis, Delft
University of Technology, 1999

SEE ALSO

PseudoInverse, TikhonovMiller
710 Chapter 2. Function reference

Wrap
Wrap an image

SYNOPSIS

#include "dip manipulation.h"


dip Error dip Wrap ( in, out, wrap )

DATA TYPES

binary, integer, float, complex

FUNCTION

This function wraps the in image around its image borders. wrap specifies the number of
pixels over which the image has to wrapped in each dimension.

ARGUMENTS

Data type Name Description


dip Image in Input image
dip Image out Output image
dip IntegerArray wrap Wrap parametrs

SEE ALSO

Wrap, Crop, Shift


DIPlib function reference 711

Xor
logic operation

SYNOPSIS

#include "dip math.h"


dip Error dip Xor ( in1, in2, out )

DATA TYPES

binary, integer

FUNCTION

The function Xor performs the logic XOR operation between the corresponding pixels in
in1 and in2, and stores the result in out.

ARGUMENTS

Data type Name Description


dip Image in1 First binary input image
dip Image in2 Second binary input image
dip Image out Output image

SEE ALSO

And, Or, Invert


Chapter 3

Assorted topics

712
DIPlib function reference 713

3.1 Boundary conditions

Neighbourhood operations pose a problem. What happens when the neighbourhood


operator operates near the border of the image and needs data from the area outside the
image? The usual solution, also adopted by DIPlib, is to silently extend the image. There
are various ways of extending the boundary. Below is a list of the possible methods. More
details can be found in the user guide. Note that not all functions support all of these.
Name Description
DIP BC SYM MIRROR Symmetric mirroring
DIP BC ASYM MIRROR Asymmetric mirroring
DIP BC PERIODIC Periodic copying
DIP BC ASYM PERIODIC Asymmetric periodic copying
DIP BC ADD ZEROS Extending the image with zeros
DIP BC ADD MAX VALUE Extending the image with +infinity
DIP BC ADD MIN VALUE Extending the image with -infinity

SEE ALSO

FillBoundaryArray, SeparableFrameWork
714 Chapter 3. Assorted topics

3.2 Compression methods for image files

The dipio Compression structure

The structure dipio Compression specifies the compression method to use when writing an
image file, and contains the following elements:
Data type Name Description
dipio CompressionMethod method Compression method
dip int level Compression parameter, dependent on method
dipio CompressionMethod is an enum with the known compression methods. File formats
typically only support one or a few of these, and most of these methods do not have a
parameter to set, in which case level is ignored. If an unsupported compression method is
selected, no compression is done. The dipio CompressionMethod has the following values:
Name Description
DIPIO CMP DEFAULT Default compression method for the file format
DIPIO CMP NONE No compression
DIPIO CMP GZIP ZIP compression, using zlib. The level parameter is between
1 and 10, 1 being the faster, lesser compression and 10 being
the slower, higher compression.
DIPIO CMP DEFLATE Deflate (same as DIPIO CMP GZIP)
DIPIO CMP COMPRESS Using UNIX’s “compress” utility, which uses the LZW
algorithm
DIPIO CMP LZW LZW compression (same as DIPIO CMP COMPRESS)
DIPIO CMP JPEG Lossy JPEG compression. The level parameter is between 1
and 100, higher numbers giving better quality output but
larger files.
DIPIO CMP PACKBITS PackBits
DIPIO CMP THUNDERSCAN ThunderScan
DIPIO CMP NEXT NeXT
DIPIO CMP CCITTRLE CCITT RLE
DIPIO CMP CCITTRLEW CCITT RLE/W
DIPIO CMP CCITTFAX3 CCITT Group 3
DIPIO CMP CCITTFAX4 CCITT Group 4
Thus only DIPIO CMP GZIP and DIPIO CMP JPEG currently have a level to set.

Supported compression methods for the various file formats

The TIFF file writer understand the methods DIPIO CMP NONE, DIPIO CMP DEFLATE,
DIPIO CMP LZW, DIPIO CMP JPEG, DIPIO CMP PACKBITS, DIPIO CMP THUNDERSCAN,
DIPIO CMP NEXT, DIPIO CMP CCITTRLE, DIPIO CMP CCITTRLEW, DIPIO CMP CCITTFAX3 and
DIPIO CMP CCITTFAX4. It defaults to DIPIO CMP DEFLATE. The level parameter is currently
not used.
DIPlib function reference 715

The ICS file writer understands DIPIO CMP NONE, DIPIO CMP GZIP and DIPIO CMP COMPRESS,
although DIPIO CMP COMPRESS is currently not implemented. It defaults to DIPIO CMP GZIP.
The GIF file writer only understands DIPIO CMP LZW. The compression method selected is
simply ignored.
The JPEG file writer only understands DIPIO CMP JPEG. The compression method selected
is simply ignored.
All other file writers do not compress, and simply ignore the compression method requested.
716 Chapter 3. Assorted topics

3.3 DerivativeSpec data structure

STRUCTURE

This structure is an aggregate of common parameters for derivative operators. Its current
definition is:

typedef struct
{
dip_DerivativeFlavour flavour;
dip_float truncation;
} dip_DerivativeSpec;

The enumerator flavour parameter is one of:


Name Description
DIP DF DEFAULT Default derivative flavour (==DIP DF FIRGAUSS)
DIP DF FIRGAUSS Gaussian family, FIR implementation, Gauss
DIP DF IIRGAUSS Gaussian family, IIR implementation, GaussIIR
DIP DF FTGAUSS Gaussian family, FT implementation, GaussFT
DIP DF FINITEDIFF Finite difference implementation, FiniteDifferenceEx

SEE ALSO

StructureTensor2D, Derivative
DIPlib function reference 717

3.4 DIPlib’s data types

Pixel values are represented by different types, called data types. DIPlib supports the data
types given in the following table:
data type dip DataType data type suffix
identifier
dip bin8 DIP DT BIN8 DIP DTID BIN8 b8
dip bin16 DIP DT BIN16 DIP DTID BIN16 b16
dip bin32 DIP DT BIN32 DIP DTID BIN32 b32
dip uint8 DIP DT UINT8 DIP DTID UINT8 u8
dip uint16 DIP DT UINT16 DIP DTID UINT16 u16
dip uint32 DIP DT UINT32 DIP DTID UINT32 u32
dip sint8 DIP DT SINT8 DIP DTID SINT8 s8
dip sint16 DIP DT SINT16 DIP DTID SINT16 s16
dip sint32 DIP DT SINT32 DIP DTID SINT32 s32
dip sfloat DIP DT SFLOAT DIP DTID SFLOAT sfl
dip dfloat DIP DT DFLOAT DIP DTID DFLOAT dfl
dip scomplex DIP DT SCOMPLEX DIP DTID SCOMPLEX scx
dip dcomplex DIP DT DCOMPLEX DIP DTID DCOMPLEX dcx
The data types can be divided into five classes: the binary, unsigned integer, signed integer,
floating point and complex classes. Different data types in the same class (e.g. dip uint8
and dip uint16) provide a different range of values they can represent.
The complex data types are defines as follows:

typedef struct typedef struct


{ {
dip_sfloat re; dip_dfloat re;
dip_sfloat im; dip_dfloat im;
} dip_scomplex; } dip_dcomplex;

The binary data types are simply aliases for a set of corresponding unsigned integer types.
The reason for having a separate typedef for the binary types is that they are not used like
ordinary integers. Each bit of the integer can store one binary value. When manipulating
binary data, care must be taken not to change any of the other bits of the integer used for
storing it.
The dip DataType enumeration is used to represent data types symbolically. It is used in
dip Image‘s to indicate what the data type of the image is. Data type identifiers are used
by the type iterator (see tpi.h) and overload schemes (see ovl.h and overload.h). Type
suffixes are used to give type specific routines a unique name. Using a standard set of
suffixes enables the type iterator and overload schemes to deal with these type specific
routines. The dip DataType enumeration, data type identifiers and suffixes can be found in
the table above.
718 Chapter 3. Assorted topics

In addition to the data type identifiers for individual data types, there are also defines to
represent an entire group. These are given in the following table:
Data type identifier group data types
DIP DTGID UINT unsigned integer
DIP DTGID UNSIGNED unsigned integer
DIP DTGID SINT signed integer
DIP DTGID INT signed and unsigned integer
DIP DTGID INTEGER signed and unsigned intege
DIP DTGID FLOAT floating-point
DIP DTGID REAL integer and floating-point
DIP DTGID COMPLEX complex floating-point
DIP DTGID SIGNED signed integer, floating-point and complex
DIP DTGID BINARY binary
DIP DTGID ALL all

SEE ALSO

DataTypeGetInfo
DIPlib function reference 719

3.5 dip MsrRegistry structure

WARNING: this documentation page is outdated!


The dip MsrRegistry structure contains the following elements:
Data type Name Description
dip int id The ID of the measurement function
dipf MsrFunctionType type The type of the function that performs
the measurement
dip MsrCreateFunction create The measurement create function, see
MsrCreateFunction
dip MsrComposeFunction create The measurement compose function, see
MsrComposeFunction
dip MsrMeasureFunction measure The measurement measure function, see
MsrMeasureFunction
dip MsrValueFunction value The measurement value function, see
MsrValueFunction
dip MsrConvertFunction labels The measurement labels function, see
MsrConvertFunction
dip MsrDescriptionFunction description The measurement description
function, see MsrDescriptionFunction
dip int iterations The number of iterations on the data
the measurement measure function
requires
The id of the measurement function should be unique, and can easily be obtained using
GetUniqueNumber.
The type element specifies on which data format of the object labels the measurement
measure function performs its measurement. The following types of measure functions are
currently supported:
Name Description
DIP MSR FUNCTION LINE BASED Measurement is performed on a line by line basis
DIP MSR FUNCTION IMAGE BASED Measurement is performed having access to
complete object label and intensity images
DIP MSR FUNCTION CHAINCODE BASED Measurement is performed on object’s chaincode
DIP MSR FUNCTION COMPOSITE Measurement is performed using the result of
other measurements
The iterations element of dip MsrRegistry specifies how many times the measurement
measure function should be called (sequentially) to perform its measurement. This feature
is not yet supported, all functions are called once.
720 Chapter 3. Assorted topics

SEE ALSO

MeasurementFeatureRegister, MsrCreateFunction, MsrMeasureFunction,


MsrValueFunction, MsrConvertFunction, MsrDescriptionFunction
DIPlib function reference 721

3.6 Description of DIPlib’s pixel tables

Pixel tables provide an efficient way to encode a multi-dimensional binary object. DIPlib’s
dip PixelTable implements this using runlength encoding (in 2-D this coding scheme is
known as pxy-tables).
A DIPlib pixel table is a structure (defined in dip pixel table.h) that incorporates a
link-list of runlengths. Each run-length consists of a n-D coordinate (integer array) and the
length of the run along the X dimension. All the runlength’s in total encode the binary
object.

LITERATURE

See section 3.6, “Contour representations”, in “Fundamentals of Image Processing”.


I.T. Young, R.L. Peverini, P.W. Verbeek and P.J. van Otterloo, A New Implementation for
Binary and Minkowski Operators, Computer Graphics and Image Processing, Volume 17,
No. 3, 189-210, 1981
722 Chapter 3. Assorted topics

3.7 File formats recognized by dipIO

The Registry

A number of file reading and writing functions are included in dipIO. These are registered in
the ImageReadRegistry and the ImageWriteRegistry. Through this registry, ImageRead
and ImageWrite are able to read from and write to any registered file format. You can add
your own functions to these (the interface functions for this are not documented yet),
thereby increasing the possibilities of ImageRead and ImageWrite.
Below you can find a list of currently supported file formats for both reading and writing.
To obtain the format ID from the registry, you need to include the specified file and call the
specified function.

Reading

These are the file formats currently supported for reading:


DIPlib function reference 723

format include file registry ID dimension- colour data types


retrieval ality
function
ICS (Image any yes any
Cytometry dipio ics.h dipio ReadICSID
Standard)
TIFF 2D yes any
(Tagged dipio tiff.h dipio ReadTIFFID
Image File
Format)
JPEG 2D yes uint8
(JPEG File dipio jpeg.h dipio ReadJPEGID
Interchange
Format)
GIF 2D yes uint8
(Graphics dipio gif.h dipio ReadGIFID
Interchange
Format)
LSM (Zeiss 1D - 4D no uint8, uint16
LSM file dipio lsm.h dipio ReadLSMID and sfloat
format)
PIC 2D and 3D no uint8
(BioRad dipio pic.h dipio ReadPICID
PIC file
format)
CVS 2D no sfloat
(Comma dipio csv.h dipio ReadCSVID
Separated
Values)

Writing

These are the file formats currently supported for writing:


724 Chapter 3. Assorted topics

format include file registry ID dimension- colour data types


retrieval ality
function
ICS v1 any yes any, binXX
(Image dipio ics.h dipio WriteICSv1ID converted to
Cytometry uintXX
Standard)
ICS v2 any yes any, binXX
(Image dipio ics.h dipio WriteICSv2ID converted to
Cytometry uintXX
Standard)
TIFF 2D yes any in
(Tagged dipio tiff.h dipio WriteTIFFID grey-value,
Image File uint8 in
Format) colour
JPEG 2D yes uint8
(JPEG File dipio jpeg.h dipio WriteJPEGID
Interchange
Format)
GIF 2D no uint8
(Graphics dipio gif.h dipio WriteGIFID
Interchange
Format)
CVS 2D no any except
(Comma dipio csv.h dipio WriteCSVID complex
Separated
Values)
FLD (AVS any no any
field file) dipio fld.h dipio WriteFLDID
PS dipio ps.h 2D yes uint8, others
(PostScript) dipio WritePSID automati-
cally
converted
EPS (Enca- dipio ps.h 2D yes uint8, others
pulated dipio WriteEPSID automati-
PostScript) cally
converted
DIPlib function reference 725

3.8 From images to scalars

Within DIPlib all data, i.e. multi-dimensional data, such as images, and scalar, are all
represented by the same object: the image. Scalars are stored as zero dimensional images.
Examine, for example, the following code to compute the sum over all the grey values:

dip_Image img;
dip_Image value;
...
dip_Sum ( img, 0, value, 0 );

Which stores the sum over all the pixel values of img in the 0-D image value. We often
want to directly manipulate scalars, in which case we need to extract the value. This can be
accomplished easily with the GetInteger, GetFloat or the GetComplex functions:

dip_Image img;
dip_Image valueimg;
dip_float value;
...
dip_Sum ( img, 0, valueimg, 0 );
dip_GetFloat ( valueimg, &value, 0 );
printf ( "The sum is: %f\n", value );
726 Chapter 3. Assorted topics

3.9 General information about convolution

Convolution can be explained in just a few words: it is a local weighted average (the weights
can be negative). This of course does not explain how to use it or what its properties are.
For this we refer to the following sources:
Ian T. Young, Jan J. Gerbrands and Lucas J. van Vliet, “Fundamentals of Image
Processing”.
Alan V. Oppenheim, Alan S. Willsky and I.T. Young, “Signals and Systems”, Prentice-Hall,
1983.
Anil K. Jain, “Fundamentals of Digital Image Processing”, Prentice-Hall, 1989.
“The Digital Signal Processing Handbook”, Vijay K. Madisetti and Douglas B. Williams
(eds), CRC Press + IEEE Press, 1998.
Kenneth R. Castleman, “Digital Image Processing”, Prentice-Hall, 1996.
DIPlib function reference 727

3.10 General information about sorting

There are two kinds of sorting routines in DIPlib. The first sorts a one-dimensional array of
data, the second sorts a set of indices to a one-dimensional array of data. The result of the
sort routines can be summarised as follows:
Sort: data[ i ] <= data[ i + 1 ]
Sort indices: data[ indices[ i ] ] <= data[ indices[ i + 1 ] ]
Note that the number of indices does not have to be equal to the amount of pixels in the
image, it may be either smaller or larger. The indices themselves should of course “point” to
a valid pixel.
The sorting algorithms are described in the following reference:
Donald E. Knuth, “The Art of Computer Programming, volume 3: Sorting and Searching”,
second edition, Addison-Wesley, 1998.
728 Chapter 3. Assorted topics

3.11 Information about dyadic operations

There are two types of dyadic operations. First there are operations such as Add, Sub, etc...
which take two input images. The second category consists of functions such as AddFloat,
AddComplex etc... The data type of the output image given the data types of the input
images is given by the following table:
dcomplex scomplex dfloat sfloat sint32 sint16
dcomplex dcomplex dcomplex dcomplex dcomplex dcomplex dcomplex
scomplex dcomplex scomplex dcomplex scomplex scomplex scomplex
dfloat dcomplex dcomplex dfloat dfloat dfloat dfloat
sfloat dcomplex scomplex dfloat sfloat sfloat sfloat
sint32 dcomplex scomplex dfloat sfloat sint32 sint32
sint16 dcomplex scomplex dfloat sfloat sint32 sint16
sint8 dcomplex scomplex dfloat sfloat sint32 sint16
uint32 dcomplex scomplex dfloat sfloat sint32 sint32
uint16 dcomplex scomplex dfloat sfloat sint32 sint16
uint8 dcomplex scomplex dfloat sfloat sint32 sint16
binary dcomplex scomplex dfloat sfloat sint32 sint16
sint8 uint32 uint16 uint8 binary
dcomplex dcomplex dcomplex dcomplex dcomplex dcomplex
scomplex scomplex scomplex scomplex scomplex scomplex
dfloat dfloat dfloat dfloat dfloat dfloat
sfloat sfloat sfloat sfloat sfloat sfloat
sint32 sint32 sint32 sint32 sint32 sint32
sint16 sint16 sint32 sint16 sint16 sint16
sint8 sint8 sint32 sint16 sint8 sint8
uint32 sint32 uint32 uint32 uint32 uint32
uint16 sint16 uint32 uint16 uint16 uint16
uint8 sint8 uint32 uint16 uint8 uint8
binary sint8 uint32 uint16 uint8 sint8
The output data type of an operation involving an image and a constant of one of the types:
dip complex, dip float, dip int, is given by the following table:
DIPlib function reference 729

dip complex dip float dip int


dcomplex dcomplex dcomplex dcomplex
scomplex scomplex scomplex scomplex
dfloat dcomplex dfloat dfloat
sfloat scomplex sfloat sfloat
sint32 scomplex sint32 sint32
sint16 scomplex sint16 sint16
sint8 scomplex sint8 sint8
uint32 scomplex uint32 uint32
uint16 scomplex uint16 uint16
uint8 scomplex uint8 uint8
binary scomplex sint8 sint8
730 Chapter 3. Assorted topics

3.12 The image structure

DESCRIPTION

dip Image is the structure that is used to store images in DIPlib. It contains a number of
fields that are used to describe an image. The type field stores the type of the image using a
dip ImageType enumeration. Currently scalar images are the only supported type
(DIP IMTP SCALAR). The DIP IMTP ALIEN type is used internally by DIPlib for creating
interfaces to other packages. Whether the other fields in the dip Image are meaningful
depends on the image type. A dip Image may contain fields specific to the current image
type. These will be discussed on the pages pertaining to the type in question. The standard
fields that are always present are:
field type short description access functions
dip ImageType The image type ImageGetType,
ImageSetType
dip ImageState The image state (none)
dip DataType Data type used to store ImageGetDataType,
pixel values ImageSetDataType
dip IntegerArray Dimensions of the image ImageGetDimensions,
ImageGetDimensionality,
ImageSetDimensions
void * Pointer to the pixel data ImageGetData
dip int Plane number, for binary ImageGetPlane
images
dip IntegerArray Stride array (see below) ImageGetStride
Pixel values are stored in the data type specified by the data type field. For a list of possible
data types see DIPlib’s data types.
The dimensionality of the image and the size of each individual dimension is stored in the
dimensions Array.
The data pointer points to the pixel at the origin of the image. For each dimension the
stride array holds the interleave between two neigbouring pixels in memory. The following
equation may be used to compute the address of a pixel at a coordinate specified by an
array called cor[]:

(N-1)
address = origin + Sum cor[i] * stride[i]
i=0

A dip Image structure does not necessarily have pixel data associated with it. When a
dip Image does not contain pixel data, it is said to be in the “raw” state. A dip Image that
does contain data, is said to be “forged”. For binary images the plane field holds the
number of the bit in which the binary data is stored. Access to the fields of a dip Image is
DIPlib function reference 731

restricted to a number of functions, which are given in the table above. The “set” functions
can only be used on “raw” images.

SEE ALSO

DIPlib’s data types


ImageNew
732 Chapter 3. Assorted topics

3.13 The connectivity parameter

DIPlib uses a different name for the various possible connectivites than you might be used
to. This is to generalize this parameter to images of any dimensionality. It is defined as
follows: if connectivity is 1 all pixels for which only one coordinate differs from the pixel’s
coordinates by maximally 1 are considered neighbours; if it is 2, all pixels for which one or
two coordinates differ maximally 1 are considered neighbours. The connectivity can never
be larger than the image dimensionality.
In terms of the obsolete connectivity definitions we have:
In 2-D this connectivity corresponds to and forms this
structuring
element
1 4 connectivity diamond
2 8 connectivity square
-1 4-8 connectivity octagon
-2 8-4 connectivity octagon
In 3-D this connectivity corresponds to and forms this
structuring
element
1 6 connectivity octahedron
2 18 connectivity cuboctahedron
3 26 connectivity cube
-1 6-26 connectivity small rhombicuboc-
tahedron
-3 26-6 connectivity small rhombicuboc-
tahedron
The negative connectivities are only defined for the functions in binary morphology such as
BinaryDilation and BinaryErosion. These alternate steps with different connectivity to
produce a better approximation to an isotropic structuring element.

You might also like