image_to_magiceye: Convert a 2D image to a 3D autostereogram

Description Usage Arguments Value Examples

View source: R/magiceye.R

Description

Convert a 2D greyscale image to a 3D autostereogram. Set dot colors used in final image.

Usage

1
image_to_magiceye(image, colors = c("#00436b", "#ffed89"), alpha_only = F)

Arguments

image

Matrix image, usually from png::readPNG() or jpeg::readJPEG().

colors

Array of at least 2 color hex codes. Colors should be visually distinct and avoid using too many.

alpha_only

Logical. Set to TRUE to only consider alpha channel of a png when rendering image.

Value

A raster matrix for plot().

Examples

1
2
3
4
5
6
7
8
# Import a jpeg or png
 demo_file <- system.file("extdata", "demo_r.png",
                          package = "rstereogram", mustWork = TRUE)
 demo_image <- png::readPNG(demo_file)

 demo_image %>%
    image_to_magiceye() %>%
    plot()

ryantimpe/MagicEye documentation built on April 12, 2021, 5:59 p.m.