fixGaussianBlur: Remove Gaussian Blur

Description Usage Arguments Details Value Author(s) Examples

View source: R/projection.R

Description

Fix the contrast projection error around very bright objects on a dark background

Usage

1
fixGaussianBlur(imageStack, indexMap, blur.size, validate = TRUE)

Arguments

imageStack

A numeric 3D array-like which should ne projected. The dimensions should be (spatial_1, spatial_2, numer_of_images)

indexMap

A custom index map according to which the image stack is projected. The values must be integers between 1 and the number of layers in imageStack

blur.size

An integer indicating the radius of the gaussian blur. The total diameter of the brush is defined as 2*blur.size+1, meaning that a blur.size' value of 0 will result in a 1x1 pixel brush.

validate

A boolean indicating if the function arguments should be validated. This is only used to marginally speed up internal calls to functions and has no bearing on the actual functionality of the method.

Details

Bright objects on dark backgrounds cause projection artefacts, a sort of gaussian "shadow" of the object. This is due to the unfocused images having a higher contrast in the regions directly outside of bright foreground objects than the actual background. This leads to ring shapes around the bright foreground which need to be removed. This is done by detecting bright objects with a primitive, intensity-based segmentation method (Otsu-thresholding) and determining a region around the foreground objects in which the gaussian blurring is visible. In this region, instead of using the determined z-indices for the projection, a Voronoi propagation starting from the closest foreground pixels is performed to ensure that the same z-layer is used for the nearby background as for the foreground.

Value

An index map with the corrected values around the foreground objects

Author(s)

Jan Sauer

Examples

1

Example output

function (imageStack, indexMap, blur.size, validate = TRUE) 
{
    if (missing(imageStack)) 
        stop("'imageStack' is missing")
    if (missing(indexMap)) 
        stop("'indexMap' is missing")
    if (validate) 
        valid = validateVariables(imageStack = imageStack, indexMap = indexMap, 
            blur.size = blur.size)
    proj_min = intensityProjection(imageStack, "min")
    otsu_thresh = otsu(x = proj_min, range = range(proj_min))
    proj_min_bin = proj_min >= otsu_thresh
    proj_min_bin = fillHull(proj_min_bin * 1)
    f = makeBrush(size = blur.size * 2 + 1, shape = "disc", step = TRUE)
    bin_img_overlay = filter2(x = proj_min_bin, filter = f, boundary = 0)
    bin_img_overlay[bin_img_overlay > 1] = 1
    bin_img_overlay = bin_img_overlay > otsu(x = bin_img_overlay, 
        range = range(bin_img_overlay))
    expand_region = bin_img_overlay * (1 - proj_min_bin)
    seed_map = indexMap * proj_min_bin
    indexMap_adjusted = propagate(x = matrix(0, nrow = dim(imageStack)[1], 
        ncol = dim(imageStack)[2]), seeds = seed_map, lambda = 1e+06)
    true_index_map = indexMap
    true_index_map[expand_region == 1] = indexMap_adjusted[expand_region == 
        1]
    return(true_index_map)
}
<environment: namespace:MaxContrastProjection>

MaxContrastProjection documentation built on April 28, 2020, 7:30 p.m.