switch_colors {RImagePalette} | R Documentation |
Swap Colors in an Image
Description
Swap the palette of an image!
Usage
switch_colors(target_image, source_image, source_colors = 3,
smoothness = 100, ...)
Arguments
target_image |
Matrix The image you wish to transfer colors into.
The output from |
source_image |
Matrix The image you wish to transfer colors from. |
source_colors |
Integer The number of colors you wish to extract from the source image. |
smoothness |
Integer The source colors are interpolated such that the image doesn't appear blocky. The value of smoothness determines how many values are interpoloated between the source_colors. That is, smoothness determines the length of the palette used. Higher values return smoother images. |
... |
Pass any of the arguments for |
Value
The image, but with swapped colors!
Examples
#Trivial example of using only 5 dominant colors
# from an image to recolor itself
img1 <- jpeg::readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
img2 <- jpeg::readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
switch_colors(img1, img2, source_colors=5, smoothness=20)
[Package RImagePalette version 0.1.1 Index]