img_centroid: Centroid of object on image

View source: R/img_centroid.R

img_centroidR Documentation

Centroid of object on image

Description

Compute the coordinates of the centroid of the object based on image moments. The centroid is based on shape if the image is binary and is weighted by the pixel values if it is not (in which case it is usually called the centre of mass).

Usage

img_centroid(x)

Arguments

x

a greyscale image, of type imager::cimg()

Value

A vector with the x and y coordinates of the centroid.

Examples

x <- img_read(system.file("extdata", "plank/16199658.jpg", package="morphr"))
X_binary <- x < 1
X_inverted <- 1 - x
img_centroid(X_binary)
img_centroid(X_inverted)

jiho/morphr documentation built on May 11, 2024, 9:32 p.m.