# \donttest{
# Set a seed, for reproducibility
set.seed(153)
# Run the adjacency analysis on a single image of a butterfly
papilio <- getimg(system.file("testdata/images/butterflies/papilio.png", package = "pavo"))
papilio_class <- classify(papilio, kcols = 4)
papilio_adj <- adjacent(papilio_class, xscale = 100)
# Expand on the above, by including (fake) color distances and hsl values
# of colour elements in the image
# Generate fake color distances
distances <- data.frame(
c1 = c(1, 1, 1, 2, 2, 3),
c2 = c(2, 3, 4, 3, 4, 4),
dS = c(5.3, 3.5, 5.7, 2.9, 6.1, 3.2),
dL = c(5.5, 6.6, 3.3, 2.2, 4.4, 6.6)
)
# Generate some fake hue, saturation, luminance values
hsl_vals <- data.frame(
patch = seq_len(4),
hue = c(1.5, 2.2, 1.0, 0.5),
lum = c(10, 5, 7, 3),
sat = c(3.5, 1.1, 6.3, 1.3)
)
# Run the full analysis, including the white background's ID
papilio_adj <- adjacent(papilio_class,
xscale = 100, bkgID = 1,
coldists = distances, hsl = hsl_vals
)
# Run an adjacency analysis on multiple images.
# First load some images of coral snake colour patterns
snakes <- getimg(system.file("testdata/images/snakes", package = "pavo"))
# Automatically colour-classify the coral snake patterns
snakes_class <- classify(snakes, kcols = 3)
# Run the adjacency analysis, with varying real-world scales for each image
snakes_adj <- adjacent(snakes_class, xpts = 120, xscale = c(50, 55))
# }
Run the code above in your browser using DataLab