Type: Package
Title: RGB Visible Indices for Image Analysis
Version: 0.1.1
Description: Computes RGB-based vegetation, color, and spectral indices from digital images for applications in agriculture, crop phenotyping, and remote sensing. The methods are based on digital image processing and plant phenotyping approaches (Singh et al. (2023) <doi:10.1080/10106049.2022.2160831>).
License: MIT + file LICENSE
Encoding: UTF-8
Imports: raster, tibble
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-04-28 11:29:58 UTC; Admin
Author: RN Singh [aut], Bappa Das [aut], Sonam [aut], Anil Kumar [aut], Santosha Rathod [aut, cre]
Maintainer: Santosha Rathod <santoshagriculture@gmail.com>
Repository: CRAN
Date/Publication: 2026-04-29 07:40:02 UTC

Basic RGB indices

Description

Computes basic RGB indices including normalized red (r), green (g), blue (b), and intensity (INT) from an RGB image.

Usage

rgb_basic(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object with seven layers:

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_basic(img)


RGB color indices

Description

Computes multiple RGB-based color indices from a three-band RGB image.

Usage

rgb_color(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object where each layer represents a specific RGB-based color index, including Grey, BI, HI, RI, SI, CI, CIVE, VEG, IPCA, GLAI, SAT, OHI, TCVI, COM1, and COM2.

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_color(img)


RGB difference indices

Description

Computes difference-based RGB indices from a three-band RGB image.

Usage

rgb_diff(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object where each layer represents a difference between RGB bands: GRD (G - R), BGD (B - G), RGD (R - G), RBD (R - B), GBD (G - B), and BRD (B - R).

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_diff(img)


Load example RGB image

Description

Provides the file path to an example RGB image included in the package. Optionally allows saving the image to a user-specified location.

Usage

rgb_example(save_path = NULL)

Arguments

save_path

Optional file path to save the example image.

Value

A character string representing the file path to the example RGB image.

Examples

# Get example image path
img_path <- rgb_example()
img_path

# Save image to temporary location
rgb_example(tempfile(fileext = ".jpg"))


Mean RGB indices

Description

Computes the mean values of RGB-based indices from a RasterBrick or RasterStack object.

Usage

rgb_indices_to_mean(x)

Arguments

x

A RasterBrick or RasterStack object containing RGB indices.

Details

The function calculates the mean of each layer in the input raster object using raster::cellStats. The output provides a summary of the indices for the entire image.

Value

A tibble (data frame) with a single row where each column represents the mean value of an RGB index computed across all pixels.

Examples

r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
x <- rgb_basic(img)

rgb_indices_to_mean(x)


Convert RGB indices to tibble

Description

Converts a RasterBrick or RasterStack object of RGB indices into a tibble.

Usage

rgb_indices_to_tbl(x)

Arguments

x

A RasterBrick or RasterStack object containing RGB indices.

Details

The function converts raster layers into a tabular format using raster::as.data.frame, preserving layer names as column names.

Value

A tibble where each column corresponds to an RGB index and each row represents a pixel from the input raster.

Examples

r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
x <- rgb_basic(img)

rgb_indices_to_tbl(x)


RGB normalized difference indices

Description

Computes normalized difference indices from a three-band RGB image.

Usage

rgb_normdiff(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object where each layer represents a normalized difference between RGB bands: NRGDI ((R - G)/(R + G + B)), NRBDI ((R - B)/(R + G + B)), NGBDI ((G - B)/(R + G + B)), NGRDI ((G - R)/(R + G + B)), NBGDI ((B - G)/(R + G + B)), and NBRDI ((B - R)/(R + G + B)).

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_normdiff(img)


RGB ratio indices

Description

Computes ratio-based indices from a three-band RGB image.

Usage

rgb_ratio(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object where each layer represents a ratio between RGB bands: GRRI (G/R), GBRI (G/B), RBRI (R/B), RGRI (R/G), BGRI (B/G), and BRRI (B/R).

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_ratio(img)


RGB vegetation indices

Description

Computes vegetation-related indices from a three-band RGB image.

Usage

rgb_veg(image)

Arguments

image

A RasterBrick or RasterStack object with three bands (R, G, B).

Value

A RasterStack object containing multiple vegetation indices derived from RGB bands. Each layer corresponds to a specific vegetation index, including: WI, GRVI, IKAW, NDTI, GBI, GLI, VARI, NDI, ExG, ExR, ExGR, MxEG, ExB, and RGBVI.

Examples

set.seed(123)
r <- raster::raster(matrix(runif(50*50), 50, 50))
g <- raster::raster(matrix(runif(50*50), 50, 50))
b <- raster::raster(matrix(runif(50*50), 50, 50))
img <- raster::stack(r, g, b)
rgb_veg(img)