From 87a7bdbd0b86cbc88c30cac6d94d350b21d9d91a Mon Sep 17 00:00:00 2001 From: Shota Ochi Date: Tue, 16 Mar 2021 19:11:42 +0900 Subject: [PATCH 1/4] use spatstat.geom --- DESCRIPTION | 4 ++-- R/conversions.R | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6c69984f..c25b75a8 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: imager Type: Package Title: Image Processing Library Based on 'CImg' -Version: 0.42.7 +Version: 0.42.8 Author: Simon Barthelme [aut], David Tschumperle [ctb], Jan Wijffels [ctb], Haz Edine Assemlal [ctb], Shota Ochi [cre] Authors@R: c(person("Simon","Barthelme",email="simon.barthelme@gipsa-lab.fr",role=c("aut")), person("David","Tschumperle",role=c("ctb")), @@ -29,5 +29,5 @@ RoxygenNote: 7.1.1 Suggests: knitr, rmarkdown,ggplot2,dplyr,scales, - testthat,OpenMPController,raster,spatstat,magick,Cairo + testthat,OpenMPController,raster,spatstat.geom,magick,Cairo VignetteBuilder: knitr diff --git a/R/conversions.R b/R/conversions.R index 669a4a70..7112448c 100755 --- a/R/conversions.R +++ b/R/conversions.R @@ -159,7 +159,7 @@ as.cimg.raster <- function(obj,...) cimg2im <- function(img,W=NULL) { - if (requireNamespace("spatstat",quietly=TRUE)) + if (requireNamespace("spatstat.geom",quietly=TRUE)) { if (depth(img) > 1) { @@ -173,12 +173,12 @@ cimg2im <- function(img,W=NULL) } else { - imrotate(img,90) %>% as.array %>% squeeze %>% spatstat::as.im(W=W) + imrotate(img,90) %>% as.array %>% squeeze %>% spatstat.geom::as.im(W=W) } } else { - stop("The spatstat package is required") + stop("The spatstat.geom package is required") } } @@ -192,13 +192,13 @@ cimg2im <- function(img,W=NULL) ##' @export im2cimg <- function(img) { - if (requireNamespace("spatstat",quietly=TRUE)) + if (requireNamespace("spatstat.geom",quietly=TRUE)) { - spatstat::as.matrix.im(img) %>% as.cimg %>% imrotate(-90) + spatstat.geom::as.matrix.im(img) %>% as.cimg %>% imrotate(-90) } else { - stop("The spatstat package is required") + stop("The spatstat.geom package is required") } } From 04e7078b5c4e4e1c2c6036f59a788fda42096599 Mon Sep 17 00:00:00 2001 From: Shota Ochi Date: Tue, 8 Jun 2021 20:30:45 +0900 Subject: [PATCH 2/4] fix the warning --- DESCRIPTION | 2 +- inst/include/CImg.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c25b75a8..7a920076 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: imager Type: Package Title: Image Processing Library Based on 'CImg' -Version: 0.42.8 +Version: 0.42.9 Author: Simon Barthelme [aut], David Tschumperle [ctb], Jan Wijffels [ctb], Haz Edine Assemlal [ctb], Shota Ochi [cre] Authors@R: c(person("Simon","Barthelme",email="simon.barthelme@gipsa-lab.fr",role=c("aut")), person("David","Tschumperle",role=c("ctb")), diff --git a/inst/include/CImg.h b/inst/include/CImg.h index 4044e6ac..decaaa1f 100644 --- a/inst/include/CImg.h +++ b/inst/include/CImg.h @@ -22918,7 +22918,7 @@ namespace cimg_library_suffixed { // Filename specified. CImg ss(siz_arg2 + 1); cimg_forX(ss,i) ss[i] = (char)ptr_arg2[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; if (!siz_arg1) return cimg::fdate(ss,(unsigned int)*ptr_arg1); for (unsigned int k = 0; k ss(siz + 1); cimg_forX(ss,i) ss[i] = (char)ptrs[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; return (double)cimg::fsize(ss); } @@ -23647,7 +23647,7 @@ namespace cimg_library_suffixed { const ulongT siz = (ulongT)mp.opcode[3]; CImg ss(siz + 1); cimg_forX(ss,i) ss[i] = (char)ptrs[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; return (double)cimg::is_directory(ss); } @@ -23672,7 +23672,7 @@ namespace cimg_library_suffixed { const ulongT siz = (ulongT)mp.opcode[3]; CImg ss(siz + 1); cimg_forX(ss,i) ss[i] = (char)ptrs[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; return (double)cimg::is_file(ss); } @@ -25561,7 +25561,7 @@ namespace cimg_library_suffixed { cimg::type::string(),w,h,d,s,sizM); CImg ss(siz2 + 1); cimg_for_inX(ss,0,ss.width() - 1,i) ss[i] = (char)ptr2[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; CImg img; if (siz1) cimg_mp_func_store(ptr1 + 1, @@ -25584,7 +25584,7 @@ namespace cimg_library_suffixed { CImg ss(siz + 1 - ind); ptrs+=1 + ind; cimg_forX(ss,i) ss[i] = (char)ptrs[i]; - ss.back() = 0; + if (ss.size() != 0) ss.back() = 0; const char *s = ss._data; while (*s && *s<=32) ++s; From be57a1995a42a2b3df153415771f1ae469e3f19f Mon Sep 17 00:00:00 2001 From: Shota Ochi Date: Tue, 8 Jun 2021 22:00:18 +0900 Subject: [PATCH 3/4] write NOTE --- inst/include/NOTE_CImg | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/include/NOTE_CImg b/inst/include/NOTE_CImg index 8507afcc..5cddf6cd 100644 --- a/inst/include/NOTE_CImg +++ b/inst/include/NOTE_CImg @@ -1 +1,2 @@ I removed the lines that contained #pragma warning() or #pragma GCC diagnostic. +I replaced the lines "ss.back() = 0;" with "if (ss.back() != 0) ss.back = 0;". From 11a02840c3a061d7272729d1d5e14ab6ec41ce48 Mon Sep 17 00:00:00 2001 From: Shota Ochi Date: Thu, 10 Jun 2021 04:00:37 +0900 Subject: [PATCH 4/4] reduce size of source --- DESCRIPTION | 2 +- vignettes/gettingstarted.Rmd | 2 +- vignettes/pixsets.Rmd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7a920076..839f1501 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: imager Type: Package Title: Image Processing Library Based on 'CImg' -Version: 0.42.9 +Version: 0.42.10 Author: Simon Barthelme [aut], David Tschumperle [ctb], Jan Wijffels [ctb], Haz Edine Assemlal [ctb], Shota Ochi [cre] Authors@R: c(person("Simon","Barthelme",email="simon.barthelme@gipsa-lab.fr",role=c("aut")), person("David","Tschumperle",role=c("ctb")), diff --git a/vignettes/gettingstarted.Rmd b/vignettes/gettingstarted.Rmd index 8e986b2a..f6657d00 100755 --- a/vignettes/gettingstarted.Rmd +++ b/vignettes/gettingstarted.Rmd @@ -15,7 +15,7 @@ vignette: > ```{r init,echo=FALSE} knitr::opts_chunk$set(warning=FALSE, message=FALSE, cache=FALSE, - comment=NA, verbose=TRUE, fig.width=5, fig.height=5,dev='jpeg',dev.args=list(quality=50)) + comment=NA, verbose=TRUE, fig.width=5, fig.height=5,dev='jpeg',dev.args=list(quality=25)) ``` **imager** contains a large array of functions for working with image data, with most of these functions coming from the [CImg library](http://www.cimg.eu/) by David Tschumperlé. This vignette is just a short tutorial, you'll find more information and examples on the website. Each function in the package is documented and comes with examples, so have a look at package documentation as well. diff --git a/vignettes/pixsets.Rmd b/vignettes/pixsets.Rmd index 7ea483f6..bddfe701 100755 --- a/vignettes/pixsets.Rmd +++ b/vignettes/pixsets.Rmd @@ -15,7 +15,7 @@ vignette: > ```{r init,echo=FALSE} knitr::opts_chunk$set(warning=FALSE, message=FALSE, cache=FALSE, - comment=NA, verbose=TRUE, fig.width=5, fig.height=5,dev='jpeg',dev.args=list(quality=50)) + comment=NA, verbose=TRUE, fig.width=5, fig.height=5,dev='jpeg',dev.args=list(quality=25)) ``` If you've already gone through the "Getting started" vignette, you know about image objects ("cimg" class). This vignette introduces pixsets, which is the other important kind of objects. Pixsets represent sets of pixels, or equivalently binary images, AKA "masks". ```{r}