ANTsX / ANTsRCore

Rcpp bindings for the C++ ANTs library used by the ANTsR package
9 stars 9 forks source link

Can't write JPG #106

Closed muschellij2 closed 4 years ago

muschellij2 commented 4 years ago

Describe the bug Cannot write out JPG files due to linking with ITKR:

To Reproduce

library(ANTsRCore)
#> 
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
#> The following objects are masked from 'package:base':
#> 
#>     all, any, apply, max, min, prod, range, sum
img = antsImageRead(getANTsRData("r16"))
tfile = tempfile(fileext = ".jpg")
antsImageWrite(img, tfile)
#> Error in antsImageWrite(img, tfile): /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/Rtmpcrl9wA/R.INSTALLf9d536f1cdc5/ITKR/src/itks/Modules/IO/JPEG/src/itkJPEGImageIO.cxx:394:
#> itk::ERROR: JPEGImageIO(0x7fca5d163030): JPEG supports unsigned char/int only
ANTsRCore::antsVersions
#>   Dependency                                   GitTag
#> 1       ANTs 416b9d10458f6bbf78e788b823ad0be9db11d7e8
#> 2  ANTsRCore                                         
#> 3    ANTsURL        https://github.com/ANTsX/ANTs.git
#> 4        ITK 49671655c88612fabeb5f0784d3f40123100f166

Created on 2019-11-22 by the reprex package (v0.3.0.9000)

Session info ``` r sessioninfo::session_info() #> ─ Session info ────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.0 (2019-04-26) #> os macOS Mojave 10.14.6 #> system x86_64, darwin15.6.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/New_York #> date 2019-11-22 #> #> ─ Packages ────────────────────────────────────────────────────────────── #> package * version date lib source #> ANTsRCore * 0.7.3 2019-11-05 [1] Github (ANTsX/ANTsRCore@f564041) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> digest 0.6.22 2019-10-21 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0) #> ITKR 0.5.2 2019-11-05 [1] Github (stnava/ITKR@fe97efa) #> knitr 1.24.3 2019-08-28 [1] Github (muschellij2/knitr@abcea3d) #> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0) #> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.0) #> RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.0) #> rlang 0.4.1 2019-10-24 [1] CRAN (R 3.6.0) #> rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) #> #> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library ```

Expected behavior ANTsR I/O supports JPEG

stnava commented 4 years ago

documentation issue. see the error reported: "JPEG supports unsigned char/int only" which suggests that one must do:

antsImageWrite( antsImageClone( ri(1), out_pixeltype='unsigned char'), '/tmp/temp.jpg' )

noting that some value conversions to [0,255] would also be needed, in general.