Skip to content

Commit

Permalink
Update hz-morph-supercells.R
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Oct 16, 2024
1 parent dad4b70 commit 6f33dd0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions misc/sandbox/supercells/hz-morph-supercells.R
Original file line number Diff line number Diff line change
@@ -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?

Expand Down

0 comments on commit 6f33dd0

Please sign in to comment.