I am new to image processing in R. To start with, I am using the EBImage
R package for this. I have a 260 by 134
Matrix
which I converted to an image using
> image1 <- as.Image(matrix1)
And, here is the image object summary
> image1
colorMode : Grayscale
storage.mode : double
dim : 260 134
frames.total : 1
frames.render: 1
imageData(object)[1:5,1:6]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
[4,] 0 0 0 0 0 0
[5,] 0 0 0 0 0 0
A value greater than zero for a specific cell in the image
object looks like this:
> imageData(image1)[9,2]
[1] 3686.308
I then use the display
function in the EBImage
package to view the image which is build from the matrix data.
> display(image1, method = "raster")
However, I get a binary image i.e just black and white pixels. I have shown it below. My data does not just consist of 0
and 1
. The background values are zero but the regions with the actual image pattern have values higher than 1. How do I display the image using grayscale and using the functions in this package? Did someone face a similar issue? I also could not find a parameter to specify a gradient level.