Skip to contents

Given an image and a matrix of labels that identify each object, the function extracts the red, green, and blue values from each object.

Usage

object_rgb(img, labels)

Arguments

img

An Image object

labels

A mask containing the labels for each object. This can be obtained with EBImage::bwlabel() or EBImage::watershed()

Value

A data.frame with n rows (number of pixels for all the objects) and the following columns:

  • id: the object id;

  • R: the value for the red band;

  • G: the value for the blue band;

  • B: the value for the green band;

Examples

if (interactive() && requireNamespace("EBImage")) {
library(pliman)
img <- image_pliman("soybean_touch.jpg")
# segment the objects using the "B" (blue) band (default)

labs <- object_label(img, watershed = TRUE)
rgb <- object_rgb(img, labs[[1]])
head(rgb)
}

#>   id         R         G         B
#> 1  1 0.3725490 0.5411765 0.5647059
#> 2  1 0.3294118 0.5019608 0.5137255
#> 3  1 0.3176471 0.4784314 0.4941176
#> 4  1 0.3254902 0.4862745 0.4941176
#> 5  1 0.3450980 0.5058824 0.5137255
#> 6  1 0.3647059 0.5372549 0.5490196