# Colour volume estimation

#### 2020-12-17

Traditionally, colour volume or “colourfulness” of an object has been measured by computing the volume of the convex hull containing the data points, as described in (Stoddard and Prum 2008)

$$\alpha$$-shapes are a new tool available in pavo to estimate colour volumes, while allowing the presence of voids and pockets, which may lead to a more accurate measurement of “colourfulness” than convex hulls. For more information on the theoretical background, please report to the related article (Gruson 2020)

# $$\alpha$$-shapes in chromaticity diagrams

You can plot the colour volume using $$\alpha$$-shape with the vol() function (for non-interactive plots, tcsvol() otherwise) by specifying type = "alpha". By default, this will use the $$\alpha^*$$ value defined in Gruson (2020).

library(pavo)
data(flowers)
vis_flowers <- vismodel(flowers, visual = "avg.uv")
tcs_flowers <- colspace(vis_flowers)
plot(tcs_flowers)
vol(tcs_flowers, type = "alpha")

To get the colour volume value, you can use the summary.colspace() function. The colour volume computed by the convex hull is contained in the c.vol column and the colour volume computed by the $$\alpha$$-shape (with parameter $$\alpha^*$$) is contained in the a.vol column:

summary(tcs_flowers)

Alternatively, you can set the $$\alpha$$ parameter to the value of your choice via the avalue argument:

plot(tcs_flowers)
vol(tcs_flowers, type = "alpha", avalue = 0.5)

# $$\alpha$$-shapes in perceptually uniform spaces

In the previous section, we focused on $$\alpha$$-shapes in chromaticity diagrams since it is the most common space where convex hulls (that $$\alpha$$-shapes aim at replacing) are used. But it is also possible to use $$\alpha$$-shapes in other spaces, such as perceptually uniform spaces.

Let’s first build this uniform space and look at the data points in this space:

cd_flowers <- coldist(vis_flowers)
xy_flowers <- jnd2xyz(cd_flowers)
plot(xy_flowers)

High-level functions to build the $$\alpha$$-shape directly in pavo have not yet been implemented but you can use the alphashape3d package directly to compute the $$\alpha$$-shapes, its volume and display it in a 3D interactive plot.

library(alphashape3d)
ashape_jnd <- ashape3d(as.matrix(xy_flowers), alpha = 10)
volume_ashape3d(ashape_jnd)
plot(ashape_jnd)

# Colour volume overlap with $$\alpha$$-shapes

$$\alpha$$-shapes can also be used to measure the colour similarity of two objects, by computing the colour volume overlap. This is done in pavo with the overlap3d() function. For example, let’s compare the colour volume of the crown and the breast of stripe-tailed yellow finches (Sicalis citrina):

data(sicalis)
tcs.sicalis.C <- subset(colspace(vismodel(sicalis)), "C")
tcs.sicalis.B <- subset(colspace(vismodel(sicalis)), "B")
voloverlap(tcs.sicalis.C, tcs.sicalis.B, type = "alpha", plot = TRUE)

Gruson, Hugo. 2020. “Estimation of Colour Volumes as Concave Hypervolumes Using α-Shapes.” Methods in Ecology and Evolution 11 (8): 955–63. https://doi.org/10.1111/2041-210X.13398.

Stoddard, Mary Caswell, and Richard O. Prum. 2008. “Evolution of Avian Plumage Color in a Tetrahedral Color Space: A Phylogenetic Analysis of New World Buntings.” The American Naturalist 171 (6): 755–76. https://doi.org/10.1086/587526.