Plots non-background pixels according to their color coordinates, and colors them according to their RGB or HSV values. Dimensions are either RGB or HSV depending on flags.
plotPixels(
img,
n = 10000,
lower = c(0, 0.55, 0),
upper = c(0.25, 1, 0.25),
color.space = "rgb",
ref.white = NULL,
pch = 20,
main = "default",
from = "sRGB",
xlim = "default",
ylim = "default",
zlim = "default",
...
)
Either a path to an image or a loadImage
object.
Number of randomly selected pixels to plot; recommend <20000 for speed. If n exceeds the number of non-background pixels in the image, all pixels are plotted. If n is not numeric, all pixels are plotted.
RGB or HSV triplet specifying the lower bounds for background pixels. Default upper and lower bounds are set to values that work well for a bright green background (RGB [0, 1, 0]).
RGB or HSV triplet specifying the upper bounds for background pixels. Default upper and lower bounds are set to values that work well for a bright green background (RGB [0, 1, 0]). Determining these bounds may take some trial and error, but the following bounds may work for certain common background colors:
Black: lower=c(0, 0, 0); upper=c(0.1, 0.1, 0.1)
White: lower=c(0.8, 0.8, 0.8); upper=c(1, 1, 1)
Green: lower=c(0, 0.55, 0); upper=c(0.24, 1, 0.24)
Blue: lower=c(0, 0, 0.55); upper=c(0.24, 0.24, 1)
If no background filtering is
needed, set bounds to some non-numeric value (NULL
, FALSE
,
"off"
, etc); any non-numeric value is interpreted as NULL
.
The color space ("rgb"
, "hsv"
, or
"lab"
) to use for plotting.
The reference white passed to
convertColor
; must be specified if img
does
not already contain CIE Lab pixels. See convertColorSpace.
Passed to scatterplot3d
.
Plot title. If left as "default", image name is used.
Original color space of image if plotting in CIE Lab space, probably either "sRGB" or "Apple RGB", depending on your computer.
Ranges for the X, Y, and Z axes. If "default", the widest ranges for each axis according to the specified color space (0-1 for RGB and HSV, 0-100 for L of Lab, -128-127 for a and b of Lab) are used.
Optional parameters passed to
scatterplot3d
.
3D plot of pixels in either RGB or HSV color space, colored according
to their color in the image. Uses
scatterplot3d
function.
# NOT RUN {
colordistance::plotPixels(system.file("extdata",
"Heliconius/Heliconius_B/Heliconius_07.jpeg", package="colordistance"),
n=20000, upper=rep(1, 3), lower=rep(0.8, 3), color.space = "rgb", angle = -45)
# }
Run the code above in your browser using DataLab