aoles / EBImage

:art: Image processing toolbox for R
70 stars 28 forks source link

normalize is buggy - seems to preserve state #26

Closed shntnu closed 6 years ago

shntnu commented 6 years ago

In the example below, normalize works differently after being called without the inputRange argument.

img <- EBImage::readImage(system.file("images", "sample.png", package="EBImage"))

o <- EBImage::normalize(img, inputRange = c(0, 0.05))

p <- EBImage::normalize(img, inputRange = c(0, 0.05))

q <- EBImage::normalize(img)

r <- EBImage::normalize(img, inputRange = c(0, 0.05))

s <- EBImage::normalize(img, inputRange = c(0, 0.05))

data.frame(image = c("o", "p", "q", "r", "s"),
           min = c(min(o), min(p), min(q), min(r), min(s)),
           max = c(max(o), max(p), max(q), max(r), max(s))
           )
#>   image min  max
#> 1     o   0 0.05
#> 2     p   0 0.05
#> 3     q   0 1.00
#> 4     r   0 1.00
#> 5     s   0 1.00

all(o==p)
#> [1] TRUE
all(r==s)
#> [1] TRUE
all(p==r)
#> [1] FALSE
Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.1 (2017-06-30) #> system x86_64, darwin15.6.0 #> ui unknown #> language (EN) #> collate en_US.UTF-8 #> tz America/New_York #> date 2017-10-10 #> Packages ----------------------------------------------------------------- #> package * version date source #> abind 1.4-5 2016-07-21 CRAN (R 3.4.1) #> backports 1.1.0 2017-05-22 cran (@1.1.0) #> base * 3.4.1 2017-08-18 local #> BiocGenerics 0.22.0 2017-10-04 Bioconductor #> compiler 3.4.1 2017-08-18 local #> datasets * 3.4.1 2017-08-18 local #> devtools 1.13.3 2017-08-02 CRAN (R 3.4.1) #> digest 0.6.12 2017-01-27 CRAN (R 3.4.1) #> EBImage 4.18.2 2017-10-04 Bioconductor #> evaluate 0.10.1 2017-06-24 cran (@0.10.1) #> fftwtools 0.9-8 2017-03-25 CRAN (R 3.4.1) #> graphics * 3.4.1 2017-08-18 local #> grDevices * 3.4.1 2017-08-18 local #> grid 3.4.1 2017-08-18 local #> htmltools 0.3.6 2017-04-28 cran (@0.3.6) #> jpeg 0.1-8 2014-01-23 CRAN (R 3.4.1) #> knitr 1.17 2017-08-10 cran (@1.17) #> lattice 0.20-35 2017-03-25 CRAN (R 3.4.1) #> locfit 1.5-9.1 2013-04-20 CRAN (R 3.4.1) #> magrittr 1.5 2014-11-22 cran (@1.5) #> memoise 1.1.0 2017-04-21 CRAN (R 3.4.1) #> methods * 3.4.1 2017-08-18 local #> parallel 3.4.1 2017-08-18 local #> png 0.1-7 2013-12-03 CRAN (R 3.4.1) #> Rcpp 0.12.13 2017-09-28 cran (@0.12.13) #> rmarkdown 1.6 2017-06-15 cran (@1.6) #> rprojroot 1.2 2017-01-16 cran (@1.2) #> stats * 3.4.1 2017-08-18 local #> stringi 1.1.5 2017-04-07 cran (@1.1.5) #> stringr 1.2.0 2017-02-18 cran (@1.2.0) #> tiff 0.1-5 2013-09-04 CRAN (R 3.4.1) #> tools 3.4.1 2017-08-18 local #> utils * 3.4.1 2017-08-18 local #> withr 2.0.0 2017-07-28 CRAN (R 3.4.1) #> yaml 2.1.14 2016-11-12 cran (@2.1.14) ```
aoles commented 6 years ago

Fixed in both release (4.18.3) and devel (4.19.11). Run BiocInstaller::biocLite() to update.