CENTROID_CVIP

centroid_cvip() - finds the centroid of a binary object.

Contents

SYNTAX

Com = centroid_cvip(labeledImage,  [r,  c])
[Rc, Cc] = centroid_cvip(labeledImage,  [r,  c])

Input Parameters include :

Output Parameter include :

DESCRIPTION

This function provides information about the centroid of the binary object. Centroid is the midpoint along each row and column axis corresponding to the middle based on the spatial distribution of pixels within the object.

REFERENCE

1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.

EXAMPLE

% Read image

 input_img = imread('Shapes.bmp');

 lab_image = label_cvip(input_img);

% Calling function

 Com = centroid_cvip(lab_image, [115,359]);

 [r,c] = centroid_cvip(lab_image,  [115,359]);

% Display input image

 figure; imshow(input_img,[]);
 fprintf('Centroid: ');
 fprintf('%d %d', Com(1), Com(2));
Centroid: 129 385

CREDITS

Author: Mehrdad Alvandipour, March 2017
Copyright © 2017-2018 Scott E Umbaugh
For updates visit CVIP Toolbox Website