Class ImageClassificationHandler

  • All Implemented Interfaces:
    Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, ContentHandler, Serializable

    public class ImageClassificationHandler
    extends AbstractContentHandler
    Overlays the annotations onto the image.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -image-reader <adams.data.io.input.AbstractImageReader> (property: imageReader)
        The image reader to use.
        default: adams.data.io.input.JAIImageReader
     
    -file-suffix <java.lang.String> (property: fileSuffix)
        The forced suffix (incl ext) to append to the image name for generating
        the meta-data file name.
        default:
     
    -reader <adams.data.io.input.AbstractReportReader> (property: reader)
        The reader setup to use for reading the object locations from the spreadsheet.
        default: adams.data.io.input.DefaultSimpleReportReader
     
    -field-label <adams.data.report.Field> (property: fieldLabel)
        The field to store the label under.
        default: Classification[S]
     
    -field-score <adams.data.report.Field> (property: fieldScore)
        The field to store the score under.
        default: Score[N]
     
    -format <java.lang.String> (property: format)
        The label format string to use for the rectangles; '@' for type and '$'
        for short type, '{score}' gets replaced with the score (if present); for
        instance: '@' or '{score}'; in case of numeric values, use '|.X' to limit
        the number of decimals, eg '{score|.2}' for a maximum of decimals after
        the decimal point.
        default: $
     
    -font <java.awt.Font> (property: font)
        The font to use for the labels.
        default: Display-PLAIN-14
     
    -color <java.awt.Color> (property: color)
        The color of the text.
        default: #ff0000
     
    -offset-x <int> (property: offsetX)
        The X offset for the label; values of 0 or greater are interpreted as absolute
        pixels, -1 uses left as anchor, -2 the center and -3 the right.
        default: 20
     
    -offset-y <int> (property: offsetY)
        The Y offset for the label values of 0 or greater are interpreted as absolute
        pixels, -1 uses top as anchor, -2 the middle and -3 the bottom.
        default: 20
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_FileSuffix

        protected String m_FileSuffix
        the file suffix to force (incl extension).
      • m_ImageReader

        protected ImageReader m_ImageReader
        the image reader to use.
      • m_FieldLabel

        protected Field m_FieldLabel
        the report field to get the label from.
      • m_FieldScore

        protected Field m_FieldScore
        the report file to get the score from.
      • m_Format

        protected String m_Format
        the label for the label.
      • m_Font

        protected Font m_Font
        the label font.
      • m_Color

        protected Color m_Color
        the color of the text.
      • m_OffsetX

        protected int m_OffsetX
        the x offset for the label.
      • m_OffsetY

        protected int m_OffsetY
        the y offset for the label.
    • Constructor Detail

      • ImageClassificationHandler

        public ImageClassificationHandler()
    • Method Detail

      • getDefaultImageReader

        protected ImageReader getDefaultImageReader()
        Returns the default image reader.
        Returns:
        the default
      • setImageReader

        public void setImageReader​(ImageReader value)
        Sets the image reader to use.
        Parameters:
        value - the reader
      • getImageReader

        public ImageReader getImageReader()
        Returns the image reader to use.
        Returns:
        the reader
      • imageReaderTipText

        public String imageReaderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getDefaultReader

        protected AbstractReportReader getDefaultReader()
        Returns the default reader.
        Returns:
        the reader
      • setFileSuffix

        public void setFileSuffix​(String value)
        Sets the forced suffix (incl ext) to append to the image name for generating the meta-data file name.
        Parameters:
        value - the suffix
      • getFileSuffix

        public String getFileSuffix()
        Returns the forced suffix (incl ext) to append to the image name for generating the meta-data file name.
        Returns:
        the suffix
      • fileSuffixTipText

        public String fileSuffixTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setReader

        public void setReader​(AbstractReportReader value)
        Sets the reader setup to use for reading the object locations from the spreadsheet.
        Parameters:
        value - the reader
      • getReader

        public AbstractReportReader getReader()
        Returns the reader setup to use for reading the object locations from the spreadsheet.
        Returns:
        the reader
      • readerTipText

        public String readerTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFieldLabel

        public void setFieldLabel​(Field value)
        Sets the field for the label.
        Parameters:
        value - the field
      • getFieldLabel

        public Field getFieldLabel()
        Returns the field for the label.
        Returns:
        the field
      • fieldLabelTipText

        public String fieldLabelTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFieldScore

        public void setFieldScore​(Field value)
        Sets the field for the score.
        Parameters:
        value - the field
      • getFieldScore

        public Field getFieldScore()
        Returns the field for the score.
        Returns:
        the field
      • fieldScoreTipText

        public String fieldScoreTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFormat

        public void setFormat​(String value)
        Sets the label format.
        Parameters:
        value - the label format
      • getFormat

        public String getFormat()
        Returns the label format.
        Returns:
        the label format
      • formatTipText

        public String formatTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFont

        public void setFont​(Font value)
        Sets the label font.
        Parameters:
        value - the label font
      • getFont

        public Font getFont()
        Returns the label font.
        Returns:
        the label font
      • fontTipText

        public String fontTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setColor

        public void setColor​(Color value)
        Sets the color of the text.
        Parameters:
        value - the color
      • getColor

        public Color getColor()
        Returns the color of the text.
        Returns:
        the color
      • colorTipText

        public String colorTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setOffsetX

        public void setOffsetX​(int value)
        Sets the X offset for the label.
        Parameters:
        value - the X offset
      • getOffsetX

        public int getOffsetX()
        Returns the X offset for the label.
        Returns:
        the X offset
      • offsetXTipText

        public String offsetXTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setOffsetY

        public void setOffsetY​(int value)
        Sets the Y offset for the label.
        Parameters:
        value - the Y offset
      • getOffsetY

        public int getOffsetY()
        Returns the Y offset for the label.
        Returns:
        the Y offset
      • offsetYTipText

        public String offsetYTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getExtensions

        public String[] getExtensions()
        Returns the list of extensions (without dot) that this handler can take care of.
        Returns:
        the list of extensions (no dot)
      • applyLabelFormat

        protected String applyLabelFormat​(String label,
                                          Double score,
                                          String labelFormat)
        Applies the label format to the object to generate a display string.
        Parameters:
        label - the label to use
        score - the score to use, ignored if null
        labelFormat - the label format to use
        Returns:
        the generated label
      • loadAnnotations

        protected Report loadAnnotations​(ImagePanel panel,
                                         File file)
        Loads the report associated with the image.
        Parameters:
        panel - the context panel
        file - the image file
        Returns:
        the report, null if failed to load report data or none available