@ALDAOperator(genericExecutionMode=ALL, level=STANDARD, allowBatchMode=false) public class PaCeQuant extends MTBOperator
The operator first applies several preprocessing steps to a given input image, e.g., noise reduction by filtering, binarization, and several morphological operations. The outcome of this first stage are binary regions corresponding to the cells in the image. Note that the input image can either be given by an 8-bit grayscale image or an already presegmented binary image. Select the input mode accordingly.
Subsequently, the cell regions are filtered according to area, i.e. too small regions are removed. In addition we seek to exclude regions from further processing which originate from more than one physical cell and have accidentally been merged into a single region during preprocessing and segmentation.
The final stage comprises the calculation of a set of features for
each region suitable to characterize the region morphology. In this
stage we use the MorphologyAnalyzer2D
operator.
Modifier and Type | Class and Description |
---|---|
static class |
PaCeQuant.BorderBackgroundContrast
Border color.
|
static class |
PaCeQuant.GapCloseMode
Heuristic for closing border gaps.
|
static class |
PaCeQuant.ImageType
Image type.
|
static class |
PaCeQuant.LobeTypes
Different types of lobes.
|
static class |
PaCeQuant.MeasurementUnits
Unit for measurements.
|
static class |
PaCeQuant.OperationMode
Operation mode of the operator.
|
static class |
PaCeQuant.OperatorPhasesToRun
Phases to run.
|
static class |
PaCeQuant.PixelCalibration
Mode of calibrating pixel size.
|
static class |
PaCeQuant.SegmentationInputFormat
Formats for input of external segmentation results.
|
private class |
PaCeQuant.SegmentationResult
Internal class for representing the result data of segmenting an image.
|
private class |
PaCeQuant.SkeletonPostprocessor
Helper operator to post-process border skeletons.
|
Modifier and Type | Field and Description |
---|---|
private Vector<MTBImageRGB> |
addResultImages
Vector of additional result images.
|
PaCeQuant.BorderBackgroundContrast |
borderContrast
Border to background relation.
|
private boolean |
classifyLobes
Flag to classify lobes into different type classes.
|
private boolean |
drawRegionIDsToOutputImages
Flag to enable/disable drawing region IDs.
|
private static HashMap<String,String> |
featureNameMapper |
private static String[] |
featureParameters
List of parameters relevant for feature extraction phase.
|
private PaCeQuant.GapCloseMode |
gapMode
Mode for closing gaps.
|
private MTBImage |
gaussFilterImg
Gauss filtered input image (for internal use only).
|
private int |
height
Height of the input image.
|
PaCeQuant.ImageType |
imType
Image type.
|
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
inDir
Input directory where to find the images to process.
|
private MTBImageByte |
inImg
Input image to process.
|
private MTBRegion2DSet |
inRegions
Input image to process.
|
private double |
maximalCellSize
Threshold for the maximal admissible cell size.
|
private double |
minimalCellSize
Threshold for the minimal admissible cell size.
|
private MorphologyAnalyzer2D |
morphFeatureOp
Operator to analyze morphology of cells.
|
private int |
naiveGapThreshold
Maximal distance of gaps in naive mode to be closed.
|
double |
niblackVarianceThresh
Niblack threshold.
|
private static String |
operatorID
Identifier string for this operator class.
|
PaCeQuant.OperationMode |
opMode
Mode of operation of the operator.
|
private String |
phaseAInfo
Info string for segmentation phase configuration parameters.
|
private String |
phaseBInfo
Info string for segmentation phase configuration parameters.
|
private PaCeQuant.OperatorPhasesToRun |
phasesToRun
Select with phases to run.
|
private PaCeQuant.PixelCalibration |
pixCalibMode
Mode for calibrating physical pixel size.
|
private double |
pixelLengthXY
Physical size of a pixel.
|
private double |
pixelLengthXYinternal
Pixel length only used internally.
|
private String |
pixelUnitString
Unit for pixel length.
|
private MTBImageRGB |
resultAdditionalImages
Additional result images condensed into a single stack
(only available if
showAdditionalResultImages is true). |
private MTBImageShort |
resultCellLabelImg
Label image of detected cell regions.
|
private MTBImageRGB |
resultCellOverlayImg
Overlay of input image with pseudo-colored cell regions.
|
private MTBRegion2DSet |
resultCellRegions
Set of detected cell regions.
|
private MTBImageRGB |
resultFeatureStack
Stack of individual feature images as heat maps
(only available if
showResultFeatureStack is true). |
private MTBTableModel |
resultFeatureTable
Table with region features.
|
private String |
resultInfo
Info string for segmentation phase configuration parameters.
|
private Vector<MTBTableModel> |
resultLobeFeatureTables
(Optional) set of tables with type information and features per lobe.
|
private MTBImageRGB |
resultLobeTypeImage
Image showing lobe classification.
|
private double |
resultMaxRegionSizeThreshold
Used threshold for maximal size of valid regions.
|
private double |
resultMinRegionSizeThreshold
Used threshold for minimal size of valid regions.
|
private PaCeQuant.SegmentationInputFormat |
segmentationInputFormat
Format of external segmentation input.
|
private static String[] |
segmentationParameters
List of parameters relevant for segmentation phase.
|
private boolean |
showAdditionalResultImages
Flag to enable/disable showing additional and intermediate result
images.
|
private boolean |
showResultFeatureStack
Flag to enable/disable showing feature visualization stack.
|
private PaCeQuant.MeasurementUnits |
thresholdUnits
Units for size thresholds.
|
private PaCeQuant.MeasurementUnits |
unitXY
Physical pixel size units.
|
private MTBImage |
vesselImg
Result of vesselness detection (for internal use only).
|
private int |
width
Width of the input image.
|
Constructor and Description |
---|
PaCeQuant()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private MTBTableModel |
calculateRegionFeatures(MTBRegion2DSet regions,
MTBImage labelImg)
Extracts features for all detected and valid cell regions.
|
private MTBImageByte |
closeGapsNativeLinks(MTBImageByte skelImg)
Method to close gaps by linking adjacent endpoints.
|
private MTBImageByte |
closeGapsWatershed(MTBImageByte skelImg)
Method to close gaps by watershed transformation.
|
protected static void |
drawStringToImage(MTBImageRGB img,
String s,
int r,
int g,
int b,
int xPos,
int yPos)
Draws string at given position into image.
|
protected static void |
drawStringToImage(MTBImageShort img,
String s,
int g,
int xPos,
int yPos)
Draws string at given position into image.
|
private MTBRegion2DSet |
filterValidCellRegions(MTBImageByte image)
Postprocesses cell regions and applies some filtering.
|
protected void |
operate() |
protected void |
prepareAdditionalResultDataStack(String title) |
protected void |
reinitOperator()
Re-initialize the operator just in case it was already run before.
|
protected MTBTableModel |
runFeatureExtractionPhase(MTBImage img,
MTBRegion2DSet validRegions,
MTBImage labelImg)
Extracts features from given set of regions and corresponding images
|
protected PaCeQuant.SegmentationResult |
runSegmentationPhase(MTBImage img)
Method that processes a single image.
|
protected void |
saveRegionData(String resultDir,
String fileRoot,
MTBRegion2DSet regions)
Save region set to output file.
|
private MTBImageByte |
segmentInputImage(MTBImage img)
Preprocessing and segmentation of input image.
|
private void |
switchGapCloseMode()
Callback routine called if gap closing mode parameter changes.
|
private void |
switchOpModeParameters()
Callback routine to change operator mode parameters.
|
private void |
switchPhaseConfigParameters()
Callback routine to change phase parameters.
|
private void |
switchPixelCalibParameters()
Callback routine called if pixel calibration mode parameter changes.
|
private void |
switchSegmentationFormatParameter()
Callback routine called if format parameter changes.
|
void |
validateCustom() |
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getDocumentation, 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, validateGeneric, writeHistory, writeHistory, writeHistory
private static final String operatorID
private static transient String[] segmentationParameters
private static transient String[] featureParameters
@Parameter(label="Select phases to run", required=true, direction=IN, dataIOOrder=-10, mode=STANDARD, callback="switchPhaseConfigParameters", paramModificationMode=MODIFIES_INTERFACE, description="Choose between segmentation and/or feature extraction.") private PaCeQuant.OperatorPhasesToRun phasesToRun
@Parameter(label=" Format of external segmentation data", required=true, direction=IN, dataIOOrder=-8, mode=STANDARD, callback="switchSegmentationFormatParameter", paramModificationMode=MODIFIES_INTERFACE, description="Segmentation data format.") private PaCeQuant.SegmentationInputFormat segmentationInputFormat
This parameter is only used if no segmentation is done by PaCeQuant.
@Parameter(label="Operation Mode", required=true, direction=IN, dataIOOrder=-5, description="Operation mode of the operator.", callback="switchOpModeParameters", paramModificationMode=MODIFIES_INTERFACE) public PaCeQuant.OperationMode opMode
public PaCeQuant.ImageType imType
@Parameter(label="Input Directory", required=true, direction=IN, description="Input directory.", dataIOOrder=-3) private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString inDir
Depending on the chosen input type the image can either be given by an 8-bit grayscale image or a binary image. In the first case the image is preprocessed and segmentation procedures are applied to identify individual cell regions. In the latter case it is assumend that the cells have already been segmented and each cell is represented by a connected component, i.e. the preprocessing and segmentation steps are skipped.
@Parameter(label="Input Image", required=true, direction=IN, description="Input image.", dataIOOrder=-3) private transient MTBImageByte inImg
Depending on the chosen input type the image can either be given by an 8-bit grayscale image or a binary image. In the first case the image is preprocessed and segmentation procedures are applied to identify individual cell regions. In the latter case it is assumend that the cells have already been segmented and each cell is represented by a connected component, i.e. the preprocessing and segmentation steps are skipped.
@Parameter(label="Input Regions", required=true, direction=IN, description="Input image.", dataIOOrder=-3) private transient MTBRegion2DSet inRegions
Depending on the chosen input type the image can either be given by an 8-bit grayscale image or a binary image. In the first case the image is preprocessed and segmentation procedures are applied to identify individual cell regions. In the latter case it is assumend that the cells have already been segmented and each cell is represented by a connected component, i.e. the preprocessing and segmentation steps are skipped.
@Parameter(label="Pixel calibration mode", required=true, direction=IN, dataIOOrder=0, description="In AUTO mode data is extracted from input data.", callback="switchPixelCalibParameters", paramModificationMode=MODIFIES_INTERFACE) private PaCeQuant.PixelCalibration pixCalibMode
@Parameter(label="Pixel length", required=true, direction=IN, description="Pixel length, note that we assume square pixels!", dataIOOrder=1) private double pixelLengthXY
@Parameter(label="Size unit x/y", required=true, direction=IN, description="Pixel units.", dataIOOrder=2) private PaCeQuant.MeasurementUnits unitXY
@Parameter(label="Configure segmentation phase:", required=true, direction=IN, dataIOOrder=3, info=true, mode=STANDARD, description="Info string.") private String phaseAInfo
@Parameter(label="Border Contrast", required=true, direction=IN, dataIOOrder=4, description="Border to background relation.") public PaCeQuant.BorderBackgroundContrast borderContrast
@Parameter(label="Heuristic for Gap Closing", required=true, direction=IN, dataIOOrder=6, description="Choose mode for closing gaps.", callback="switchGapCloseMode", paramModificationMode=MODIFIES_INTERFACE) private PaCeQuant.GapCloseMode gapMode
@Parameter(label=" End-point distance for naive heuristic", required=true, direction=IN, dataIOOrder=7, description="Maximal distance of end-points to be linked.") private int naiveGapThreshold
@Parameter(label="Unit for Size Thresholds", required=true, direction=IN, dataIOOrder=8, description="Unit of specified size thresholds.") private PaCeQuant.MeasurementUnits thresholdUnits
@Parameter(label="Minimal Size of Cells", required=true, direction=IN, dataIOOrder=8, description="Cells smaller than this threshold are discarded.") private double minimalCellSize
Cell regions falling below this threshold are ignored.
@Parameter(label="Maximal Size of Cells", required=true, direction=IN, dataIOOrder=9, description="Cells larger than this threshold are discarded.") private double maximalCellSize
Cell regions lying above this threshold are ignored.
@Parameter(label="Configure feature extraction phase:", required=true, direction=IN, dataIOOrder=10, info=true, mode=STANDARD, description="Info string.") private String phaseBInfo
@Parameter(label="Feature Extraction", required=true, direction=IN, dataIOOrder=11, mode=STANDARD, description="Feature extraction operator.") private MorphologyAnalyzer2D morphFeatureOp
@Parameter(label="Analyze lobe types?", required=true, direction=IN, dataIOOrder=12, mode=STANDARD, description="Enable/disable lobe types.") private boolean classifyLobes
@Parameter(label="Niblack threshold", required=false, direction=IN, dataIOOrder=-5, mode=ADVANCED, description="Threshold for variance check in Niblack binarization.") public double niblackVarianceThresh
@Parameter(label="Configure result data:", required=false, direction=IN, dataIOOrder=0, info=true, mode=STANDARD, description="Info string.") private String resultInfo
@Parameter(label="Draw region IDs to output images?", required=false, direction=IN, dataIOOrder=10, mode=STANDARD, description="Enable/disable drawing of region IDs.") private boolean drawRegionIDsToOutputImages
@Parameter(label="Show/save additional results?", required=false, supplemental=true, direction=IN, dataIOOrder=1, mode=STANDARD, description="Enable/disable showing additional results.") private boolean showAdditionalResultImages
@Parameter(label="Show/save feature stack? (takes some time...)", required=false, supplemental=true, direction=IN, dataIOOrder=2, mode=STANDARD, description="Enable/disable showing feature stack.") private boolean showResultFeatureStack
Attention, stack is large, saving to disk takes some time!
@Parameter(label="Detected cell regions", supplemental=false, direction=OUT, dataIOOrder=0, description="Set of detected and filtered cell regions.") private transient MTBRegion2DSet resultCellRegions
@Parameter(label="Result Table of Feature Value", dataIOOrder=1, direction=OUT, description="Result table of region features.") private transient MTBTableModel resultFeatureTable
Each row contains one region, each column corresponds to a feature.
@Parameter(label="Detected Cell Regions Image", dataIOOrder=2, direction=OUT, description="Image of detected cell regions (overlay).") private transient MTBImageRGB resultCellOverlayImg
@Parameter(label="Label Image of Detected Cell Regions", dataIOOrder=3, direction=OUT, description="Label image of detected cell regions.") private transient MTBImageShort resultCellLabelImg
@Parameter(label="Minimal Size of Valid Regions", dataIOOrder=4, direction=OUT, description="Calculated threshold for filtering regions.") private double resultMinRegionSizeThreshold
@Parameter(label="Maximal Size of Valid Regions", dataIOOrder=5, direction=OUT, description="Calculated threshold for filtering regions.") private double resultMaxRegionSizeThreshold
@Parameter(label="Result Tables of Lobe Types and Features", dataIOOrder=6, direction=OUT, description="Result tables of lobe types and features.") private transient Vector<MTBTableModel> resultLobeFeatureTables
These data are only available if classifyLobes
is true.
@Parameter(label="Result Image with Lobe Types", dataIOOrder=7, direction=OUT, description="Image displaying lobe types.") private transient MTBImageRGB resultLobeTypeImage
This result image is only available if classifyLobes
is true.
@Parameter(label="Additonal Result Images", dataIOOrder=0, direction=OUT, supplemental=true, description="Additional result images (as stack).") private transient MTBImageRGB resultAdditionalImages
showAdditionalResultImages
is true).@Parameter(label="Result Feature Stack", dataIOOrder=5, direction=OUT, supplemental=true, description="Result image stack with feature values.") private transient MTBImageRGB resultFeatureStack
showResultFeatureStack
is true).private transient int width
private transient int height
private double pixelLengthXYinternal
private String pixelUnitString
private transient MTBImage gaussFilterImg
private transient MTBImage vesselImg
private transient Vector<MTBImageRGB> addResultImages
public PaCeQuant() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown if construction fails.private void switchOpModeParameters()
private void switchPixelCalibParameters()
private void switchSegmentationFormatParameter()
private void switchPhaseConfigParameters()
private void switchGapCloseMode()
public void validateCustom() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
validateCustom
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
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
protected void reinitOperator()
protected void saveRegionData(String resultDir, String fileRoot, MTBRegion2DSet regions) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
This method saves each region of the set to an individual output file and in addition all regions together to a common zip file.
resultDir
- Directory where to save the files.fileRoot
- Common root of all file names.regions
- Set of regions to save.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.protected void prepareAdditionalResultDataStack(String title)
protected PaCeQuant.SegmentationResult runSegmentationPhase(MTBImage img) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
img
- Image to process.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.protected MTBTableModel runFeatureExtractionPhase(MTBImage img, MTBRegion2DSet validRegions, MTBImage labelImg) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
img
- Input image to process.validRegions
- Corresponding set of regions.labelImg
- Corresponding label image.MorphologyAnalyzer2D
.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.private MTBImageByte segmentInputImage(MTBImage img) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
img
- Image to process.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of processing failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of problems with processing history.private MTBImageByte closeGapsWatershed(MTBImageByte skelImg) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
skelImg
- Input skeleton image of cell borders.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.private MTBImageByte closeGapsNativeLinks(MTBImageByte skelImg)
skelImg
- Input skeleton image of cell borders.private MTBRegion2DSet filterValidCellRegions(MTBImageByte image) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
The method mainly targets at discarding invalid regions, e.g., regions which are too small, touch the image border, or which most likely refer to more than one cell and have accidentally been merged.
image
- Binary input image (regions white, background black).de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of operation failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of problems with the processing history.private MTBTableModel calculateRegionFeatures(MTBRegion2DSet regions, MTBImage labelImg) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
regions
- Set of valid regions.labelImg
- Corresponding label image of region set.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of problems with the processing history.protected static void drawStringToImage(MTBImageRGB img, String s, int r, int g, int b, int xPos, int yPos)
img
- Image where to draw the string into.s
- String to draw.r
- Red color ratio.g
- Green color ratio.b
- Blue color ratio.xPos
- Position of string in x.yPos
- Position of string in y.protected static void drawStringToImage(MTBImageShort img, String s, int g, int xPos, int yPos)
img
- Image where to draw the string into.s
- String to draw.g
- Grayscale value.xPos
- Position of string in x.yPos
- Position of string in y.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.