Name

DrawBoundingBoxes — draws bounding boxes into an image

Calling Sequence

DrawBoundingBoxes(BlobList, Color, FigureHandle)

Parameters

BlobList

a list of blob features, should be generated using AnalyzeBlobs

Color

a vector with three elements, all elements must be in the interval [0, 1].

FigureHandle

Handle to the graphic window where the bounding boxes shall be drawn. This parameter is optional. If it is omitted, the bounding boxes are drawn in the current figure.

Description

This function draws bounding boxes into an image. Thus it is possible to mark objects found in an image with rectangles.

Examples

RGB = imread('lena.png'); // This image should reside in the current directory.

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.BoundingBox = %t; // The bounding box shall be calculated for each blob.

BlobStatistics = AnalyzeBlobs(FilteredBlobImage, IsCalculated);

Figure1 = figure();

ShowImage(FilteredBlobImage, 'BlobImage', jetcolormap(16));

DrawBoundingBoxes(BlobStatistics, Figure1, [1 1 1]); // Bounding boxes are drawn in white.

Figure2 = figure(); 

DrawBoundingBoxes(Image, Figure2, [1 0 0]); // Bounding boxes are drawn in red.