Title: | Extract Color Palettes from Photos and Pick Official LTER Palettes |
---|---|
Description: | Allows identification of palettes derived from LTER (Long Term Ecological Research) photographs based on user criteria. Also facilitates extraction of palettes from users' photos directly. |
Authors: | Nicholas J Lyon [aut, cre] , Gabe De La Rosa [ctb], Julien Brun [ctb] , National Science Foundation [fnd] (NSF 1929393, 09/01/2019 - 08/31/2024), University of California, Santa Barbara [cph] |
Maintainer: | Nicholas J Lyon <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 1.1.0.900 |
Built: | 2024-10-25 05:32:50 UTC |
Source: | https://github.com/lter/lterpalettefinder |
Accepts the hexadecimal code vector and tests if it is formatted correctly
palette_check(palette)
palette_check(palette)
palette |
(character) Vector of hexadecimal codes returned by 'palette_extract()', '..._sort()', or '..._subsample()' |
An error message or nothing
# Check for misformatted hexcodes palette_check(palette = c("#8e847a", "#9fc7f2"))
# Check for misformatted hexcodes palette_check(palette = c("#8e847a", "#9fc7f2"))
Accepts the hexadecimal code vector returned by 'palette_extract()', '..._sort()', or '..._subsample()' and creates a base plot of all returned colors labeled with their HEX codes. This will facilitate (hopefully) your selection of which of the 25 colors you would like to use in a given context.
palette_demo( palette, export = FALSE, export_name = "my_palette", export_path = getwd() )
palette_demo( palette, export = FALSE, export_name = "my_palette", export_path = getwd() )
palette |
(character) Vector of hexadecimal codes like that returned by 'palette_extract()', '..._sort()', or '..._subsample()' |
export |
(logical) Whether or not to export the demo plot |
export_name |
(character) Name for exported plot |
export_path |
(character) File path to save exported plot (defaults to working directory) |
A plot of the retrieved colors labeled with their HEX codes
# Extract colors from a supplied image my_colors <- palette_extract( image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder") ) # Plot that result palette_demo(palette = my_colors)
# Extract colors from a supplied image my_colors <- palette_extract( image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder") ) # Plot that result palette_demo(palette = my_colors)
Retrieves hexadecimal codes for the colors in an image file. Currently only PNG, JPEG, TIFF, and HEIC files are supported. The function automatically removes dark colors and removes 'similar' colors to yield 25 colors from which you can select the subset that works best for your visualization needs. Note that photos that are very dark may return few viable colors.
palette_extract(image, sort = FALSE, progress_bar = TRUE)
palette_extract(image, sort = FALSE, progress_bar = TRUE)
image |
(character) Name/path to PNG, JPEG, TIFF, or HEIC file from which to extract colors |
sort |
(logical) Whether extracted HEX codes should be sorted by hue and saturation |
progress_bar |
(logical) Whether to 'message' a progress bar |
(character) Vector containing all hexadecimal codes remaining after extraction and removal of 'dark' and 'similar' colors
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder"), sort = TRUE, progress_bar = FALSE) # Plot that result palette_demo(palette = my_colors)
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder"), sort = TRUE, progress_bar = FALSE) # Plot that result palette_demo(palette = my_colors)
From a dataframe of all possible palettes (updated periodically so check back!) specify the characteristics of the palette you want and retrieve the palettes that match those criteria. Can specify by number of colors in the palette, type of palette (e.g., qualitative, sequential, etc.), or which LTER site the palette came from.
palette_find(site = "all", name = "all", type = "all")
palette_find(site = "all", name = "all", type = "all")
site |
(character) Vector of three-letter LTER site abbreviations for which to return palettes or "all" or "LTER" for the LTER logo colors |
name |
(character) Vector of palette names (if known) for which to return palettes |
type |
(character) Vector of palette types (i.e., qualitative, tricolor, sequential, or diverging) for which to return palettes |
(dataframe / character) If more than one palette, a dataframe is returned; if exactly one palette, a character vector is returned
# Look at all palette options by calling the function without specifying arguments lterpalettefinder::palette_find() # What if our query returns NO options? palette_find(name = "no such name") # What if our query returns MULTIPLE options? palette_find(site = "sbc") # What if our query returns JUST ONE option? (this is desirable) palette_find(name = "salamander")
# Look at all palette options by calling the function without specifying arguments lterpalettefinder::palette_find() # What if our query returns NO options? palette_find(name = "no such name") # What if our query returns MULTIPLE options? palette_find(site = "sbc") # What if our query returns JUST ONE option? (this is desirable) palette_find(name = "salamander")
Accepts the hexadecimal code vector returned by 'palette_extract()', '..._sort()', or '..._subsample()' and creates a simple plot of all returned colors labeled with their HEX codes. This will facilitate (hopefully) your selection of which of the 25 colors you would like to use in a given context.
palette_ggdemo(palette)
palette_ggdemo(palette)
palette |
(character) Vector of hexadecimal codes returned by 'palette_extract()', '..._sort()', or '..._subsample()' |
A ggplot2 plot
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_ggdemo(palette = my_colors)
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_ggdemo(palette = my_colors)
For each palette, data includes the photographer, LTER site, number of included colors, and the hexadecimal codes for each color (data are in 'wide' format)
palette_options
palette_options
A dataframe with 14 variables and one row per palette (currently 14 rows)
name of the photographer who took the picture
concatenation of LTER site and palette name, separated by a hyphen
three-letter LTER site name abbreviation
a unique-within site-name for each palette based on the picture's content
either "qualitative", "sequential", or "diverging" depending on the pattern of colors in the palette
the hexadecimal code for colors 1 through n for each palette
Lyon, N. J., De La Rosa, G. 2022.
Sorts hexademical codes retrieved by ‘palette_extract()' by hue and saturation. This allows for reasonably good identification of ’similar' colors in the way that a human eye would perceive them (as opposed to a computer's representation of colors).
palette_sort(palette)
palette_sort(palette)
palette |
(character) Vector returned by 'palette_extract()' |
(character) Vector containing all hexadecimal codes returned by 'palette_extract()'
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_demo(palette = my_colors) # Now sort sort_colors <- palette_sort(palette = my_colors) # And plot again to show change palette_demo(palette = sort_colors)
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_demo(palette = my_colors) # Now sort sort_colors <- palette_sort(palette = my_colors) # And plot again to show change palette_demo(palette = sort_colors)
Randomly subsample the HEX codes returned by 'palette_extract()' or 'palette_sort()' to desired length. Can also set random seed for reproducibility.
palette_subsample(palette, wanted = 5, random_seed = 36)
palette_subsample(palette, wanted = 5, random_seed = 36)
palette |
(character) Vector of hexadecimal codes like those returned by 'palette_extract()' or 'palette_sort()' |
wanted |
(numeric) Integer for how many colors should be returned |
random_seed |
(numeric) Integer for 'base::set.seed()' |
(character) Vector of hexadecimal codes of user-specified length
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_ggdemo(palette = my_colors) # Now randomly subsample random_colors <- palette_subsample(palette = my_colors, wanted = 5) # And plot again to show change palette_ggdemo(palette = random_colors)
# Extract colors from a supplied image my_colors <- palette_extract(image = system.file("extdata", "lyon-fire.png", package = "lterpalettefinder")) # Plot that result palette_ggdemo(palette = my_colors) # Now randomly subsample random_colors <- palette_subsample(palette = my_colors, wanted = 5) # And plot again to show change palette_ggdemo(palette = random_colors)