Description Usage Arguments Value Examples
Changes pixels in an image to a different color and displays and/or returns the re-colored image.
1 2 | changePixelColor(pixel.array, pixel.idx, target.color = "green",
return.img = FALSE, plotting = TRUE, main = "")
|
pixel.array |
An image represented as a 3D array (as read in by
|
pixel.idx |
An n x 2 matrix of index coordinates specifying which pixels to change, where rows are pixels and columns are X and Y coordinates in the image. |
target.color |
Color with which to replace specified pixels. Can be
either a an RGB triplet or one of the colors listed by
|
return.img |
Logical. Should RGB array with swapped colors be returned? |
plotting |
Logical. Should output be plotted in the plot window? |
main |
Optional title to display for image. |
Raster array with indicated pixels changed to target color, if
return.img = TRUE
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Change a rectangle in the center to black
flowers <- jpeg::readJPEG(system.file("extdata", "flowers.jpg", package =
"countcolors"))
sinister.object <- expand.grid(c(114:314), c(170:470))
countcolors::changePixelColor(flowers, sinister.object, target.color = "black")
## Not run:
# Change all the white flowers to magenta
indicator.img <- countcolors::sphericalRange(flowers, center = c(1, 1, 1),
radius = 0.1, color.pixels = TRUE, plotting = FALSE)
countcolors::changePixelColor(flowers, indicator.img$pixel.idx,
target.color="magenta")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.