Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hue (HSV) based snow flagging #28

Open
khufkens opened this issue Mar 5, 2020 · 2 comments
Open

Hue (HSV) based snow flagging #28

khufkens opened this issue Mar 5, 2020 · 2 comments

Comments

@khufkens
Copy link
Member

khufkens commented Mar 5, 2020

A Hue based filter performs well in finding images with snow and cloud contamination, even on average daily values across an ROI (no image processing needed).

# HSV based snow flagging
library(phenocamr)
library(tidyverse)

if(!file.exists(file.path(tempdir(),"chibougamau_EN_1000_1day.csv"))){
  download_phenocam(site = "chibougamau",
                    out_dir = tempdir(),
                    frequency = 1,
                    roi_id = 1000)
}

# read data
df <- read.table(file.path(tempdir(),"chibougamau_EN_1000_1day.csv"),
                 sep = ",",
                 header = TRUE,
                 stringsAsFactors = FALSE)

df <- df %>% filter(!is.na(r_mean))

hsv <- rgb2hsv(df$r_mean, df$g_mean, df$b_mean)

df$snow_flag <- ifelse(hsv[1,] > 0.55 & hsv[1,] < 0.97,"snow","no snow")

p <- ggplot(df) +
  geom_point(aes(as.Date(date), gcc_90, col = as.factor(snow_flag))) +
  theme_minimal()

print(p)

snow_flags

@khufkens khufkens changed the title HSV based snow flagging Hue (HSV) based snow flagging Mar 5, 2020
@khufkens
Copy link
Member Author

khufkens commented Mar 5, 2020

A similar test for bartlettir renders no false positives, although the background has snow the trunks limit blue tints and don't trigger flagging. The reverse is true with evergreens which covered with snow turn blue-ish and trigger the snow flagging thresholds on the hue values.

bartlettir

# HSV based snow flagging
library(phenocamr)
library(tidyverse)

if(!file.exists(file.path(tempdir(),"bartlettir_DB_1000_1day.csv"))){
  download_phenocam(site = "bartlettir",
                    out_dir = tempdir(),
                    frequency = 1,
                    roi_id = 1000)
}

# read data
df <- read.table(file.path(tempdir(),"bartlettir_DB_1000_1day.csv"),
                 sep = ",",
                 header = TRUE,
                 stringsAsFactors = FALSE)

df <- df %>% filter(!is.na(r_mean))

hsv <- rgb2hsv(df$r_mean, df$g_mean, df$b_mean)

df$snow_flag <- ifelse(hsv[1,] > 0.55 & hsv[1,] < 0.97,"snow","no snow")

p <- ggplot(df) +
  geom_point(aes(as.Date(date), gcc_90, col = as.factor(snow_flag))) +
  theme_minimal()

print(p)

@khufkens
Copy link
Member Author

khufkens commented Mar 5, 2020

The same goes for detecting snow on ground, if nothing else is in the way. So for agricultural fields it allows you to detect snow on the ground (since the signal isn't contaminated by stems).

arsmorris1

# HSV based snow flagging
library(phenocamr)
library(tidyverse)

if(!file.exists(file.path(tempdir(),"arsmorris1_AG_1000_1day.csv"))){
  download_phenocam(site = "arsmorris1",
                    out_dir = tempdir(),
                    frequency = 1,
                    roi_id = 1000)
}

# read data
df <- read.table(file.path(tempdir(),"arsmorris1_AG_1000_1day.csv"),
                 sep = ",",
                 header = TRUE,
                 stringsAsFactors = FALSE)

df <- df %>% filter(!is.na(r_mean))

hsv <- rgb2hsv(df$r_mean, df$g_mean, df$b_mean)

df$snow_flag <- ifelse(hsv[1,] > 0.55 & hsv[1,] < 0.97,"snow","no snow")

p <- ggplot(df) +
  geom_point(aes(as.Date(date), gcc_90, col = as.factor(snow_flag))) +
  theme_minimal()

print(p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant