#' RGB ratio indices
#'
#' Computes ratio-based indices from a three-band RGB image.
#'
#' @param image A RasterBrick or RasterStack object with three bands (R, G, B).
#'
#' @return
#' 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)
#'
#' @export
rgb_ratio <- function(image){
  suppressWarnings({
    img <- raster::brick(image)
    R <- img[[1]]; G <- img[[2]]; B <- img[[3]]
    out <- raster::stack(G/R,G/B,R/B,R/G,B/G,B/R)
    names(out) <- c("GRRI","GBRI","RBRI","RGRI","BGRI","BRRI")
    out[!is.finite(out)] <- NA
    out
  })
}