@ALDAOperator(genericExecutionMode=ALL, level=APPLICATION, shortDescription="Locally adaptive contrast enhancement for microscopy images. ") public class LocallyAdaptiveContrastEnhancement extends MTBOperator
Reference:
Jyh-Ying Peng, Chun-Nan Hsu, Chung-Chih Lin,
"Adaptive Image Enhancement for Fluorescence Microscopy",
Int. Conf. on Technologies and Applications of Artificial Intelligence,
pp. 9-16, 2010.
The basic idea of this algorithm is to enhance contrast by normalizing each pixel's intensity according to the standard intensity deviation in a local region around the pixel. Subsequently it should be easier to distinguish image background and relevant foreground structures from each other. Although in principal arbitrary segmentation methods could be applied after contrast enhancement, the algorithm is optimized for subsequent binarization, e.g. by Otsu thresholding. In addition, note that the algorithm does not work very well on images showing small structures on very noisy background (like P-bodies or stress granules). It is much better suited for larger structures like DAPI-stained nuclei which can more easily be distinguished from clutter, at least visually.
The size of each local region is adaptive and chosen so that the standard deviation in the region exceeds a certain fraction of the overall image standard deviation, where the fraction is usually lying in the range of 0.2 to 0.8. The ratio can be adapted by the corresponding parameter for the standard deviation ratio. The size of the local region is bounded to a maximum radius which is to be selected according to the size of the entities shown in the image.
The actual image enhancement is based on the following equations.
The radius for each pixel region is first of all calculated as follows:
To avoid numerical instabilities the local standard deviation for normalization is calculated as follows, given the selected local region size $r^\ast$:
As an extension to the original paper this operator features a mode for component-wise application of the algorithm. This means that the image is first of all thresholded and connected components are extracted. Then the contrast enhancement is applied to each component's bounding box separately. Finally, the result image is generated from all enhanced patches after they have been thresholded, i.e. the result image in this case is already a binary segmentation of foreground and background. This inherent binarization is done as the contrast-enhanced image does contain only fractions of reasonable information and, thus, is difficult to post-process without specific knowledge only available inside of this operator.
The basics of this operator have been implemented in the course of the bachelor thesis of Joachim Schumann in SS 2011.
Modifier and Type | Field and Description |
---|---|
private boolean |
applyComponentWise
Flag to activate component-wise application, yields a binary result image.
|
private boolean |
calcRadiusImage
Flag to enable calculation and display of radius image (only in
non-component mode).
|
private MTBImage |
inImg
Input image to be processed.
|
private int |
maxradius
Maximal radius of region to be considered for intensity normalization.
|
private MTBImage |
radiusImg
Optional radius image.
|
private MTBImage |
resultImg
Enhanced or segmented result image, either of type double or binary.
|
private double |
stdDevRatio
Ratio of image standard deviation used as threshold for radius calculation.
|
Constructor and Description |
---|
LocallyAdaptiveContrastEnhancement()
Default constructor.
|
LocallyAdaptiveContrastEnhancement(MTBImage inimg)
Constructor with given image.
|
LocallyAdaptiveContrastEnhancement(MTBImage inimg,
double pc,
int maxr)
Constructor with given image and parameters.
|
Modifier and Type | Method and Description |
---|---|
private static MTBImage[] |
calcEnhancedImage(MTBImage img,
double TstD,
int maxradius,
boolean calcRadiusImage)
Calculates the new image intensity values of the image.
|
private static double |
calcTStD(double StDI,
double percentage)
Calculates the threshold for the local standard daviation.
|
private static double |
calStDI(MTBImage image)
Calculates the standard deviation of the given image.
|
private MTBRegion2DSet |
extractLocalComponents()
Extracts list of connected components from Otsu thresholded input image.
|
String |
getDocumentation() |
MTBImage |
getInputImage()
Returns the input image, null if not set.
|
MTBImage |
getRadiusImage()
Returns supplemental radius image, null if not generated.
|
MTBImage |
getResultImage()
Returns result image.
|
boolean |
isAppliedComponentwise()
Return operator mode.
|
protected void |
operate()
This method does the actual work.
|
void |
setInputImage(MTBImage inimg)
Specify the input image.
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input Image", required=true, direction=IN, supplemental=false, description="Input image", mode=STANDARD) private transient MTBImage inImg
@Parameter(label="Result Image", required=false, direction=OUT, supplemental=false, description="Result image") private transient MTBImage resultImg
Note that the enhanced, non-binarized image is scaled to [0,1].
@Parameter(label="Maximal Region Radius", required=false, direction=IN, supplemental=false, dataIOOrder=-20, description="Max. Radius of Region", mode=ADVANCED) private int maxradius
This radius is supposed to be chosen according to the size of the entities of interest in the image.
@Parameter(label="Std. Deviation Ratio", required=false, direction=IN, mode=ADVANCED, dataIOOrder=-18, description="Percentage of StD used as threshold value.") private double stdDevRatio
For each pixel the radius of the region used for intensity normalization is calculated as to be the radius of the smallest region showing a standard deviation that exceeds a threshold. This threshold is calculated as the given ratio of the image's standard deviation. The larger this ratio is set, the larger the regions will become in tendency.
@Parameter(label="Apply component-wise", required=false, direction=IN, mode=ADVANCED, description="Flag to enable component-wise processing, results in binary image.", dataIOOrder=-16) private boolean applyComponentWise
Usually for enhancing an image average intensity values and standard deviations are calculated over the complete image. But, if there are large regions without structure in an image, calculated values are probably misleading, resulting in image degradation rather than image enhancement.
One possibility to overcome this problem is to apply the intensity normalization only locally. In detail, the image is initially thresholded by Otsu, then dilated and connected components are extracted. Subsequently for each connected component the bounding box is extracted (slightly enlarged), and the normalization is only applied to the image region corresponding to the bounding box. At the end all enhanced regions are merged again to yield the final, enhanced image.
@Parameter(label="Calculate Radius Image", required=false, direction=IN, mode=ADVANCED, supplemental=true, description="Flag for calculating radius image.") private boolean calcRadiusImage
@Parameter(label="Radius Image", required=false, direction=OUT, supplemental=true, mode=ADVANCED, description="Radius image") private transient MTBImage radiusImg
public LocallyAdaptiveContrastEnhancement() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public LocallyAdaptiveContrastEnhancement(MTBImage inimg) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
inimg
- Input image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public LocallyAdaptiveContrastEnhancement(MTBImage inimg, double pc, int maxr) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
inimg
- Input image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setInputImage(MTBImage inimg)
inimg
- Input image to be processed.public MTBImage getInputImage()
public MTBImage getResultImage()
public MTBImage getRadiusImage()
public boolean isAppliedComponentwise()
protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private MTBRegion2DSet extractLocalComponents() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
The method first applies Otsu thresholding to the given image and subsequently applies a dilation with a 3x3 structuring element. Then connected components are extracted, and finally all components with a size larger than 50 pixels are returned as result.
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private static double calStDI(MTBImage image)
image
- Image to process.private static double calcTStD(double StDI, double percentage)
Equation:
StDI
- Standard deviation.percentage
- Specified percentage.private static MTBImage[] calcEnhancedImage(MTBImage img, double TstD, int maxradius, boolean calcRadiusImage)
img
- Image to process.TstD
- Standard deviation threshold to apply.maxradius
- Maximal local region radius.calcRadiusImage
- Flag to enable calculation of radius image.public String getDocumentation()
getDocumentation
in class de.unihalle.informatik.Alida.operator.ALDOperator
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.