plotPixels {colordistance} | R Documentation |
Plot pixels in color space
Description
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.
Usage
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",
...
)
Arguments
img |
Either a path to an image or a |
n |
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. |
lower |
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]). |
upper |
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:
If no background filtering is
needed, set bounds to some non-numeric value ( |
color.space |
The color space ( |
ref.white |
The reference white passed to
|
pch |
Passed to |
main |
Plot title. If left as "default", image name is used. |
from |
Original color space of image if plotting in CIE Lab space, probably either "sRGB" or "Apple RGB", depending on your computer. |
xlim , ylim , zlim |
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
|
Value
3D plot of pixels in either RGB or HSV color space, colored according
to their color in the image. Uses
scatterplot3d
function.
Note
If n
is not numeric, then all pixels are plotted, but this is
not recommended. Unless the image has a low pixel count, it takes much
longer, and plotting this many points in the plot window can obscure
important details.
There are seven CIE standardized illuminants available in
colordistance
(A, B, C, E, and D50, D55, and D65), but the most
common are:
-
"A"
: Standard incandescent lightbulb -
"D65"
: Average daylight -
"D50"
: Direct sunlight
Examples
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)