The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Corresponding author:

1. Introduction

The rgbIndices package provides a comprehensive set of RGB-based indices derived from digital images. These indices are widely used in agriculture, crop phenotyping, vegetation monitoring, and image-based modeling.

The package includes multiple groups of indices such as basic, difference, ratio, normalized difference, vegetation, and color indices.


2. RGB Components

An RGB image consists of three channels:


3. Basic Indices

Index Formula
Normalized Red (r) R / (R + G + B)
Normalized Green (g) G / (R + G + B)
Normalized Blue (b) B / (R + G + B)
Intensity (INT) (R + G + B) / 3

4. Difference Indices

Index Full Form Formula
GRD Green Red Difference G − R
BGD Blue Green Difference B − G
RGD Red Green Difference R − G
RBD Red Blue Difference R − B
GBD Green Blue Difference G − B
BRD Blue Red Difference B − R

5. Ratio Indices

Index Full Form Formula
GRRI Green Red Ratio Index G / R
GBRI Green Blue Ratio Index G / B
RBRI Red Blue Ratio Index R / B
RGRI Red Green Ratio Index R / G
BGRI Blue Green Ratio Index B / G
BRRI Blue Red Ratio Index B / R

6. Normalized Difference Indices

Index Full Form Formula
NGRDI Normalized Green Red Difference Index (G − R) / (R + G + B)
NRGDI Normalized Red Green Difference Index (R − G) / (R + G + B)
NBRDI Normalized Blue Red Difference Index (B − R) / (R + G + B)
NRBDI Normalized Red Blue Difference Index (R − B) / (R + G + B)
NGBDI Normalized Green Blue Difference Index (G − B) / (R + G + B)
NBGDI Normalized Blue Green Difference Index (B − G) / (R + G + B)

Note: Some normalized difference indices are sign-inverted counterparts of each other (e.g., NGRDI vs NRGDI).

7. Vegetation Indices

Index Full Form Formula
WI Woebbecke Index (G − B) / (R − G)
GRVI Green Red Vegetation Index (G − R) / (G + R)
IKAW Kawashima Index (R − B) / (R + B)
NDTI Normalized Difference Turbidity Index (R − G) / (R + G)
GBI Green Blue Index (G − B) / (G + B)
GLI Green Leaf Index (2G − R − B) / (2G + R + B)
VARI Visible Atmospherically Resistant Index (G − R) / (G + R − B)
NDI Normalized Difference Index (g − r) / (g + r)
ExG Excess Green Index 2g − r − b
ExR Excess Red Index 1.4r − g
ExGR Excess Green minus Red 3g − 2.4r − b
MxEG Modified Excess Green 1.262G − 0.884R − 0.311B
ExB Excess Blue 1.4b − g
RGBVI RGB Vegetation Index (G² − RB) / (G² + RB)

8. Color Indices

Index Full Form Formula
Grey Gray Intensity 0.2898r + 0.5870g + 0.1140b
BI Brightness Index √((R² + G² + B²)/3)
HI Hue Index (2R − G − B) / (G − B)
RI Redness Index R² / (B × G³)
SI Saturation Index 2(R − G − B) / (G − B)
CI Coloration Index (R − B) / R
CIVE Color Index of Vegetation 0.441R − 0.811G + 0.385B + 18.78745
VEG Vegetative Index G / (R^0.667 × B^0.333)
SAT Overall Saturation Index (
OHI Overall Hue Index atan(2(R − G − B)/(30.5(G − B)))
TCVI True Color Vegetation Index 1.4(2R − 2B)/(2R − G − 2B + 255×0.4)

9. Example Workflow

library(rgbIndices)
library(raster)
## Loading required package: sp
# ---------------------------
# Example
# ---------------------------
set.seed(123)
r <- raster::raster(matrix(runif(30*30), 30, 30))
g <- raster::raster(matrix(runif(30*30), 30, 30))
b <- raster::raster(matrix(runif(30*30), 30, 30))
img <- raster::stack(r, g, b)

# Compute indices
idx  <- rgb_basic(img)
idx1 <- rgb_diff(img)
idx2 <- rgb_ratio(img)
idx3 <- rgb_normdiff(img)
idx4 <- rgb_veg(img)
idx5 <- rgb_color(img)

# Summary statistics
rgb_indices_to_mean(idx)
## # A tibble: 1 × 7
##       R     G     B     r     g     b   INT
##   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.496 0.500 0.493 0.334 0.336 0.330 0.497
# Convert to table
tbl <- rgb_indices_to_tbl(idx)
head(tbl)
## # A tibble: 6 × 7
##       R      G     B     r     g      b   INT
##   <dbl>  <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl>
## 1 0.288 0.924  0.155 0.210 0.676 0.114  0.456
## 2 0.963 0.887  0.864 0.355 0.327 0.318  0.904
## 3 0.665 0.508  0.575 0.380 0.291 0.329  0.583
## 4 0.131 0.0872 0.541 0.172 0.115 0.713  0.253
## 5 0.648 0.461  0.784 0.342 0.244 0.414  0.631
## 6 0.847 0.709  0.136 0.501 0.419 0.0804 0.564

—————————

Real image example

—————————

img_real <- raster::stack(rgb_example())
raster::plotRGB(img_real)
rgb_basic(img_real)

10. Applications

11. Reference

Singh, R. N., Krishnan, P., Singh, V. K., & Das, B. (2023).
Estimation of yellow rust severity in wheat using visible and thermal imaging coupled with machine learning models.
Geocarto International.
https://www.tandfonline.com/doi/full/10.1080/10106049.2022.2160831

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.