countColorsInDirectory: Count colors within range(s) in every image in a directory

Description Usage Arguments Value See Also Examples

Description

A wrapper for countColors that finds every image (JPEG or PNG) in a #' folder and counts colors in each image.

Usage

1
2
3
4
countColorsInDirectory(folder, color.range = "spherical", center, radius,
  lower, upper, bg.lower = rep(0.8, 3), bg.upper = rep(1, 3),
  target.color = c("magenta", "cyan", "yellow"), plotting = FALSE,
  save.indicator = FALSE, dpi = 72, return.indicator = FALSE)

Arguments

folder

Path to a folder containing images.

color.range

Type of range being specified. Must be either "spherical" or "rectangular".

center

A vector or n x 3 matrix of color centers (RGB triplets) around which to search using spherical color range. RGB range 0-1 (not 0-255). See details.

radius

Values between 0 and 1 specifying the size of the area around center to search. The same number of centers and radii must be specified.

lower

RGB triplet(s) specifying the bounds of color space to search. Must be the same length. See details.

upper

RGB triplet(s) specifying the bounds of color space to search. Must be the same length. See details.

bg.lower

RGB triplets specifying the bounds of color space to ignore as background, or NULL to use the entire image.

bg.upper

RGB triplets specifying the bounds of color space to ignore as background, or NULL to use the entire image.

target.color

If an indicator image is created, the color with which to replace specified pixels. Can be either an RGB triplet or one of the colors listed by colors.

plotting

Logical. Should output be plotted in the plot window?

save.indicator

Logical OR path for saving indicator image. If TRUE, saves image to the same directory as the original image as 'originalimagename_masked.png'; if a path is provided, saves it to that directory/name instead.

dpi

Resolution (dots per image) for saving indicator image.

return.indicator

Logical. Should an indicator image (RGB array with targeted pixels changed to indicator color) be returned?

Value

A list of countColors lists, one for each image.

See Also

countColors

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
folder <- system.file("extdata", package = "countcolors")

# Screen out white in both the flower image and the pelican image
upper <- c(1, 1, 1)
lower <- c(0.8, 0.8, 0.8)

white.screen <- countcolors::countColorsInDirectory(folder, color.range =
"rectangular", upper = upper, lower = lower, bg.lower = NULL, plotting =
TRUE, target.color = "turquoise")

## End(Not run)

Example output

5 images 

Using rectangular bound(s):
R: 0.8-1; G: 0.8-1; B: 0.8-1

 Image: bat_wing.png
Image: flowers.jpg
Image: pelicans.jpg
Image: photoshop.png
Image: white_bg.png
Warning messages:
1: In removeBackground(img, lower = lower, upper = upper, quietly = alpha.message,  :
  No transparent pixels in image
2: In removeBackground(img, lower = lower, upper = upper, quietly = alpha.message,  :
  No transparent pixels in image
3: In removeBackground(img, lower = lower, upper = upper, quietly = alpha.message,  :
  No transparent pixels in image

countcolors documentation built on May 2, 2019, 6:08 a.m.