From 6f33dd098e8b27e90e1a8236c1683cb5dd3d4f2b Mon Sep 17 00:00:00 2001 From: Beaudette Date: Wed, 16 Oct 2024 14:06:36 -0700 Subject: [PATCH] Update hz-morph-supercells.R --- misc/sandbox/supercells/hz-morph-supercells.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/misc/sandbox/supercells/hz-morph-supercells.R b/misc/sandbox/supercells/hz-morph-supercells.R index 2530ec262..99d43064f 100644 --- a/misc/sandbox/supercells/hz-morph-supercells.R +++ b/misc/sandbox/supercells/hz-morph-supercells.R @@ -1,24 +1,26 @@ # https://jakubnowosad.com/supercells/ -library(terra) +library(supercells) library(aqp) +library(terra) library(sf) -library(supercells) + x <- rast('leaf-john-kelley.jpg') s <- supercells(x, k = 7, compactness = 30, transform = 'to_LAB', verbose = 2, avg_fun = median) +s <- vect(s) plotRGB(x) -plot(st_geometry(s), add = TRUE, border = 'yellow') +lines(s, col = 'yellow') cols <- rgb(s$leaf.john.kelley_1, s$leaf.john.kelley_2, s$leaf.john.kelley_3, maxColorValue = 255) par(mfcol = c(1, 2)) plotRGB(x, mar = c(0, 0, 0, 0)) -par(mar = c(0, 0, 0, 0)) -plot(st_geometry(s), col = cols, border = NA) +plot(s, col = cols, border = 'white', mar = c(0, 0, 0, 0), axes = FALSE) -m <- rgb2munsell(cbind(s$leaf.john.kelley_1, s$leaf.john.kelley_2, s$leaf.john.kelley_3) / 255) +m <- col2Munsell(cbind(s$leaf.john.kelley_1, s$leaf.john.kelley_2, s$leaf.john.kelley_3)) +m # question: does avg_fun work on transformed or original values?