|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.image.ImageFilter
java.awt.image.RGBImageFilter
BrightnessContrastFilter
public class BrightnessContrastFilter
Class BrightnessContrastFilter implements RGBFilter for image adjustment to implement a contrast/brightness filter. It maps the unscaled (brightness,contrast) values with maximum (maxBrightness,maxContrast) to brightness and contrast values (bScaled,cScaled) in [0.0:1.0]. The Filter maps RGB pixel values to a new RGB pixel value as a function of (bScaled,cScaled) and the (maxGray,minG,maxG) of the image.
The brightness, contrast model assumes that the half-way range of each is the original image value. The transform for the new gray value g' is: g' = slopeC*g + bIntercept. These are derived as follows: maxSlopeC= maxGray / (maxG - minG), bIntercept = (bScaled - 0.5) * (2 * maxGray). We then compute the contrast intercept to cover the complete range so that 1. if cScaled=1.0, then slopeC= maxSlopeC, 2. if cScaled=0.5, then slopeC= 1.0. Then, ssM= maxSlopeC-1.0) / 0.5, ssB= (0.5 * maxSlopeC + 2), and then, slopeC= ssM*cScaled + ssB.The filtering part is derived from the code in the Chan & Lee "The Java Class Library", (JDK1.0.2) pg 1143.
This is also similar to the example in the more recent JavaClassLibJDK1.1.2/JavaClassVol2/java/awt.image/ RGBImageFilter/canFilterIndexColorModel
This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Flicker Mozilla and Legal files are available on http://open2dprot.sourceforge.net/Flicker
Field Summary | |
---|---|
(package private) int |
b
current BLUE pixel when filter is running |
(package private) float |
bIntercept
brightness intercept is (bS -0.5)*(2*maxGray) |
(package private) float |
bScaled
scaled current brightness value to range of [0:1.0] |
(package private) int |
colorMode
method to use when filter RBG: (NORM_COLOR, PSEUDO_COLOR, RGB_TO_GRAY_COLOR) |
(package private) float |
cScaled
scaled current contrast value to range of [0:1.0] |
private static int |
dbugCtr
|
(package private) static Flicker |
flk
flicker instance |
(package private) int |
g
current GREEN pixel when filter is running |
(package private) float |
hue
current hue pixel value when HSV filtering |
(package private) ImageScroller |
is
The Image Scroller for the image data to compute filter on |
int |
maxG
maximum Gray value seen in the original inputpixels[]. |
(package private) int |
maxGray
|
(package private) float |
maxSlopeC
maximum contrast needed to cover the maximum dynamic range compute as: maxSlopeC= maxGray/(maxG-minG)); |
int |
minG
minimum Gray value seen in the original inputpixels[]. |
(package private) int |
newRGBpixel
current new RGB pixel when filter is running |
(package private) boolean |
pseudoColorFlag
true if pseudo color else grayscale. |
(package private) int |
r
current RED pixel when filter is running |
(package private) int[] |
rgb3
array hold return values (R,G,B) for hsv2rgb(H,S,V) |
(package private) boolean |
rgbToGrayFlag
cvt RGB to grayscale. |
(package private) float |
saturation
current saturation pixel value when HSV filtering |
(package private) float |
slopeC
contrast slope is (cS -0.5)*maxSlopeC |
(package private) float |
value
current value pixel value when HSV filtering |
Fields inherited from class java.awt.image.RGBImageFilter |
---|
canFilterIndexColorModel, newmodel, origmodel |
Fields inherited from class java.awt.image.ImageFilter |
---|
consumer |
Fields inherited from interface java.awt.image.ImageConsumer |
---|
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT |
Constructor Summary | |
---|---|
BrightnessContrastFilter(Flicker flkS)
BrightnessContrastFilter() - constructor. |
Method Summary | |
---|---|
(package private) char |
cvByteToChar(byte b)
cvByteToChar() - convert signed byte [-128:+127] to unsigned char in range [0:255] |
(package private) int |
cvByteToInt(byte b)
cvByteToInt() - convert signed byte [-128:+127] to unsigned int in range [0:255] |
(package private) byte |
cvIntToByte(int i)
cvIntToByte() - convert int in range [0:255] to signed byte in range of [-128:+127]. |
int |
filterRGB(int x,
int y,
int rgbPixel)
filterRGB() - 1:1 pixel filtering required for RGBFilter class. |
(package private) void |
hsv2rgb(float hue,
float saturation,
float value,
int[] rgb)
hsv2rgb() - convert (hue,saturation,value) color model to (red,green,blue) color model. |
(package private) void |
setBrCt(ImageScroller is,
int brightness,
int contrast,
int maxBrightness,
int maxContrast,
boolean calcBrightnessFlag)
setBrCt() - set parameters for the filter when it is invoked by pressing or dragging the mouse with the Shift key pressed. |
Methods inherited from class java.awt.image.RGBImageFilter |
---|
filterIndexColorModel, filterRGBPixels, setColorModel, setPixels, setPixels, substituteColorModel |
Methods inherited from class java.awt.image.ImageFilter |
---|
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setProperties |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int dbugCtr
static Flicker flk
ImageScroller is
int colorMode
boolean rgbToGrayFlag
boolean pseudoColorFlag
int[] rgb3
float hue
float saturation
float value
int r
int g
int b
int newRGBpixel
int maxGray
public int maxG
public int minG
float maxSlopeC
float bIntercept
float slopeC
float bScaled
float cScaled
Constructor Detail |
---|
public BrightnessContrastFilter(Flicker flkS)
Method Detail |
---|
final void setBrCt(ImageScroller is, int brightness, int contrast, int maxBrightness, int maxContrast, boolean calcBrightnessFlag)
is
- is the image data to compute filter onbrightness
- new value of brightness [0:maxBrightness-1], unscaledcontrast
- new value of contrast [0:maxContrast-1], unscaledmaxBrightness
- max value of brightness, unscaledmaxContrast
- max value of contrast, unscaledcalcBrightnessFlag
- use slider values or calc via mousedDragged
[DEPRICATED]final void hsv2rgb(float hue, float saturation, float value, int[] rgb)
hue
- in the range of [0.0:1.0]saturation
- in the range of [0.0:1.0] default to 1.0value
- of dynamic rangergb
- is the red[0], green[1], blue[3] colormapfinal int cvByteToInt(byte b)
b
- is byte to convert
final char cvByteToChar(byte b)
b
- is byte to convert
final byte cvIntToByte(int i)
i
- is integer to convert
public int filterRGB(int x, int y, int rgbPixel)
filterRGB
in class java.awt.image.RGBImageFilter
x
- coordinate of pixel (not used)y
- coordinate of pixel (not used)rgb
- is pixel (r,g,b) value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |