Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/javierluraschi/pixels
Tools for Working with Pixels in R
https://github.com/javierluraschi/pixels
Last synced: about 1 month ago
JSON representation
Tools for Working with Pixels in R
- Host: GitHub
- URL: https://github.com/javierluraschi/pixels
- Owner: javierluraschi
- License: other
- Created: 2017-10-20T00:57:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-03T21:56:16.000Z (about 4 years ago)
- Last Synced: 2023-11-20T16:20:33.662Z (about 1 year ago)
- Language: R
- Homepage:
- Size: 488 KB
- Stars: 30
- Watchers: 4
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - pixels - HTML widget and Shiny Gadget to render and draw pixels. (UI Components / Image / Audio / Video)
README
---
title: "Tools for Working with Pixels in R"
output:
github_document:
fig_width: 9
fig_height: 5
---[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/pixels)](https://cran.r-project.org/package=pixels)
This package provides an [htmlwidget](http://www.htmlwidgets.org/) and [Shiny Gadget](https://shiny.rstudio.com/articles/gadgets.html) to render and draw
pixels with ease.To draw pixels run `get_pixels()` which will start the gadget to
retrieve an array of numeric values representing each pixel in the image:```{r eval=FALSE}
library(pixels)
get_pixels()
```To display pixels, use `show_pixels()` with a row-first vector as
follows:```{r eval=FALSE}
show_pixels(
round(runif(400, 0, 1)),
grid = c(40, 10),
size = c(800, 200),
params = list(fill = list(color = "#FF3388"))
)
```Finally, one can use 'shiny_render_pixels()' with a 'Shiny' application to help
collect image datasets. For instance, to collect images similar to the MNIST
dataset as follows:```{r eval=FALSE}
library(shiny)ui <- fluidPage(
tags$head(
tags$style(HTML("
#pixels {
height: 270px !important;
margin-top: 10px;
}
"))
),
titlePanel("Digit Capture Application"),
textOutput("prompt"),
shiny_pixels_output("pixels"),
actionButton("captureDigit", "Capture")
)server <- function(input, output) {
output$pixels <- shiny_render_pixels(
show_pixels()
)
digit <- reactiveVal(floor(runif(1, 1, 10)))
output$prompt <- renderText(paste0("Please draw number ", digit(), ":"))
observeEvent(input$captureDigit, {
digit_path <- file.path("digits", digit())
if (!dir.exists(digit_path)) dir.create(digit_path, recursive = TRUE)
saveRDS(input$pixels, paste0(digit_path, "/", as.numeric(Sys.time()), ".rds"))
digit(floor(runif(1, 1, 10)))
output$pixels <- shiny_render_pixels(
show_pixels()
)
})
}shinyApp(ui = ui, server = server)
```