Skip to content
Snippets Groups Projects
Commit 948a18cc authored by Laurent Guerard's avatar Laurent Guerard
Browse files

Add background correction method

parent 5f704ad5
No related branches found
No related tags found
No related merge requests found
......@@ -107,20 +107,31 @@ def fix_BF_czi_imagetitle(imp):
return image_title
def preprocess_membrane_channel(imp):
"""apply myosoft pre-processing steps for the membrane channel
def do_background_correction(imp, gaussian_radius=20):
"""Perform background correction on an image.
This is done by applying a Gaussian blur to the image and then dividing the
original image by the blurred image.
Parameters
----------
imp : ImagePlus
a single channel image of the membrane staining
imp : ij.ImagePlus
The image to be corrected.
gaussian_radius : int
The radius of the Gaussian filter to be used. Default value is 20.
Returns
-------
ij.ImagePlus
The background-corrected image.
"""
IJ.run(imp, "Enhance Contrast", "saturated=0.35")
IJ.run(imp, "Apply LUT", "")
IJ.run(imp, "Enhance Contrast", "saturated=1")
IJ.run(imp, "8-bit", "")
IJ.run(imp, "Invert", "")
IJ.run(imp, "Convolve...", "text1=[-1.0 -1.0 -1.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 0\n-1.0 -1.0 24.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 0] normalize")
imp_bgd = imp.duplicate()
IJ.run(
imp_bgd,
"Gaussian Blur...",
"sigma=" + str(gaussian_radius) + " scaled",
)
return ImageCalculator.run(imp, imp_bgd, "Divide create 32-bit")
def get_threshold_from_method(imp, channel, method):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment