Name

CreatePixelIndexList — creates a list of pixel indices for each blob in a blob image

Calling Sequence

PixelIndexMatrix = CreatePixelIndexList(BlobImage);

Parameters

BlobImage

2D matrix of type uint32

PixelIndexMatrix

Matrix of type int32 that has as many columns as BlobImage contains blobs and as many rows as the biggest blob has pixels. If a blob has n pixels, the first n rows contain the n pixel indices.

Description

This function creates a matrix of pixel indices. Each column corresponds to a blob. If a blob has n pixels, the first n rows contain the n pixel indices. AnalyzeBlobs calls this function so you do not need to call it yourself.

Examples

RGB = ReadImage('contrib\IPD-3.3\demos\teaset.png'); 

Image = RGB2Gray(RGB);

ThresholdedImage = SegmentbyThreshold(Image, 200);

BlobImage = SearchBlobs(ThresholdedImage);

FilteredBlobImage = FilterBySize(BlobImage, 100); // Small objects are removed.

IsCalculated = GenerateFeatureStruct(%f); // Feature struct is generated.

IsCalculated.PixelIndexList = %t; // The pixel index list shall be calculated for each blob.

SizeHistogram = CreateHistogram(BlobImage);
 
NumberOfObjects = length(SizeHistogram) - 1;

PixelIndexMatrix = CreatePixelIndexList(FilteredBlobImage);

for n = 1 : NumberOfObjects
  
 PixelIndexList = PixelIndexMatrix(1 : SizeHistogram(n + 1), n);

 disp(PixelIndexList);

end;

See also

SearchBlobs, FilterBySize, CreateFeatureStruct, AnalyzeBlobs, CreateSizeHistogram, CumulateSizeHistogram