This function uses the magick
package to edit the color and perform other
image manipulations on a background image. It can be useful if you want to
highlight certain features of these images.
img_edit(
spe,
sampleid,
image_id = "lowres",
channel = NA,
brightness = 100,
saturation = 100,
hue = 100,
enhance = FALSE,
contrast_sharpen = NA,
quantize_max = NA,
quantize_dither = TRUE,
equalize = FALSE,
normalize = FALSE,
transparent_color = NA,
transparent_fuzz = 0,
background_color = NA,
median_radius = NA,
negate = FALSE
)
Defaults to the output of
fetch_data(type = 'spe')
. This is a
SpatialExperiment-class
object with the spot-level Visium data and information required for
visualizing the histology. See fetch_data()
for more details.
A character(1)
specifying which sample to plot from
colData(spe)$sample_id
(formerly colData(spe)$sample_name
).
A character(1)
with the name of the image ID you want to
use in the background.
A character(1)
passed to
magick::image_channel. If NA
this step is skipped.
A numeric(1)
passed to
magick::image_modulate.
A numeric(1)
passed to
magick::image_modulate.
A numeric(1)
passed to magick::image_modulate.
A logical(1)
controlling whether to use
magick::enhance.
A numeric(1)
passed to
magick::image_contrast. If NA
this step is skipped.
A numeric(1)
passed to
magick::image_quantize. If NA
this step is skipped.
A logical(1)
passed to
magick::image_quantize.
A logical(1)
controlling whether to use
magick::equalize.
A logical(1)
controlling whether to use
magick::normalize.
A character(1)
passed to
magick::image_transparent. If NA
this step is skipped.
A numeric(1)
passed to
magick::image_transparent.
A character(1)
passed to
magick::image_background. If NA
this step is skipped.
A numeric(1)
passed to
magick::image_median. If NA
this step is skipped.
A logical(1)
controlling whether to use
magick::negate.
A magick
image object such as the one returned by
magick::image_read.
The magick
functions are used in the sequence represented by the arguments
to this function. You can alternatively use this function sequentially. Or
directly use the magick
package.
Other Image editing functions:
img_update_all()
,
img_update()
if (enough_ram()) {
## Obtain the necessary data
if (!exists("spe")) spe <- fetch_data("spe")
## Reduce brightness to 25%
x <- img_edit(spe, sampleid = "151507", brightness = 25)
plot(x)
}
#> 2023-09-05 20:31:48.286234 loading file /github/home/.cache/R/BiocFileCache/152d33414640_Human_DLPFC_Visium_processedData_sce_scran_spatialLIBD.Rdata%3Fdl%3D1