Reputation: 1
I have a matrix with numerical values. I was able to convert these values with heatmap.2 in a heatmap.
heatmap.2(as.matrix(mtcars), Rowv=FALSE, Colv=FALSE, density.info="none", trace="none", dendrogram='none')
I would now like to export the heatmap as a 16bit image that contains all the values as an information in the color code. My idea is to analyse the generated image with ImageJ/Fiji. However, I only found export options that generate an RGB file in different formats that I cannot use for my ImageJ analysis.
I would be very thankful for any input. Many thanks!
Cheers, Rus
Upvotes: 0
Views: 538
Reputation: 2174
Common image formats (jpeg,png,tif) are often meant for standard images (think photos or graphics).
For more features such as 16 bits coding we must consider them as rasters (images for image processing (eg your ImageJ) or Geographic Information Systems). We will use for this the raster
and rgdal
packages (the later is needed for tiff format).
Say that your heatmap matrix is called m
library(raster)
library(rgdal)
r <- raster(m) # convert your matrix to as raster (spatialized matrix)
writeRaster(r, "r.tif", type="INT2U") # INT2U stands for Unsigned 16bits Integer (?dataType for other types)
Upvotes: 1