exchangeImage.Rd
Exchanges the image and scales the coordinates of all
spatial aspects in the SPATA2
object accordingly.
exchangeImage(
object,
image,
img_scale_fct = 1,
adjust = TRUE,
verbose = NULL,
...
)
An object of class spata2
.
Image input or character value. If character, input is interpreted as a directory
to a file or to an URL and is read with EBImage::readImage()
. The read image
should be of type .png, .jpeg or .tiff. Capital letters work, too.
If not character, the function ensures that the input is - or is convertible - to
class Image
via EBImage::as.Image()
. If that fails, an error is thrown.
Numeric value or NULL
. If numeric, used as a scale factor
to manipulate the size of the new image. The scale factor can be lower or bigger
than one. But must be bigger than 0. See details for more information.
Logical value. If TRUE
, the function assumes that
the new image has the same justification as the image that was first loaded when the
SPATA2
object was created and it assumes that it needs the same rotation and flipping
to be aligned with the coordinates. Thus, tracked flipping and rotation that has been applied and
the old image is applied to adjust the new image accordingly. If FALSE
, the
image is stored as it is read in.
Logical. If set to TRUE informative messages regarding the computational progress will be printed.
(Warning messages will always be printed.)
Used to absorb deprecated arguments or functions.
Using argument img_scale_fct
:
This argument can either be used to downscale very big images by a factor or it can be used to effectively multiply the resolution of the old image.
img_scale_fct
< 1: The scale factor is used to simply scale down the width and height of the
new image. E.g. width is 800px and height is 1000px and img_scale_fct = 0.5
. In this case,
the new image is stored with the dimensions width of 400px and height of 500px.
img_scale_fct
> 1: The scale factor is used to set the width and height in relation
to the old image. E.g. width and height of the old image are both 1000px and img_scale_fct = 1.5
the new image will be stored with the dimensions width = 1500px and height = 1500px - three
times as high of a resolution than the old image. If the basic resolution of the new image
is not bigger or equal than the required one an error is thrown. - Setting img_scale_fct
to a
value bigger than 1 only makes sense if the new image is bigger than the old one.
The function requires the SPATA2
object to already contain an
image. This is because images of different resolution (total number of pixels)
require the x- and y-coordinates to be scaled. The function assumes
that the coordinates are properly scaled to the old image. The scale factor with
which the coordinates are scaled to the new image is then computed by comparing the resolution
of the old image with the one from the new image.
Images are stored in form of the Image
class from the EBImage
package. To
be precise, they are stored in an S4 object of class HistologyImaging
altogether
with meta data.
rescaleImage()
to downscale the current image. createHistologyImaging()
to see
information on how to set up the container in which the image is stored. containsImage()
and containsHistologyImaging()
to read more information about the difference between
both.