Centroid

Replace the greyscale shapes (Range 0-255) in the original image by their respective centroids (commonly used after the 8-bit labelling operators).

 

function call:

[out_img1]=vsg('Centroid',in_img1);

 

Arguments:

in_img1 input image, 3 channel RGB, 1 channel greyscale or binary image, or DICOM image.

 

Description:

Replace grey scale shape by a single pixel at its centre of gravity. The Centroid function is limited by the fact that it can have maximum 255 blobs in a scene. It is also assumes a black background which is ignored in the centroid calculation. This approach is based on the fact that all the shapes must have a distinct grey scale. out_img1- An image which contains a white pixel representing the centroid of each white blob in the input image.

 

Example:

img1=openimage('blobs.jpg');

[img1] = vsg('Threshold',img1,100);

[out_img1]=vsg('Centroid',img1);

h=figure;image(uint8(img1));set(h,'Name','Input image');

h=figure; imagesc(uint8(out_img1));set(h,'Name','Centroid image');

Notes:

This function can handle up to 255 individual blobs. If there are more blobs in the input image, use the slower function Centroid16 which can handle more blobs.
Home       Functions       Back