Read in an image file from the disk as an array of pixel intensities.
ReadImageData(image.name, fix.lut = NULL)
The path to the image file on disk. The file extension must be one of '.jpeg', '.png', '.tiff' or '.tif'.
When reading in images (via EBImage::readImage()
), R can
give an array of different dimensionality than you expect. If you suspect
this happening, set the value of this parameter to the number of
dimensions that you expect your read image to have and this function will
try to automatically give you the image array in the form you want. Read
FixLUTError()
to find out more.
An array of integers representing the image.
This function wraps EBImage::readImage()
and EBImage::imageData()
. By
default, readImage
reads in pixel intensities in the range [0, 1]
.
ReadImageData
reads in pixel intensities as integers as they would be
represented in a tiff file and displayed therefrom in ImageJ. This is
necessary when calculating number and brightness, where we need pixel values
to be in units of 'counts'.
Thinking of the read image as a matrix mat
, the pixel at \(x = \)i
,
\(y = \)j
has colour based on the value of mat[i, j]
where the
\(x\) axis points right and the \(y\) axis points down. This is in
accordance with how EBImage::EBImage's EBImage::readImage()
(which this
function wraps). However, when one prints a matrix in a console (or views it
in a program such as excel), the value in position \(x = \)i
, \(y =
\)j
is from mat[j, i]
, so if you're confused about a phantom
transposition, this is why.
Sometimes (for whatever reason) the reading of image values as integers with
readTIFF(..., as.is = TRUE)
fails such that the values which should be 1,
2, 3 etc. end up as 256, 512, 778 etc. This function corrects for this as
follows: if the greatest common divisor of the elements in the array are one
of 2^8, 2^12, 2^16 or 2^32, then divide each element of the array by this
greatest common divisor. This will return 256, 512, 778 etc. to 1, 2, 3 etc.
# NOT RUN {
img <- ReadImageData(system.file('extdata', '50.tif', package = 'nandb'))
# }
Run the code above in your browser using DataLab