#' Convert RGB indices to tibble
#'
#' Converts a RasterBrick or RasterStack object of RGB indices into a tibble.
#'
#' @param x A RasterBrick or RasterStack object containing RGB indices.
#'
#' @return
#' A tibble where each column corresponds to an RGB index
#' and each row represents a pixel from the input raster.
#'
#' @details
#' The function converts raster layers into a tabular format using
#' \code{raster::as.data.frame}, preserving layer names as column names.
#'
#' @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)
#'
#' @export
rgb_indices_to_tbl <- function(x){
  
  df <- raster::as.data.frame(x)
  
  colnames(df) <- names(x)
  
  tibble::as_tibble(df)
  
}