View source: R/BioTrajectory.R View source: R/readImage.R
readImage | R Documentation |
This function reads an image from a file path and resizes it to a specified number of rows. It supports several image formats, including JPG, JPEG, PNG, TIFF, and TIF. The function also converts the image into a suitable format for further processing.
readImage(path, resizeRows)
path |
The file path of the image to be read. |
resizeRows |
The desired number of rows (height) to resize the image. The aspect ratio of the image will be maintained during resizing. |
The function detects the image format based on the file extension. It currently supports the following formats: JPG, JPEG, PNG, TIFF, and TIF. If the image has more than 3 dimensions (such as an RGBA image with an alpha channel), the alpha channel is discarded. The image is resized only if its height exceeds the specified 'resizeRows'.
A cimg object containing the resized image.
# Example usage
img_path <- system.file('extdata/data.tiff', package='BioTrajectory')
img <- readImage(img_path, resizeRows = 500)
plot(img) # Visualizes the resized image
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.