Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206180

how to save an Cimg object with NAN value in r?

$
0
0

when manipulating images with {imager}, I subtract an image from the other, and shockedly found I can't save the image. After converting the image into data.frame, I conclude when NAN appears, the it can't be saved. pls find the toy example.

How can I save such image?

library(imager)
im1 <- load.image("imx1.jpg")
im2 <- load.image("imx1.jpg") %>% isoblur(5)

imx <- (im1-im2)^0.5

plot(imx)
# class(imx)
#[1] "cimg""imager_array""numeric"     

save.image(imx, "imxxx.jpg") 
# Error in if (any(A > 1) | any(A < 0)) { : 
# missing value where TRUE/FALSE needed

imxdf <- as.data.frame(imx)
#> imxdf
#     x y cc       value
#1    1 1  1         NaN
#2    2 1  1         NaN
#3    3 1  1         NaN
#4    4 1  1         NaN

Orignal image


Viewing all articles
Browse latest Browse all 206180

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>