resizeImage | R Documentation |
Saves the instructions to use and store the resized version of an image to optimize resolution and memory usage.
resizeImage(object, ...)
## S4 method for signature 'SPATA2'
resizeImage(
object,
img_name,
resize_fct,
img_name_new = "{img_name}_{resize_fct}",
apply_to_transl = TRUE,
overwrite = FALSE,
verbose = NULL
)
## S4 method for signature 'SpatialData'
resizeImage(
object,
img_name,
resize_fct,
img_name_new = "{img_name}_{resize_fct}",
apply_to_transl = TRUE,
overwrite = FALSE,
verbose = TRUE,
...
)
## S4 method for signature 'HistoImage'
resizeImage(object, resize_fct, apply_to_transl = TRUE, verbose = TRUE, ...)
object |
An object of class |
... |
Used to absorb deprecated arguments or functions. |
img_name |
Character value. The image to be resized. |
resize_fct |
The value should be a positive number between 0 and 1, representing the proportion by which the image should be resized.
For example, |
img_name_new |
A character string or glue instruction, specifying the name for the resized image. If character, a new, additional image is registered. Set to FALSE if you want the resized image to be registered under the original image name. Defaults to |
apply_to_transl |
Logical. If TRUE, the resizing will also be applied to
instructions on how to translate the image as set with |
overwrite |
Logical value. Must be |
verbose |
Logical. If (Warning messages will always be printed.) |
This function sets instructions on how to deal with the size of the image. By default, any
image registered in the SPATA2 object manually or during initiation with, for instance, initiateSpataObjectVisium()
is registered with the original size (width x height) as stored on the disk on your device. R is not
particularly efficient when it comes to handling images of a certain size. This resizing functionality
allows you to adjust the size in which the image is handled when used in order to optimize the ratio
between image resolution and computational performance.
The updated input object, containing the added, removed or computed results.
loadImage()
, writeImage()
library(SPATA2)
library(SPATAData)
object <- downloadSpataObject("UKF313T")
# contains two images
getImageNames(object)
# Resize the "hires" image by a factor of 0.5 and update the object
object <- resizeImage(object, img_name = "hires", resize_with = 0.5)
# Now the object contains three images
getImageNames(object)
# Note how both 'registered images' draw from the same directory
# This is possible since the instruction to resize the image is applied
# during loadImage()
getImageDir(object, img_name = "lowres") # dir 1
getImageDir(object, img_name = "hires") # dir 2
getImageDir(object, img_name = "hires_0.5") # dir 2
# ---> Check out writeImage() to store information of downloaded SPATA2 objects on your disk
# Show the results: plot the original and resized image
plotImage(object, img_name = "hires") +
plotImage(object, img_name = "hires_0.5") # by default, resized images are renamed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.