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
)
A
SpatialExperiment-class
object. See fetch_data()
for how to download some example objects or
read10xVisiumWrapper()
to read in spaceranger --count
output files and
build your own spe
object.
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()
,
img_update_all()
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)
}
#> 2024-12-13 19:41:05.42802 loading file /github/home/.cache/R/BiocFileCache/103d2e431726_Human_DLPFC_Visium_processedData_sce_scran_spatialLIBD.Rdata%3Fdl%3D1