Description Usage Arguments Details Value Examples
View source: R/02b_Lab_color_clustering.R
Applies getLabHist
to every image in a provided set of image
paths and/or directories containing images.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
images |
Character vector of directories, image paths, or both. |
bins |
Number of bins for each channel OR a vector of length 3 with bins for each channel. Bins = 3 will result in 3^3 = 27 bins; bins = c(2, 2, 3) will result in 2 * 2 * 3 = 12 bins (2 L, 2 a, 3 b), etc. |
sample.size |
Numeric. How many pixels should be randomly sampled from the non-background part of the image and converted into CIE Lab coordinates? If non-numeric, all pixels will be converted, but this can be very slow (see details). |
ref.white |
Reference white passed to |
from |
Original color space of image, probably either "sRGB" or "Apple RGB", depending on your computer. |
bin.avg |
Logical. Should the returned color clusters be the average of
the pixels in that bin (bin.avg= |
as.vec |
Logical. Should the bin sizes just be returned as a vector?
Much faster if only using |
plotting |
Logical. Should a histogram of the bin colors and sizes be plotted? |
pausing |
Logical. If |
lower, upper |
RGB or HSV triplets specifying the lower and 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
( |
alpha.channel |
Logical. If available, should alpha channel transparency be
used to mask background? See |
title |
String for what the title the plot if plotting is on; defaults to the image name. |
a.bounds, b.bounds |
Numeric ranges for the a (green-red) and b (blue-yellow) channels of Lab color space. Technically, a and b have infinite range, but in practice nearly all values fall between -128 and 127 (the default). Many images will have an even narrower range than this, depending on the lighting conditions and conversion; setting narrower ranges will result in finer-scale binning, without generating empty bins at the edges of the channels. |
... |
Additional arguments passed to |
getLabHist
uses convertColorSpace
to convert
pixels into CIE Lab coordinates, which requires a references white. 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
Color conversions will be highly dependent on the reference white used, which is why no default is provided. Users should look into standard illuminants to choose an appropriate reference for a dataset.
Unlike RGB or HSV color spaces, the three channels of CIE Lab color space do
not all range between 0 and 1; instead, L (luminance) is always between 0 and
100, and the a (green-red) and b (blue-yellow) channels generally vary
between -128 and 127, but usually occupy a narrower range depending on the
reference white. The exception is reference white A (standard incandescent
lighting), which tends to have lower values when converting with
convertColor
.
A list of getLabHist
dataframes, 1 per image, named
by image name.
1 2 3 4 5 6 | images <- system.file("extdata", "Heliconius/Heliconius_B",
package="colordistance")
colordistance::getLabHistList(images, bins = 2, sample.size = 1000, ref.white
= "D65", plotting = TRUE, pausing = FALSE, lower = rep(0.8, 3), upper =
rep(1, 3), a.bounds = c(-100, 100), b.bounds = c(-127, 100), ylim = c(0, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.