Title: | Turn Images into Data Sets |
---|---|
Description: | The goal of 'image2data' is to extract images and return them into a data set, especially for teaching data manipulation and data visualization. Basically, the eponymous function takes an image file ('png', 'tiff', 'jpeg', 'bmp') and turn it into a data set, pixels being rows (subjects) and columns (variables) being their coordinate positions (x- and y-axis) and their respective color (in hex codes). The function can return a complete image or a range of color (i.e., contour, silhouette). The data can then be manipulated as would any data set by either creating other related variables (to hide the image) or as a genuine toy data set. |
Authors: | P.-O. Caron [aut, cre, cph] |
Maintainer: | P.-O. Caron <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2025-02-03 02:37:42 UTC |
Source: | https://github.com/quantmeth/image2data |
Extract an image file ("png", "tiff", "jpeg", "bmp"
) and turn it into an enjoyable data set, pixels being rows (subjects) and columns (variables) being their coordinate positions (x and y axis) and their respective color (in hex codes).
image2data( path, type = "fill", scaling = "standardized", showplot = TRUE, reduce = 1, A = 1, R = c(0, 0.05), G = c(0, 0.05), B = c(0, 0.05), Grey = NULL, precision = 1, seed = NULL )
image2data( path, type = "fill", scaling = "standardized", showplot = TRUE, reduce = 1, A = 1, R = c(0, 0.05), G = c(0, 0.05), B = c(0, 0.05), Grey = NULL, precision = 1, seed = NULL )
path |
Path to image file. |
type |
Type of extraction of data. |
scaling |
Tranform the data to a specified scale. Three options are available : |
showplot |
Show a preliminary plot of the data (default is |
reduce |
|
A |
Transparency, otherwise known as |
R , G , B
|
Color to return with |
Grey |
Grey range to be returned with |
precision |
Set precision of |
seed |
Set seed value for random pixel returned with |
A data frame with pixels as rows and columns are x and y coordinates and g is their color in hex (factors).
path <- system.file(file.path("extdata", "success.png"), package = "image2data") image2data(path = path, type = "line") image2data(path = path, type = "line", Grey = c(0,.50)) ## Not run: image2data(path = file.choose()) ## End(Not run)
path <- system.file(file.path("extdata", "success.png"), package = "image2data") image2data(path = path, type = "line") image2data(path = path, type = "line", Grey = c(0,.50)) ## Not run: image2data(path = file.choose()) ## End(Not run)