de.unihalle.informatik.MiToBo.enhance
Class LocallyAdaptiveContrastEnhancement

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBOperator
          extended by de.unihalle.informatik.MiToBo.enhance.LocallyAdaptiveContrastEnhancement
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

@ALDAOperator(genericExecutionMode=ALL,
              level=APPLICATION)
public class LocallyAdaptiveContrastEnhancement
extends MTBOperator

This class implements contrast enhancement for microscopy images.

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:

%preamble{\usepackage{amssymb,amsmath}}
where $R_{max}$ is the maximally allowed radius, $T_{StD}$ is the threshold for local standard deviation calculated as fraction of the image intensity standard deviation, and $StD[R_r(x,y)]$ is the standard deviation in a region $R_r(x,y)$ with radius $r$ around the current pixel $(x,y)$.

To avoid numerical instabilities the local standard deviation for normalization is calculated as follows, given the selected local region size $r^\ast$:

%preamble{\usepackage{amssymb,amsmath}}
Finally the normalization for contrast enhancement, i.e. the calculation of the new image intensity value $I_N(x,y)$ is done as follows:
%preamble{\usepackage{amssymb, amsmath}}

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.

Author:
Joachim Schumann, Birgit Moeller

Nested Class Summary
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
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.
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
LocallyAdaptiveContrastEnhancement()
          Default constructor.
LocallyAdaptiveContrastEnhancement(MTBImage inimg)
          Constructor with given image.
LocallyAdaptiveContrastEnhancement(MTBImage inimg, double pc, int maxr)
          Constructor with given image and parameters.
 
Method Summary
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.
 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.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applyComponentWise

@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
Flag to activate component-wise application, yields a binary result image.

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.


calcRadiusImage

@Parameter(label="Calculate Radius Image",
           required=false,
           direction=IN,
           mode=ADVANCED,
           supplemental=true,
           description="Flag for calculating radius image.")
private boolean calcRadiusImage
Flag to enable calculation and display of radius image (only in non-component mode).


inImg

@Parameter(label="Input Image",
           required=true,
           direction=IN,
           supplemental=false,
           description="Input image",
           mode=STANDARD)
private transient MTBImage inImg
Input image to be processed.


maxradius

@Parameter(label="Maximal Region Radius",
           required=false,
           direction=IN,
           supplemental=false,
           dataIOOrder=-20,
           description="Max. Radius of Region",
           mode=ADVANCED)
private int maxradius
Maximal radius of region to be considered for intensity normalization.

This radius is supposed to be chosen according to the size of the entities of interest in the image.


radiusImg

@Parameter(label="Radius Image",
           required=false,
           direction=OUT,
           supplemental=true,
           mode=ADVANCED,
           description="Radius image")
private transient MTBImage radiusImg
Optional radius image.


resultImg

@Parameter(label="Result Image",
           required=false,
           direction=OUT,
           supplemental=false,
           description="Result image")
private transient MTBImage resultImg
Enhanced or segmented result image, either of type double or binary.

Note that the enhanced, non-binarized image is scaled to [0,1].


stdDevRatio

@Parameter(label="Std. Deviation Ratio",
           required=false,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=-18,
           description="Percentage of StD used as threshold value.")
private double stdDevRatio
Ratio of image standard deviation used as threshold for radius calculation.

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.

Constructor Detail

LocallyAdaptiveContrastEnhancement

public LocallyAdaptiveContrastEnhancement()
                                   throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor.

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

LocallyAdaptiveContrastEnhancement

public LocallyAdaptiveContrastEnhancement(MTBImage inimg)
                                   throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor with given image.

Parameters:
inimg - Input image.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

LocallyAdaptiveContrastEnhancement

public LocallyAdaptiveContrastEnhancement(MTBImage inimg,
                                          double pc,
                                          int maxr)
                                   throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor with given image and parameters.

Parameters:
inimg - Input image.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

calcEnhancedImage

private static MTBImage[] calcEnhancedImage(MTBImage img,
                                            double TstD,
                                            int maxradius,
                                            boolean calcRadiusImage)
Calculates the new image intensity values of the image.

Parameters:
img - Image to process.
TstD - Standard deviation threshold to apply.
maxradius - Maximal local region radius.
calcRadiusImage - Flag to enable calculation of radius image.
Returns:
Array with enhanced image and (optionally) radius image.

calcTStD

private static double calcTStD(double StDI,
                               double percentage)
Calculates the threshold for the local standard daviation.

Equation:

%preamble{\usepackage{amssymb,amsmath}}

Parameters:
StDI - Standard deviation.
percentage - Specified percentage.
Returns:
Calculated threshold.

calStDI

private static double calStDI(MTBImage image)
Calculates the standard deviation of the given image.

Parameters:
image - Image to process.
Returns:
Calculated standard deviation.

extractLocalComponents

private MTBRegion2DSet extractLocalComponents()
                                       throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                              de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Extracts list of connected components from Otsu thresholded input image.

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.

Returns:
List of connected components larger than 50 pixels.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

getInputImage

public MTBImage getInputImage()
Returns the input image, null if not set.


getRadiusImage

public MTBImage getRadiusImage()
Returns supplemental radius image, null if not generated.


getResultImage

public MTBImage getResultImage()
Returns result image.


isAppliedComponentwise

public boolean isAppliedComponentwise()
Return operator mode.

Returns:
If true, enhancement is applied component-wise.

operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
This method does the actual work.

Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

setInputImage

public void setInputImage(MTBImage inimg)
Specify the input image.

Parameters:
inimg - Input image to be processed.