# NOT RUN {
# Import a jpeg or png
demo_file <- system.file("extdata", "demo_img.jpg",
package = "brickr", mustWork = TRUE)
demo_image <- jpeg::readJPEG(demo_file)
#Create a 24x24 mosaic
# }
# NOT RUN {
demo_image %>%
image_to_mosaic(img_size = 24) %>%
build_mosaic()
# }
# NOT RUN {
#Only use the two more common tiers of colors
# }
# NOT RUN {
demo_image %>%
image_to_mosaic(img_size = 24,
color_palette = c("universal", "generic")) %>%
build_mosaic()
# }
# NOT RUN {
#Be more prescriptive with colors using 'color_table'.
# Here, we prevent all blues from being used
lego_colors_no_blue = lego_colors %>%
dplyr::filter(!grepl("[Bb]lue|[Aa]zur", Color))
# }
# NOT RUN {
demo_image %>%
image_to_mosaic(img_size = 24,
color_table = lego_colors_no_blue) %>%
build_mosaic()
# }
# NOT RUN {
#Color matching is done with the 'farver' package. There are different method.
# Change the method to euclidean (RGB distance matching)
# }
# NOT RUN {
demo_image %>%
image_to_mosaic(img_size = 24,
method = "euclidean") %>%
build_mosaic()
# }
# NOT RUN {
#Change the default size of bricks to use.
# In this extreme example, use 4x6s for the background, 1x1 everywhere else
# }
# NOT RUN {
demo_image %>%
image_to_mosaic(img_size = 24,
use_bricks = c("4x6")) %>%
build_mosaic()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab