Class AlgorithmRGBtoGray
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.utilities.AlgorithmRGBtoGray
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.awt.event.WindowListener,java.lang.Runnable,java.util.EventListener
public class AlgorithmRGBtoGray 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.
- Version:
- 1.0 Dec 30, 1999
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description private floatblueValueWeighting values for the red, green, and blue channels.private booleanequalRangeprivate floatgreenValueWeighting values for the red, green, and blue channels.private booleanintensityAverageIf true indicates that the result image is an average of the three channels.private floatmaxBprivate floatmaxGprivate floatmaxRprivate floatminBprivate floatminGprivate floatminRprivate floatredValueWeighting values for the red, green, and blue channels.private floatthirdValueThis value equal one third (0.3333333).private floatthresholdOnly average values above threshold.private booleanthresholdAverageIf true only average values above threshold.-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmRGBtoGray(ModelImage srcImg)Creates a new AlgorithmRGBtoGray object.AlgorithmRGBtoGray(ModelImage srcImg, float redValue, float greenValue, float blueValue, boolean thresholdAverage, float threshold, boolean intensityAverage, boolean equalRange, float minR, float maxR, float minG, float maxG, float minB, float maxB)Creates a new AlgorithmRGBtoGray object.AlgorithmRGBtoGray(ModelImage destImg, ModelImage srcImg)Creates a new AlgorithmRGBtoGray object.AlgorithmRGBtoGray(ModelImage destImg, ModelImage srcImg, float redValue, float greenValue, float blueValue, boolean thresholdAverage, float threshold, boolean intensityAverage, boolean equalRange, float minR, float maxR, float minG, float maxG, float minB, float maxB)Creates a new AlgorithmRGBtoGray object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalcStoreInDest()Calculates the gray scale image.private voidcalcStoreInPlace()Calculates the gray scale image.voidfinalize()Prepares this class for destruction.voidrunAlgorithm()Starts the program.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
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.
-
equalRange
private boolean equalRange
-
minR
private float minR
-
maxR
private float maxR
-
minG
private float minG
-
maxG
private float maxG
-
minB
private float minB
-
maxB
private float maxB
-
-
Constructor Detail
-
AlgorithmRGBtoGray
public AlgorithmRGBtoGray(ModelImage srcImg)
Creates a new AlgorithmRGBtoGray object.- Parameters:
srcImg- source image model
-
AlgorithmRGBtoGray
public AlgorithmRGBtoGray(ModelImage destImg, ModelImage srcImg)
Creates a new AlgorithmRGBtoGray object.- Parameters:
destImg- image model where result image is to storedsrcImg- source image model
-
AlgorithmRGBtoGray
public AlgorithmRGBtoGray(ModelImage srcImg, float redValue, float greenValue, float blueValue, boolean thresholdAverage, float threshold, boolean intensityAverage, boolean equalRange, float minR, float maxR, float minG, float maxG, float minB, float maxB)
Creates a new AlgorithmRGBtoGray object.- Parameters:
srcImg- source image modelredValue- weighting of the red channelgreenValue- weighting of the green channelblueValue- weighting of the blue channelthresholdAverage- if true only average values above thresholdthreshold- DOCUMENT ME!intensityAverage- DOCUMENT ME!
-
AlgorithmRGBtoGray
public AlgorithmRGBtoGray(ModelImage destImg, ModelImage srcImg, float redValue, float greenValue, float blueValue, boolean thresholdAverage, float threshold, boolean intensityAverage, boolean equalRange, float minR, float maxR, float minG, float maxG, float minB, float maxB)
Creates a new AlgorithmRGBtoGray object.- Parameters:
destImg- image model where result image is to storedsrcImg- source image modelredValue- weighting of the red channelgreenValue- weighting of the green channelblueValue- weighting of the blue channelthresholdAverage- if true only average values above thresholdthreshold- DOCUMENT ME!intensityAverage- DOCUMENT ME!
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithmin classAlgorithmBase
-
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
-
-