diff --git a/DESCRIPTION b/DESCRIPTION
index 32b9511..de212eb 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -40,6 +40,6 @@ Suggests:
tesseract (>= 2.0),
gifski
Encoding: UTF-8
-RoxygenNote: 7.2.3
+RoxygenNote: 7.3.0
Roxygen: list(load = "installed", markdown = TRUE)
Language: en-US
diff --git a/NEWS b/NEWS
index eb7d9ac..4d8ddcd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+2.8.3
+ - Switch to base-R pipe in examples and vignette
+
2.8.2
- Fix image_draw() for small images: #317
- Change image_shadow() to transparent background by default
diff --git a/R/edges.R b/R/edges.R
index 971ea53..3ebeebf 100644
--- a/R/edges.R
+++ b/R/edges.R
@@ -22,8 +22,8 @@
#' @examples if(magick_config()$version > "6.8.9"){
#' shape <- demo_image("shape_rectangle.gif")
#' rectangle <- image_canny(shape)
-#' rectangle %>% image_hough_draw('5x5+20')
-#' rectangle %>% image_hough_txt(format = 'svg') %>% cat()
+#' rectangle |> image_hough_draw('5x5+20')
+#' rectangle |> image_hough_txt(format = 'svg') |> cat()
#' }
image_edge <- function(image, radius = 1){
assert_image(image)
diff --git a/R/morphology.R b/R/morphology.R
index 59e5a63..d67d4d5 100644
--- a/R/morphology.R
+++ b/R/morphology.R
@@ -14,38 +14,38 @@
#' @family image
#' @examples #example from IM website:
#' if(magick_config()$version > "6.8.8"){
-#' pixel <- image_blank(1, 1, 'white') %>% image_border('black', '5x5')
+#' pixel <- image_blank(1, 1, 'white') |> image_border('black', '5x5')
#'
#' # See the effect of Dilate method
-#' pixel %>% image_scale('800%')
-#' pixel %>% image_morphology('Dilate', "Diamond") %>% image_scale('800%')
+#' pixel |> image_scale('800%')
+#' pixel |> image_morphology('Dilate', "Diamond") |> image_scale('800%')
#'
#' # These produce the same output:
-#' pixel %>% image_morphology('Dilate', "Diamond", iter = 3) %>% image_scale('800%')
-#' pixel %>% image_morphology('Dilate', "Diamond:3") %>% image_scale('800%')
+#' pixel |> image_morphology('Dilate', "Diamond", iter = 3) |> image_scale('800%')
+#' pixel |> image_morphology('Dilate', "Diamond:3") |> image_scale('800%')
#'
#' # Plus example
-#' pixel %>% image_morphology('Dilate', "Plus", iterations = 2) %>% image_scale('800%')
+#' pixel |> image_morphology('Dilate', "Plus", iterations = 2) |> image_scale('800%')
#'
#' # Rose examples
-#' rose %>% image_morphology('ErodeI', 'Octagon', iter = 3)
-#' rose %>% image_morphology('DilateI', 'Octagon', iter = 3)
-#' rose %>% image_morphology('OpenI', 'Octagon', iter = 3)
-#' rose %>% image_morphology('CloseI', 'Octagon', iter = 3)
+#' rose |> image_morphology('ErodeI', 'Octagon', iter = 3)
+#' rose |> image_morphology('DilateI', 'Octagon', iter = 3)
+#' rose |> image_morphology('OpenI', 'Octagon', iter = 3)
+#' rose |> image_morphology('CloseI', 'Octagon', iter = 3)
#'
#' # Edge detection
#' man <- demo_image('man.gif')
-#' man %>% image_morphology('EdgeIn', 'Octagon')
-#' man %>% image_morphology('EdgeOut', 'Octagon')
-#' man %>% image_morphology('Edge', 'Octagon')
+#' man |> image_morphology('EdgeIn', 'Octagon')
+#' man |> image_morphology('EdgeOut', 'Octagon')
+#' man |> image_morphology('Edge', 'Octagon')
#'
#' # Octagonal Convex Hull
-#' man %>%
-#' image_morphology('Close', 'Diamond') %>%
+#' man |>
+#' image_morphology('Close', 'Diamond') |>
#' image_morphology('Thicken', 'ConvexHull', iterations = 1)
#'
#' # Thinning down to a Skeleton
-#' man %>% image_morphology('Thinning', 'Skeleton', iterations = 1)
+#' man |> image_morphology('Thinning', 'Skeleton', iterations = 1)
#'
#' # Specify custom kernel matrix usingn a string:
#' img <- demo_image("test_mag.gif")
diff --git a/R/segmentation.R b/R/segmentation.R
index 92c7ffb..e5d265f 100644
--- a/R/segmentation.R
+++ b/R/segmentation.R
@@ -32,15 +32,15 @@
#' \donttest{
#' # Split image in blobs of connected pixel levels
#' if(magick_config()$version > "6.9.0"){
-#' objects %>%
-#' image_connect(connectivity = 4) %>%
+#' objects |>
+#' image_connect(connectivity = 4) |>
#' image_split()
#'
#' # Fuzzy c-means
#' image_fuzzycmeans(logo)
#'
-#' logo %>%
-#' image_convert(colorspace = "HCL") %>%
+#' logo |>
+#' image_convert(colorspace = "HCL") |>
#' image_fuzzycmeans(smoothing = 5)
#' }
#' }
diff --git a/R/threshold.R b/R/threshold.R
index 0c7eff0..44188fa 100644
--- a/R/threshold.R
+++ b/R/threshold.R
@@ -24,8 +24,8 @@
#' image_threshold(test, type = "white", threshold = "50%")
#'
#' # Turn image into BW
-#' test %>%
-#' image_threshold(type = "white", threshold = "50%") %>%
+#' test |>
+#' image_threshold(type = "white", threshold = "50%") |>
#' image_threshold(type = "black", threshold = "50%")
#'
#' # adaptive thresholding
diff --git a/README.md b/README.md
index ae7f9bc..c70a272 100644
--- a/README.md
+++ b/README.md
@@ -42,14 +42,14 @@ image_scale(frink, "200x200")
image_flip(frink)
image_rotate(frink, 45) ## <-- result of this is shown
image_negate(frink)
-frink %>%
- image_background("green") %>%
- image_flatten() %>%
+frink |>
+ image_background("green") |>
+ image_flatten() |>
image_border("red", "10x10")
```
```r
-image_rotate(frink, 45) %>% image_write("man/figures/frink-rotated.png")
+image_rotate(frink, 45) |> image_write("man/figures/frink-rotated.png")
```
![](man/figures/frink-rotated.png)
@@ -65,7 +65,7 @@ image_edge(frink)
```
```r
-image_charcoal(frink) %>% image_write("man/figures/frink-charcoal.png")
+image_charcoal(frink) |> image_write("man/figures/frink-charcoal.png")
```
![](man/figures/frink-charcoal.png)
diff --git a/man/edges.Rd b/man/edges.Rd
index fe6c2e4..09dcc0c 100644
--- a/man/edges.Rd
+++ b/man/edges.Rd
@@ -56,8 +56,8 @@ available at the \href{https://legacy.imagemagick.org/Usage/transform/}{imagemag
if(magick_config()$version > "6.8.9"){
shape <- demo_image("shape_rectangle.gif")
rectangle <- image_canny(shape)
-rectangle \%>\% image_hough_draw('5x5+20')
-rectangle \%>\% image_hough_txt(format = 'svg') \%>\% cat()
+rectangle |> image_hough_draw('5x5+20')
+rectangle |> image_hough_txt(format = 'svg') |> cat()
}
}
\seealso{
diff --git a/man/morphology.Rd b/man/morphology.Rd
index 8e35919..f0d04f8 100644
--- a/man/morphology.Rd
+++ b/man/morphology.Rd
@@ -49,38 +49,38 @@ for examples.
\examples{
#example from IM website:
if(magick_config()$version > "6.8.8"){
-pixel <- image_blank(1, 1, 'white') \%>\% image_border('black', '5x5')
+pixel <- image_blank(1, 1, 'white') |> image_border('black', '5x5')
# See the effect of Dilate method
-pixel \%>\% image_scale('800\%')
-pixel \%>\% image_morphology('Dilate', "Diamond") \%>\% image_scale('800\%')
+pixel |> image_scale('800\%')
+pixel |> image_morphology('Dilate', "Diamond") |> image_scale('800\%')
# These produce the same output:
-pixel \%>\% image_morphology('Dilate', "Diamond", iter = 3) \%>\% image_scale('800\%')
-pixel \%>\% image_morphology('Dilate', "Diamond:3") \%>\% image_scale('800\%')
+pixel |> image_morphology('Dilate', "Diamond", iter = 3) |> image_scale('800\%')
+pixel |> image_morphology('Dilate', "Diamond:3") |> image_scale('800\%')
# Plus example
-pixel \%>\% image_morphology('Dilate', "Plus", iterations = 2) \%>\% image_scale('800\%')
+pixel |> image_morphology('Dilate', "Plus", iterations = 2) |> image_scale('800\%')
# Rose examples
-rose \%>\% image_morphology('ErodeI', 'Octagon', iter = 3)
-rose \%>\% image_morphology('DilateI', 'Octagon', iter = 3)
-rose \%>\% image_morphology('OpenI', 'Octagon', iter = 3)
-rose \%>\% image_morphology('CloseI', 'Octagon', iter = 3)
+rose |> image_morphology('ErodeI', 'Octagon', iter = 3)
+rose |> image_morphology('DilateI', 'Octagon', iter = 3)
+rose |> image_morphology('OpenI', 'Octagon', iter = 3)
+rose |> image_morphology('CloseI', 'Octagon', iter = 3)
# Edge detection
man <- demo_image('man.gif')
-man \%>\% image_morphology('EdgeIn', 'Octagon')
-man \%>\% image_morphology('EdgeOut', 'Octagon')
-man \%>\% image_morphology('Edge', 'Octagon')
+man |> image_morphology('EdgeIn', 'Octagon')
+man |> image_morphology('EdgeOut', 'Octagon')
+man |> image_morphology('Edge', 'Octagon')
# Octagonal Convex Hull
- man \%>\%
- image_morphology('Close', 'Diamond') \%>\%
+ man |>
+ image_morphology('Close', 'Diamond') |>
image_morphology('Thicken', 'ConvexHull', iterations = 1)
# Thinning down to a Skeleton
-man \%>\% image_morphology('Thinning', 'Skeleton', iterations = 1)
+man |> image_morphology('Thinning', 'Skeleton', iterations = 1)
# Specify custom kernel matrix usingn a string:
img <- demo_image("test_mag.gif")
diff --git a/man/segmentation.Rd b/man/segmentation.Rd
index b8cd523..0595a6a 100644
--- a/man/segmentation.Rd
+++ b/man/segmentation.Rd
@@ -55,15 +55,15 @@ objects
\donttest{
# Split image in blobs of connected pixel levels
if(magick_config()$version > "6.9.0"){
-objects \%>\%
- image_connect(connectivity = 4) \%>\%
+objects |>
+ image_connect(connectivity = 4) |>
image_split()
# Fuzzy c-means
image_fuzzycmeans(logo)
-logo \%>\%
- image_convert(colorspace = "HCL") \%>\%
+logo |>
+ image_convert(colorspace = "HCL") |>
image_fuzzycmeans(smoothing = 5)
}
}
diff --git a/man/thresholding.Rd b/man/thresholding.Rd
index f1581d5..bf53565 100644
--- a/man/thresholding.Rd
+++ b/man/thresholding.Rd
@@ -62,8 +62,8 @@ image_threshold(test, type = "black", threshold = "50\%")
image_threshold(test, type = "white", threshold = "50\%")
# Turn image into BW
-test \%>\%
- image_threshold(type = "white", threshold = "50\%") \%>\%
+test |>
+ image_threshold(type = "white", threshold = "50\%") |>
image_threshold(type = "black", threshold = "50\%")
# adaptive thresholding
diff --git a/vignettes/intro.Rmd b/vignettes/intro.Rmd
index 3ffd0fc..b2efa47 100644
--- a/vignettes/intro.Rmd
+++ b/vignettes/intro.Rmd
@@ -103,14 +103,7 @@ Note that size is currently 0 because ImageMagick is lazy (in the good sense) an
IDE's with a built-in web browser (such as RStudio) automatically display magick images in the viewer. This results in a neat interactive image editing environment.
-
-
+
Alternatively, on Linux you can use `image_display` to preview the image in an X11 window. Finally `image_browse` opens the image in your system's default application for a given type.
@@ -215,8 +208,8 @@ image_append(c(img, img_blurred))
Or use any of the [standard kernels](https://legacy.imagemagick.org/Usage/convolve/)
```{r}
-img %>% image_convolve('Sobel') %>% image_negate()
-img %>% image_convolve('DoG:0,0,2') %>% image_negate()
+img |> image_convolve('Sobel') |> image_negate()
+img |> image_convolve('DoG:0,0,2') |> image_negate()
```
### Text annotation
@@ -258,13 +251,13 @@ test <- image_annotate(test, "This is how we combine transformations", color = "
print(test)
```
-Using `magrittr` pipe syntax makes it a bit more readable
+Using pipe syntax makes it a bit more readable
```{r}
-image_read("https://jeroen.github.io/images/frink.png") %>%
- image_rotate(270) %>%
- image_background("blue", flatten = TRUE) %>%
- image_border("red", "10x10") %>%
+image_read("https://jeroen.github.io/images/frink.png") |>
+ image_rotate(270) |>
+ image_background("blue", flatten = TRUE) |>
+ image_border("red", "10x10") |>
image_annotate("The same thing with pipes", color = "white", size = 30)
```
@@ -277,16 +270,16 @@ The standard base methods `[` `[[`, `c()` and `length()` are used to manipulate
```{r}
# Download earth gif and make it a bit smaller for vignette
-earth <- image_read("https://jeroen.github.io/images/earth.gif") %>%
- image_scale("200x") %>%
+earth <- image_read("https://jeroen.github.io/images/earth.gif") |>
+ image_scale("200x") |>
image_quantize(128)
length(earth)
earth
head(image_info(earth))
-rev(earth) %>%
- image_flip() %>%
+rev(earth) |>
+ image_flip() |>
image_annotate("meanwhile in Australia", size = 20, color = "white")
```
@@ -367,9 +360,9 @@ Morphing creates a sequence of `n` images that gradually morph one image into an
```{r}
newlogo <- image_scale(image_read("https://jeroen.github.io/images/Rlogo.png"))
oldlogo <- image_scale(image_read("https://jeroen.github.io/images/Rlogo-old.png"))
-image_resize(c(oldlogo, newlogo), '200x150!') %>%
- image_background('white') %>%
- image_morph() %>%
+image_resize(c(oldlogo, newlogo), '200x150!') |>
+ image_background('white') |>
+ image_morph() |>
image_animate(optimize = TRUE)
```