read_image {pixelclasser} | R Documentation |
Imports and transforms a jpg or tiff file.
Description
Imports an image file (in JPEG or TIFF format) into an array, and converts
the original R
, G
and B
values in the file into
proportions (r
, g
and b
variables).
Usage
read_image(file_name)
is.transformed_image(x)
## S3 method for class 'pixel_transformed_image'
summary(object, ...)
Arguments
file_name |
A character string containing the name of the image file. |
x |
the R object being tested |
object |
an object of class |
... |
other parameters passed to the function. |
Details
This function calls the functions jpeg::readJPEG()
or
tiff::readTIFF()
to import the image into an R array. Then it
transforms the data into proportions
Value
Returns an object of class "pixel_transformed_image"
, which
is an array of dimensions r x c x 3
, being r
and c
the number of rows and columns in the image. The last dimension corresponds
to the original R
, G
and B
variables (= bands) that
define the colours of the pixels. The values in the array are the
proportions of each colour (r, g, b
), i.e. r
= R
/
(R + G + B
), and so on.
See Also
For more information about jpeg and tiff file formats, see the help
pages of readJPEG
and
readTIFF
functions.
Examples
# An example that loads the example file included in the package
ivy_oak_rgb <- read_image(system.file("extdata", "IvyOak400x300.JPG",
package = "pixelclasser"))