Skip to content
Snippets Groups Projects
Commit 3e0ea80f authored by Gilquin's avatar Gilquin
Browse files

fix: rename cc input

parent 6d1a9a64
No related branches found
No related tags found
No related merge requests found
......@@ -23,14 +23,14 @@ import::here("image.R", "img_to_df", .character_only = TRUE)
#' Histogram ggplot of each color channel of an image.
#'
#' @param img an imager::cimg
#' @param cc a character vector, subset of ("R", "G", "B").
#' @param ch a character vector, subset of ("R", "G", "B").
#'
#' @returns a ggplot2 graph
channel_hist <- function(img, cc = c("R", "G", "B")) {
if (all(cc %in% c("R", "G", "B"))) {
channel_hist <- function(img, ch = c("R", "G", "B")) {
if (all(ch %in% c("R", "G", "B"))) {
gg <- img %>%
img_to_df() %>%
filter(channel %in% cc) %>%
filter(channel %in% ch) %>%
ggplot(aes(value, col = channel)) +
geom_histogram(bins = 30L) +
facet_wrap(~channel)
......@@ -46,14 +46,14 @@ channel_hist <- function(img, cc = c("R", "G", "B")) {
#' Raster ggplot of an image channel.
#'
#' @param img an imager::cimg
#' @param cc character, specify the image channel, one of "R", "G", "B".
#' @param ch character, specify the image channel, one of "R", "G", "B".
#'
#' @returns a ggplot2 graph
raster_channel <- function(img, cc = NULL) {
if (cc %in% c("R", "G", "B")) {
raster_channel <- function(img, ch = NULL) {
if (ch %in% c("R", "G", "B")) {
gg <- img %>%
img_to_df() %>%
filter(channel == cc) %>%
filter(channel == ch) %>%
ggplot(aes(x, y, fill = value)) +
geom_raster() +
scale_x_continuous(expand = c(0L, 0L)) +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment