@ALDAOperator(genericExecutionMode=ALL,
level=APPLICATION,
allowBatchMode=false)
public class LabelImageEditor
extends MTBOperator
implements MouseListener, MouseMotionListener, ActionListener
The editor supports removing regions by one-click operations. Images can
be relabeled and open contour branches be removed. Also holes within
regions, i.e., background sections and small regions completely surrounded
by another region, can be eliminated.
Short gaps in boundaries can be closed by drawing free-hand lines
by mouse.
To enhance the display of an image the contrast of region labels can be
improved by shifting dark labels into a higher interval of gray-scale
values increasing the difference (contrast) to the black background.
| Modifier and Type | Field and Description |
|---|---|
private MTBImageShort |
activeImage
Image currently under processing.
|
private ij.ImagePlus |
activePlus
Reference to currently active image.
|
private ij.process.ImageProcessor |
activeProcessor
Reference to processor of currently active image
activePlus. |
private JRadioButton |
buttonBlack
Button to select black pen color in drawing.
|
private JRadioButton |
buttonWhite
Button to select white pen color in drawing.
|
private boolean |
calledFirstTime
Flag to ensure that callback only works once the operator has been called.
|
private static String |
classID
Class identifier.
|
private String |
currentFile
Full path name of currently active image file.
|
private static int |
defaultDrawLineWidth
Default width of freehand border lines.
|
private static int |
defaultMaxBorderWidth
Maximal border width default value.
|
private boolean |
finished
Flag to indicate if operations are finished.
|
private ij.gui.ImageCanvas |
ic
Image canvas for displaying image and interacting.
|
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
inputDir
Image directory to process.
|
private String |
inputRegExp
Optional file filter.
|
private String |
internalOutputDir
Internal variable of output dir (to avoid modifying parameter).
|
private int |
lastLabel
Stores the last clicked label for transfer in memory mode.
|
private Point2D.Double |
lastPathPoint
Local helper variable in drawing new boundaries,
stores last point of current path.
|
private ij.process.ImageProcessor |
lastProcessor
Reference to last processor before last action.
|
private JFrame |
mainFrame
Main window frame.
|
private boolean |
memoryMode
In memory mode labels can be transferred from one region to another.
|
private JTextField |
optionsBorderMaxWidth
Text field with current maximal border width.
|
private JTextField |
optionsDrawLineWidth
Text field with current width of lines when drawing boundaries.
|
private JFrame |
optionsFrame
Window for setting some options and configuration parameters.
|
private MTBImage |
originalImage
Original image currently under processing.
|
private String |
outFileEnding
Optional output file suffix.
|
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
outputDir
Optional output directory.
|
private boolean |
scanPath
Local flag to indicate if we are currently tracing a path
for a new piece of boundary.
|
private boolean |
stillActive
Flag to indicate if process is still active.
|
| Constructor and Description |
|---|
LabelImageEditor()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(ActionEvent e) |
private void |
callbackInputDir()
Callback function called in case of changes of parameter
inputDir. |
private void |
initMainFrame()
Initialize the main window on opening the first image.
|
private void |
initOptionsFrame()
Initialize the options window.
|
private static void |
labelNeighbors(ij.process.ImageProcessor ip,
int px,
int py,
int label)
Recursively label neighbors until approaching next region.
|
void |
mouseClicked(MouseEvent e) |
void |
mouseDragged(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mouseMoved(MouseEvent e) |
void |
mousePressed(MouseEvent e) |
void |
mouseReleased(MouseEvent e) |
protected void |
operate() |
private void |
optimizeContrast(ij.process.ImageProcessor ip)
Optimize visibility by shifting labels into
upper part of gray-scale range.
|
private void |
saveFile()
Saves the current processing result.
|
readResolveaddOperatorExecutionProgressEventListener, 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, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistoryprivate static final String classID
private static final int defaultMaxBorderWidth
private static final int defaultDrawLineWidth
@Parameter(label="Input Directory",
required=true,
direction=IN,
description="Input directory.",
dataIOOrder=0,
callback="callbackInputDir",
paramModificationMode=MODIFIES_VALUES_ONLY)
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString inputDir
@Parameter(label="File Filter",
required=false,
direction=IN,
description="Regular expression to filter input files.",
dataIOOrder=0)
private String inputRegExp
@Parameter(label="Output Directory",
required=false,
direction=IN,
description="Output directory.",
dataIOOrder=1)
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString outputDir
If left unset results are saved to input directory.
@Parameter(label="Output file ending",
required=false,
direction=IN,
description="Output file ending.",
dataIOOrder=2)
private String outFileEnding
private JFrame mainFrame
private ij.gui.ImageCanvas ic
private MTBImage originalImage
private MTBImageShort activeImage
private ij.ImagePlus activePlus
private ij.process.ImageProcessor activeProcessor
activePlus.private ij.process.ImageProcessor lastProcessor
activePlus.private boolean stillActive
private String currentFile
private boolean finished
private String internalOutputDir
private boolean calledFirstTime
private boolean memoryMode
private int lastLabel
private boolean scanPath
private Point2D.Double lastPathPoint
private JFrame optionsFrame
private JTextField optionsBorderMaxWidth
private JTextField optionsDrawLineWidth
private JRadioButton buttonBlack
private JRadioButton buttonWhite
public LabelImageEditor()
throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException - Thrown if construction fails.protected void operate()
throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
operate in class de.unihalle.informatik.Alida.operator.ALDOperatorde.unihalle.informatik.Alida.exceptions.ALDOperatorExceptionpublic void mouseClicked(MouseEvent e)
mouseClicked in interface MouseListenerprivate static void labelNeighbors(ij.process.ImageProcessor ip,
int px,
int py,
int label)
ip - Image processor to modify.px - Position in x where to start.py - Position in y where to start.label - Label to assign to new region.public void mousePressed(MouseEvent e)
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent e)
mouseReleased in interface MouseListenerpublic void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent e)
mouseExited in interface MouseListenerpublic void mouseDragged(MouseEvent e)
mouseDragged in interface MouseMotionListenerpublic void mouseMoved(MouseEvent e)
mouseMoved in interface MouseMotionListenerpublic void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenerprivate void initMainFrame()
private void initOptionsFrame()
private void optimizeContrast(ij.process.ImageProcessor ip)
ip - Image processor to process.private void saveFile()
private void callbackInputDir()
Copyright © 2010–2025 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.