Description Usage Arguments Details Value Examples
Searches for pixels within a radius of a single color. Draws a sphere around a region of color space in which to search for pixels.
1 2 | sphericalRange(pixel.array, center, radius, target.color = "green",
main = "", color.pixels = TRUE, plotting = TRUE)
|
pixel.array |
An image represented as a 3D array (as read in by
|
center |
A single color (RGB triplet) around which to search. RGB range 0-1 (not 0-255). |
radius |
A value between 0 and 1 specifying the size of the area around
|
target.color |
Color with which to replace specified pixels. Can be
either a an RGB triplet or one of the colors listed by
|
main |
Optional title to display for image. |
color.pixels |
Logical. Should a diagnostic image with pixels changed to
|
plotting |
Logical. Should output be plotted in the plot window? |
lower
and upper
should be vectors of length 3 in a 0-1 range,
in the order R-G-B. For example, the upper bounds for white would be c(1, 1,
1), and the lower bounds might be c(0.8, 0.8, 0.8). This would search for all
pixels where the red value, blue value, AND green value are all between 0.8
and 1.
A list with the following elements:
pixel.idx
: Coordinates of pixels within color range.
img.fraction
: Proportion of the image within color range.
original.img
: The original RGB array.
indicator.img
: If color.pixels = TRUE
, RGB array with
color-swapped pixels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Target color: change all of the red flowers to turquoise
flowers <- jpeg::readJPEG(system.file("extdata", "flowers.jpg", package =
"countcolors"))
# Red:
center <- c(255, 75, 75) / 255
# Setting the radius too low:
red.flowers <- countcolors::sphericalRange(flowers, center = center, radius =
0.05, target.color = "turquoise")
# Setting the radius too high:
red.flowers <- countcolors::sphericalRange(flowers, center = center, radius =
0.4, target.color = "turquoise")
# Setting the radius just right:
red.flowers <- countcolors::sphericalRange(flowers, center = center, radius =
0.2, target.color = "turquoise")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.