Skip to content

Commit

Permalink
added the lut readers
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Feb 19, 2018
1 parent fcdf814 commit ffa6fcc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

export(sri24_image_df)
export(sri24_images)
export(sri24_label_df)
export(sri24_label_list)
46 changes: 46 additions & 0 deletions R/sri24_label_list.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

#' SRI24 Label Look Up Tables (LUT)
#'
#' @param label The specific label LUT to read in
#'
#' @return A list of \code{data.frame}s or a specific \code{data.frame}
#' @export
#'
#' @examples
#' sri24_label_list()
#' sri24_label_df()
#' sri24_label_df("LPBA40")
sri24_label_list = function() {
lab_file = system.file("extdata", "SRI24-tzo116plus.txt", package = "sri24")
lab_file = readLines(lab_file)
lab_file = gsub(" \\s+", " ", lab_file)
lab_file = gsub(" ", "\t", lab_file)
tfile = tempfile(fileext = ".txt")
writeLines(lab_file, tfile)
tab = read.table(file = tfile, header = FALSE, as.is = TRUE)
colnames(tab) = c("index", "label", "R", "G", "B", "A")
L = list()
L$`TZO` = tab

lab_file = system.file("extdata", "LPBA40-labels.txt", package = "sri24")
lab_file = readLines(lab_file)
lab_file = gsub(" \\s+", " ", lab_file)
lab_file = gsub(" ", "\t", lab_file)
tfile = tempfile(fileext = ".txt")
writeLines(lab_file, tfile)
tab = read.table(file = tfile, header = FALSE, as.is = TRUE)
colnames(tab) = c("index", "label", "R", "G", "B", "A")

L$`LPBA40` = tab

return(L)
}


#' @rdname sri24_label_list
#' @export
sri24_label_df = function(label = c("TZO", "LPBA40")) {
label = match.arg(label)
L = sri24_label_list()
L[[label]]
}
25 changes: 25 additions & 0 deletions man/sri24_label_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ffa6fcc

Please sign in to comment.