Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmi3kno/bunny
Magick Helper
https://github.com/dmi3kno/bunny
Last synced: 3 months ago
JSON representation
Magick Helper
- Host: GitHub
- URL: https://github.com/dmi3kno/bunny
- Owner: dmi3kno
- License: other
- Created: 2019-07-26T23:03:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T11:15:07.000Z (about 2 years ago)
- Last Synced: 2024-08-03T21:03:28.737Z (6 months ago)
- Language: R
- Size: 2.16 MB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome-r-dataviz - bunny - Useful helper functions for working with magick. (Drawing & Rendering / Miscellaneous)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "20%"
)
```
# bunny[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
The goal of `bunny` is to provide useful helper functions for working with `magick`.
## Installation
You can install the released version of bunny from [Github](https://www.github.com) with:
``` r
#install.packages("bunny") # not yet
remotes::install_github("dmi3kno/bunny")
```## Pixel operations
This is a basic example which shows you how to solve a common problem:
```{r example, message=FALSE}
library(magick)
library(bunny)## basic example code
frink <- image_read("https://jeroen.github.io/images/frink.png")
image_getpixel(frink, geometry_point(100,100))
```Other than extracting color from individual pixels, `bunny` can also draw on images:
```{r, fig.height=5}
frink <- image_read("https://jeroen.github.io/images/frink.png")
image_plot(frink, geometry_area(50,35,80,150), "red")
image_plot(frink, geometry_point(70,70), "red")
```## Hough lines operations
`bunny` can help you tidy up the Hough Lines mvg object, returned by `magick::image_hough_txt()`. Lets detect straight lines in the `bunny` logo.
```{r}
img <- image_read("data-raw/bunny_hex.png")img_prep <- img %>% image_convert(type="Grayscale") %>%
image_threshold("black") %>%
image_canny() %>%
image_morphology("Close", "Diamond")img_prep %>%
image_hough_draw(geometry="50x50+200",overlay = TRUE)
```Hough Lines are retuned in plain text object (`mvg` format). Let's tidy up that text and make it more suitable for analysis. `bunny::tidy_hough_mvg()` returns a list, which, among other things contains data frame describing lines and another data frame describing line intersections.
```{r}
hough <- img_prep %>%
image_hough_txt(geometry="50x50+200") %>%
tidy_hough_mvg()hough$lines_data
hough$xsect_data
```Stay tuned for more exciting functions...