Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (21 sloc) 1.09 KB

Connected-component labelling (aka blob extraction)

by Andrew Brampton 2011

Simple javascript library that does connected-component labelling (aka blob extraction). It uses the Algorithm described in the paper "A linear-time component labeling algorithm using contour tracing technique".

This is useful for Computer Vision problems, such as identifying objects in a photo.


<script type="text/javascript" src="connected-component-labelling.js"></script>

    matrix = BlobExtraction(matrix, rect);


function BlobExtraction(matrix, width, height)

Performs blob extraction on a matrix of zeros and ones. The matrix must be a one dimensional array, which represents a image with dimisions width x height.

A array the same size as matrix is returned, containing numbered labels.

function BlobBounds(labels, width, height)

Uses the labels returned by BlobExtraction, works out the bounds of each labelled blob.

function BlobColouring(dest, width, height, labels)

Creates a coloured image, containing all the blobs identified in labels.

Something went wrong with that request. Please try again.