Class AlgorithmComplexToReal

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmComplexToReal
    extends AlgorithmBase
    Simple algorithm that converts an RGB image to a single greyscale image.

    User can specify red, green, and blue scaling factors Default is equal weighting new gray value = ( R + G + B) / 3 if no threshold averaging; if thresholdAverage is true, only average values above trheshold

    The standard for computer graphics is > Y = 0.299*R + 0.587*G + 0.114*B > > That assumes both Y and RGB are in the range 0:255 > > BT.601 calls for Y to be limited to 16:235, if you want > that multiply the constants by 219/255 and add 16 to Y.

    Yes, but Y is not pure luminance, the other components it might be PbPr, CbCr carry color information that affect perceived brightness.

    Author:
    Justin Senseney
    • Field Detail

      • intensityAverage

        private boolean intensityAverage
        If true indicates that the result image is an average of the three channels. Default is false
      • redValue

        private float redValue
        Weighting values for the red, green, and blue channels. Default all channels = 0.33333
      • greenValue

        private float greenValue
        Weighting values for the red, green, and blue channels. Default all channels = 0.33333
      • blueValue

        private float blueValue
        Weighting values for the red, green, and blue channels. Default all channels = 0.33333
      • thirdValue

        private float thirdValue
        This value equal one third (0.3333333).
      • threshold

        private float threshold
        Only average values above threshold.
      • thresholdAverage

        private boolean thresholdAverage
        If true only average values above threshold.
    • Constructor Detail

      • AlgorithmComplexToReal

        public AlgorithmComplexToReal​(ModelImage srcImg)
        Creates a new AlgorithmComplexToReal object.
        Parameters:
        srcImg - source image model
      • AlgorithmComplexToReal

        public AlgorithmComplexToReal​(ModelImage destImg,
                                      ModelImage srcImg)
        Creates a new AlgorithmComplexToReal object.
        Parameters:
        destImg - image model where result image is to stored
        srcImg - source image model
      • AlgorithmComplexToReal

        public AlgorithmComplexToReal​(ModelImage srcImg,
                                      float redValue,
                                      float greenValue,
                                      float blueValue,
                                      boolean thresholdAverage,
                                      float threshold,
                                      boolean intensityAverage)
        Creates a new AlgorithmComplexToReal object.
        Parameters:
        srcImg - source image model
        redValue - weighting of the red channel
        greenValue - weighting of the green channel
        blueValue - weighting of the blue channel
        thresholdAverage - if true only average values above threshold
        threshold - DOCUMENT ME!
        intensityAverage - DOCUMENT ME!
      • AlgorithmComplexToReal

        public AlgorithmComplexToReal​(ModelImage destImg,
                                      ModelImage srcImg,
                                      float redValue,
                                      float greenValue,
                                      float blueValue,
                                      boolean thresholdAverage,
                                      float threshold,
                                      boolean intensityAverage)
        Creates a new AlgorithmComplexToReal object.
        Parameters:
        destImg - image model where result image is to stored
        srcImg - source image model
        redValue - weighting of the red channel
        greenValue - weighting of the green channel
        blueValue - weighting of the blue channel
        thresholdAverage - if true only average values above threshold
        threshold - DOCUMENT ME!
        intensityAverage - DOCUMENT ME!
    • Method Detail

      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • calcStoreInDest

        private void calcStoreInDest()
        Calculates the gray scale image.
      • calcStoreInPlace

        private void calcStoreInPlace()
        Calculates the gray scale image. Must use getSrcImage() after running this routine