Description Usage Arguments Value Note Examples
Takes images, computes color clusters for each image, and calculates distance matrix/dendrogram from those clusters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | imageClusterPipeline(
images,
cluster.method = "hist",
distance.method = "emd",
lower = c(0, 140/255, 0),
upper = c(60/255, 1, 60/255),
hist.bins = 3,
kmeans.bins = 27,
bin.avg = TRUE,
norm.pix = FALSE,
plot.bins = FALSE,
pausing = TRUE,
color.space = "rgb",
ref.white,
from = "sRGB",
bounds = c(0, 1),
sample.size = 20000,
iter.max = 50,
nstart = 5,
img.type = FALSE,
ordering = "default",
size.weight = 0.5,
color.weight = 0.5,
plot.heatmap = TRUE,
return.distance.matrix = TRUE,
save.tree = FALSE,
save.distance.matrix = FALSE,
a.bounds = c(-127, 128),
b.bounds = c(-127, 128)
)
|
images |
Character vector of directories, image paths, or both. |
cluster.method |
Which method for getting color clusters from each image
should be used? Must be either |
distance.method |
One of four possible comparison methods for calculating
the color distances: |
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 ( |
hist.bins |
Only applicable if |
kmeans.bins |
Only applicable if |
bin.avg |
Logical. Should the color clusters used for the distance matrix
be the average of the pixels in that bin (bin.avg= |
norm.pix |
Logical. Should RGB or HSV cluster values be normalized using
|
plot.bins |
Logical. Should the bins for each image be plotted as they are calculated? |
pausing |
Logical. If |
color.space |
The color space ( |
ref.white |
The reference white passed to
|
from |
Display color space of image if clustering in CIE Lab space, probably either "sRGB" or "Apple RGB", depending on your computer. |
bounds |
Upper and lower limits for the channels; R reads in images with intensities on a 0-1 scale, but 0-255 is common. |
sample.size |
Only applicable if |
iter.max |
Only applicable if |
nstart |
Only applicable if |
img.type |
Logical. Should file extensions be retained with labels? |
ordering |
Logical if not left as "default". Should the color clusters
in the list be reordered to minimize the distances between the pairs? If
left as default, ordering depends on distance method: "emd" and "chisq" do
not order clusters ("emd" orders on a case-by-case in the
|
size.weight |
Weight of size similarity in determining overall score and
ordering (if |
color.weight |
Weight of color similarity in determining overall score
and ordering (if |
plot.heatmap |
Logical. Should a heatmap of the distance matrix be plotted? |
return.distance.matrix |
Logical. Should the distance matrix be returned to the R environment or just plotted? |
save.tree |
Either logical or a filepath for saving the tree; default if
set to |
save.distance.matrix |
Either logical or filepath for saving distance
matrix; default if set to |
a.bounds, b.bounds |
Passed to |
Color distance matrix, heatmap, and saved distance matrix and tree
files if saving is TRUE
.
This is the fastest way to get a distance matrix for color similarity
starting from a folder of images. Essentially, it just calls in a series of
other package functions in order: input images -> getImagePaths
-> getHistList
or getKMeansList
followed by
extractClusters
-> getColorDistanceMatrix
->
plotting -> return/save distance matrix. Sort of railroads you, but good for
testing different combinations of clustering methods and distance metrics.
1 2 3 4 5 6 7 8 | ## Not run:
colordistance::imageClusterPipeline(dir(system.file("extdata", "Heliconius/",
package="colordistance"), full.names=TRUE), color.space="hsv", lower=rep(0.8,
3), upper=rep(1, 3), cluster.method="hist", distance.method="emd",
hist.bins=3, plot.bins=TRUE, save.tree="example_tree.newick",
save.distance.matrix="example_DM.csv")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.