create a mask image to remove image background from Visium H&E images
he_mask(
object,
maxres = 2000,
stretch = F,
sd_thresh = 9,
crop = T,
crop_area = NULL
)
# S4 method for class 'Seurat'
he_mask(
object,
maxres = 2000,
stretch = F,
sd_thresh = 9,
crop = T,
crop_area = NULL
)
# S4 method for class 'SpatRaster'
he_mask(
object,
maxres = 2000,
stretch = F,
sd_thresh = 9,
crop = T,
crop_area = NULL
)
a Seurat object containing Kandinsky data (`KanData()`) or an image of class `SpatRaster` created with the `terra` package
numeric value indicating the ideal maximum pixel dimension accepted for Visium H&E image. If image size is bigger than this value, a scale factor will be applied to lower image pixel resolution/size up to the defined maximum value
boolean value, whether or not to apply a linear stretch to increase masked image contrast. Default is FALSE
numeric value indicating the minimum RGB standard deviation accepted to keep an image pixel as part of the final tissue mask. Lower `sd_thresh` values will give more permissive filtering results.
boolean value, whether or not to crop the final masked image
bounding box coordinates to be used to crop masked image. If `crop = T` and `crop_area` is set to `NULL`, Visium spot coordinates will be used to automatically define the bounding box for cropping the image
Seurat object with new 'masked_img' slot within the Kandinsky data if object is a Seurat object, or a masked `Spatraster` image
Additional details... This function will apply a variance-based threshold to the RGB channels of the H&E image stored within the Kandinsky data to keep only the area of image covering the tissue sample and to remove the rest of the image background. The masking strategy relies on the fact that RGB values from H&E staining will usually show a higher standard deviation compared to the gray-ish Visium slide background.