FindContigRegions

Declaration: FindContigRegions(Data: TInt2DArray; Thresh1, Thresh2, MinSize, MaxSize: integer; var Regions: TInt2DArray): integer;
Finds contiguous regions in an image. The image is represented by the two-dimensional integer array of intensities stored in Data. A contiguous region is defined by pixels which are adjacent (i.e. having an edge in common); pixels which have just a single corner in common are not regarded to be contiguous. The parameters Thresh1 and Thresh2 define the limits of the interesting intensities. All pixels having an intensity greater than or equal to Thresh1 and less than or equal to Thresh2 are used for finding contiguous regions.

The parameters MinSize and MaxSize control the minimum and maximum size limits (in pixels) of a contiguous region. Regions which have an area less than MinSize or greater than MaxSize are not detected and are considered to belong to the background. Setting MaxSize to a zero value switches off the size limit control.

The function FindContigRegions returns the found contiguous regions in the variable array Regions. The rows of this array contain all found regions (each row describes a particular region). The columns of Regions contain the following information:

column contents
0,1 the x and y coordinates of one of the pixels of the region
2 left edge of the circumscribing rectangle (parallel to the axes)
3 right edge
4 bottom edge
5 top edge
6 size of the region (number of pixels)

After performing FindContigRegions the Data array contains the indication of contiguous regions; all regions are numbered from 1 to NRegs, cells having the same region number belong to the same region, cells with zeroes are not part of a particle. Please note that the region number starts with 1 while the indices of the Region array are zero-based. The function returns the number of contiguous regions.