|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xinapse.multisliceimage.ColourMapping
public class ColourMapping
The ColourMapping class represents a mapping from pixel presentation values (PPVs) to colours that are displayed as an image.
The class has a number of built-in colour mappings, and contains the methods to create custom colour mappings. This class also contains methods to convert from a set of pixel presentation values (pixel values) to colour values that should be displayed on screen.
Included is the capability to set the display characteristics (approximately) according to the DICOM Grayscale Standard Display Function, as described in Part 14 of the DICOM standards. This allows the two ColourMappings MONOCHROME1 and MONOCHROME2 to be set and updated according to local display conditions. The factors taken into account when setting these ColourMappings are:
The settings are stored in the user Preferences, on a host-by-host basis, and so should be set by every user for every computer that he or she uses.
N.B. no other ColourMappings are affected by the display settings.
This Class also implements Icon, so that the ColourMapping can be used to generate icons representing the ColourMapping.
| Field Summary | |
|---|---|
static ColourMapping |
BLUE
The ColourMapping representing a blue intensity scale. |
java.awt.image.IndexColorModel |
cm
The IndexColorModel used to contain the mapping. |
static ColourMapping |
COOL
The Cool ColourMapping scale. |
static ColourMapping |
CYAN
The ColourMapping representing a cyan intensity scale. |
static float |
DEFAULT_GAMMA
The default gamma value of the computer display. |
static float |
DEFAULT_MAX_LUMINANCE
The default luminance of the computer display for a digital driver level (DDL) of 255, including the effects of ambient light. |
static float |
DEFAULT_MIN_LUMINANCE
The default luminance of the computer display for a digital driver level (DDL) of zero, including the effects of ambient light. |
static ColourMapping |
GREEN
The ColourMapping representing a green intensity scale. |
static ColourMapping |
HOBS
The ColourMapping representing a hot body (black to white via red) intensity scale. |
static ColourMapping |
MAGENTA
The ColourMapping representing a magenta intensity scale. |
static float |
MAX_GAMMA
The maximum display gamma value that is allowed. |
static float |
MAX_LUMINANCE
The maximum value of display luminance (for a DDL of 255) that is allowed (including ambient light). |
static float |
MIN_GAMMA
The minimum display gamma value that is allowed. |
static float |
MIN_LUMINANCE
The minimum value of display luminance (for a DDL of zero) that is allowed (including ambient light). |
static ColourMapping |
MONOCHROME1
The ColourMapping representing a grey (white to black) intensity scale. |
static ColourMapping |
MONOCHROME2
The ColourMapping representing a grey (black to white) intensity scale. |
static ColourMapping |
RBOW1
The ColourMapping representing a rainbow of colours intensity scale. |
static ColourMapping |
RBOW2
The ColourMapping representing an alternative rainbow of colours intensity scale. |
static ColourMapping |
RED
The ColourMapping representing a red intensity scale. |
static ColourMapping |
STEP
The ColourMapping representing a step change in intensity scale. |
static ColourMapping |
YELLOW
The ColourMapping representing a yellow intensity scale. |
| Constructor Summary | |
|---|---|
ColourMapping(byte[] red,
byte[] green,
byte[] blue)
Creates a new ColourMapping object from a set of red, green and blue gun values. |
|
ColourMapping(short nSlots)
Creates an empty ColourMapping with the specified number of slots in the map. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Returns an exact copy of this ColourMapping. |
void |
colourLookup(int nCols,
int nRows,
java.lang.Object pixValues,
int offset,
PixelDataType dataType,
byte[] bytePixel,
double min,
double max,
boolean inverted,
boolean[] mask,
boolean interpolate,
ComplexMode complexMode)
Converts an array of pixel intensity values into the byte values that can then be used as an argument in the getRaster().setDataElements() method of BufferedImage to put pixel colours to a BufferedImage Object. |
static void |
colourLookupColourPacked(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
Converts an array of pixel intensity values into the int values that can then be used as an argument in the getRaster().setDataElements() method of BufferedImage to put pixel colours to a BufferedImage Object. |
static void |
colourLookupRGBByPlane(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
Converts an array of pixel intensity values into the int values that can then be used as an argument in the getRaster().setDataElements() method of BufferedImage to put pixel colours to a BufferedImage Object. |
static void |
colourLookupRGBInterlaced(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
Converts an array of pixel intensity values into the int values that can then be used as an argument in the getRaster().setDataElements() method of BufferedImage to put pixel colours to a BufferedImage Object. |
static ColourMapping |
get(java.lang.String name)
Returns one of the "built-in" ColourMappings, selected according to its name. |
java.awt.Color |
getColour(short slot)
Returns the colour in a particular slot of the colour mapping. |
java.lang.String |
getEntriesString()
Returns a String showing either: The [R,G,B] entries for this ColourMapping, or If the ColourMapping is MONOCHROME1 or MONOCHROME2, the String "MONOCHROME1" or "MONOCHROME2". |
static float |
getGamma()
Returns the current gamma value setting for the display. |
int |
getIconHeight()
Get the height of the Icon used to represent this ColourMapping. |
int |
getIconWidth()
Get the width of the Icon used to represent this ColourMapping. |
static ColourMapping |
getInstance(java.lang.String entriesString)
Creates a new ColourMapping object from a String representation of the ColourMapping name, or the list of entries in the ColourMapping. |
static ColourMapping[] |
getKnownColourMappings()
Returns an array of known built-in ColorMappings. |
static float |
getMaxLuminance()
Returns the current maximmum display luminance setting for a digital driver level (DDL) of 255. |
static float |
getMinLuminance()
Returns the current minimum display luminance setting for a digital driver level (DDL) of zero. |
int |
getNSlots()
Returns the number of slots in this ColourMapping. |
boolean |
isGreyScale()
Returns true if this is a grey scale ColourMapping. |
ColourMapping |
makeTransparent(byte alpha,
boolean transparentBackground)
Add transparency (an alpha channel) to an existing ColourMapping. |
void |
paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
Paints the Icon used to represent this ColourMapping. |
static void |
savePreferences()
Saves the display settings for the DICOM standard display in the user's preferences. |
static void |
setDisplaySettings(float minLuminance,
float maxLuminance,
float gamma)
Set the display characteristics. |
void |
setRGB(int[] red,
int[] green,
int[] blue)
Sets the R,G,B components of every element of the ColourMapping. |
java.lang.String |
toString()
Returns a String describing this ColourMapping. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final float MIN_LUMINANCE
public static final float MAX_LUMINANCE
public static final float MIN_GAMMA
public static final float MAX_GAMMA
public static final float DEFAULT_MIN_LUMINANCE
public static final float DEFAULT_MAX_LUMINANCE
public static final float DEFAULT_GAMMA
public static final ColourMapping MONOCHROME1
public static final ColourMapping MONOCHROME2
public static final ColourMapping HOBS
public static final ColourMapping RBOW1
public static final ColourMapping RBOW2
public static final ColourMapping COOL
public static final ColourMapping RED
public static final ColourMapping GREEN
public static final ColourMapping BLUE
public static final ColourMapping YELLOW
public static final ColourMapping CYAN
public static final ColourMapping MAGENTA
public static final ColourMapping STEP
public java.awt.image.IndexColorModel cm
| Constructor Detail |
|---|
public ColourMapping(short nSlots)
nSlots - the number of slots in the ColourMapping.
public ColourMapping(byte[] red,
byte[] green,
byte[] blue)
throws InvalidColourMappingException
red - the red gun values for each slot in the ColourMapping.green - the green gun values for each slot in the ColourMapping.blue - the blue gun values for each slot in the ColourMapping.
InvalidColourMappingException - if the lengths of the red, green and blue arrays
are unequal, or if the length of the arrays is greater than 256, or less than 1.| Method Detail |
|---|
public static ColourMapping getInstance(java.lang.String entriesString)
throws InvalidColourMappingException
entriesString - a a String representing either:
InvalidColourMappingException - if the entries in the ColourMapping cannot be
parsed from the entriesString.
public static ColourMapping get(java.lang.String name)
throws com.xinapse.util.InvalidArgumentException
Note: the name of a ColourMapping can be retrieved with the toString() method.
name - the name of the ColourMapping.
com.xinapse.util.InvalidArgumentException - if the supplied name does not match any of the
names of the built-in mappings.
public ColourMapping makeTransparent(byte alpha,
boolean transparentBackground)
alpha - the transparency value as un unsigned byte value.transparentBackground - if the background (colour values slot 0) is to be completely
transparent.
public void colourLookup(int nCols,
int nRows,
java.lang.Object pixValues,
int offset,
PixelDataType dataType,
byte[] bytePixel,
double min,
double max,
boolean inverted,
boolean[] mask,
boolean interpolate,
ComplexMode complexMode)
throws java.lang.IllegalArgumentException
nCols - the number of columns in the array of pixel intensity values.nRows - the number of rows in the array of pixel intensity values.pixValues - an array of pixel intensity values to look up.offset - an offset (in pixels) into the array of pixValues at which to start the lookup.dataType - the PixelDataType data type of the pixel intensity values.bytePixel - the byte array that will contain the intensity values as mapped by the
ColourMapping. If interpolation is false, then bytePixel should have the
same length as pixValue.
If interpolation is true, then bytePixel should be four times as long as
pixValues.min - the pixel intensity that maps to the bottom (lowest value) of the
ColourMapping.max - the pixel intensity that maps to the top (highest value) of the
ColourMapping.inverted - true if the mapping of colours should be inverted.mask - if non-null, then this is used to mask pixels so that they appear the same colour
as the background.interpolate - true if the image should be interpolated in the
horizontal and vertical directions with an interpolation factor of two.
Bi-linear interpolation is used.
java.lang.IllegalArgumentException - if the colours cannot be looked up.
public static void colourLookupRGBInterlaced(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
If the alpha value is 255 (totally opaque) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_RGB, with each pixel's colour being defined by the R,G,B values packed into each int in the array.
If the alpha value is other than 255 (transparent) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_ARGB, with each pixel's colour being defined by the alpha,R,G,B values packed into each int in the array.
The brightness and contrast of the image may be adjusted by setting min and max. These would be set to 0 and 255 respectively to show the full colour range. If these are changed, the colours are remapped so that the colour at the min is remapped to zero gun value, and the colour at the max is remapped to the gun value 255.
nCols - the number of columns in the array of pixel intensity values.nRows - the number of rows in the array of pixel intensity values.pixValues - an array of pixel intensity values to look up.offset - an offset (in pixels) into the array of pixValues at which to start the lookup.intPixel - the int array that will contain the colour values.
If interpolation is false, then intPixel should have the
same length as pixValue.
If interpolation is true, then bytePixel should be four times as long as
pixValues.min - the colour intensity that maps to a gun value of zero.max - the colour intensity that maps to a gun value of 255.inverted - true if the mapping of colours should be inverted.mask - if non-null, then this is used to mask pixels so that they appear the same colour
as the background.interpolate - true if the image should be interpolated in the
horizontal and vertical directions with an interpolation factor of two.
Bi-linear interpolation is used.alpha - the opacity value. 0 is totally transparent and 255 is totally opaque.transparentBackground - if true, then any black pixels will be set completely
transparent.
public static void colourLookupRGBByPlane(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
If the alpha value is 255 (totally opaque) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_RGB, with each pixel's colour being defined by the R,G,B values packed into each int in the array.
If the alpha value is other than 255 (transparent) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_ARGB, with each pixel's colour being defined by the alpha,R,G,B values packed into each int in the array.
The brightness and contrast of the image may be adjusted by setting min and max. These would be set to 0 and 255 respectively to show the full colour range. If these are changed, the colours are remapped so that the colour at the min is remapped to zero gun value, and the colour at the max is remapped to the gun value 255.
nCols - the number of columns in the array of pixel intensity values.nRows - the number of rows in the array of pixel intensity values.pixValues - an array of pixel intensity values to look up.offset - an offset (in pixels) into the array of pixValues at which to start the lookup.intPixel - the int array that will contain the colour values.
If interpolation is false, then intPixel should have the
same length as pixValue.
If interpolation is true, then bytePixel should be four times as long as
pixValues.min - the colour intensity that maps to a gun value of zero.max - the colour intensity that maps to a gun value of 255.inverted - true if the mapping of colours should be inverted.mask - if non-null, then this is used to mask pixels so that they appear the same colour
as the background.interpolate - true if the image should be interpolated in the
horizontal and vertical directions with an interpolation factor of two.
Bi-linear interpolation is used.alpha - the opacity value. 0 is totally transparent and 255 is totally opaque.transparentBackground - if true, then any black pixels will be set completely
transparent.
public static void colourLookupColourPacked(int nCols,
int nRows,
byte[] pixValues,
int offset,
int[] intPixel,
short min,
short max,
boolean inverted,
boolean[] mask,
boolean interpolate,
byte alpha,
boolean transparentBackground)
If the alpha value is 255 (totally opaque) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_RGB, with each pixel's colour being defined by the R,G,B values packed into each int in the array.
If the alpha value is other than 255 (transparent) then the BufferedImage must be of type java.awt.image.BufferedImage.TYPE_INT_ARGB, with each pixel's colour being defined by the alpha,R,G,B values packed into each int in the array.
The brightness and contrast of the image may be adjusted by setting min and max. These would be set to 0 and 255 respectively to show the full colour range. If these are changed, the colours are remapped so that the colour at the min is remapped to zero gun value, and the colour at the max is remapped to the gun value 255.
nCols - the number of columns in the array of pixel intensity values.nRows - the number of rows in the array of pixel intensity values.pixValues - an array of pixel intensity values to look up.offset - an offset (in pixels) into the array of pixValues at which to start the lookup.intPixel - the int array that will contain the colour values.
If interpolation is false, then intPixel should have the
same length as pixValue.
If interpolation is true, then bytePixel should be four times as long as
pixValues.min - the colour intensity that maps to a gun value of zero.max - the colour intensity that maps to a gun value of 255.inverted - true if the mapping of colours should be inverted.mask - if non-null, then this is used to mask pixels so that they appear the same colour
as the background.interpolate - true if the image should be interpolated in the
horizontal and vertical directions with an interpolation factor of two.
Bi-linear interpolation is used.alpha - the opacity value. 0 is totally transparent and 255 is totally opaque.transparentBackground - if true, then any black pixels will be set completely
transparent.
public void setRGB(int[] red,
int[] green,
int[] blue)
throws InvalidColourMappingException
red - an array of red gun values.green - an array of green gun values.blue - an array of blue gun values.
InvalidColourMappingException - if the length of the arrays containing R,G,B values
does not match the number of slots in the ColourMapping, or if any of the gun
values is ouside the range [0..255].public int getNSlots()
public java.awt.Color getColour(short slot)
slot - the slot number of the colour mapping.
public boolean isGreyScale()
public int getIconHeight()
getIconHeight in interface javax.swing.Iconpublic int getIconWidth()
getIconWidth in interface javax.swing.Icon
public void paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
paintIcon in interface javax.swing.Iconpublic static ColourMapping[] getKnownColourMappings()
public java.lang.String getEntriesString()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Object
public static void setDisplaySettings(float minLuminance,
float maxLuminance,
float gamma)
throws java.lang.IllegalArgumentException,
InvalidColourMappingException
minLuminance - the luminance level of the display for a digital driver level (DDL) of
zero for the red, green and blue guns. This luminance includes the effects of any ambient
light falling on the display.maxLuminance - the luminance level of the display for a digital driver level (DDL) of
255 for the red, green and blue guns. This luminance includes the effects of any ambient
light falling on the display.gamma - the gamma characteristic for the display. The change in luminance of the
display (from the minLuminance) is assumed to be proportional to the DDL raised to the
power gamma.
java.lang.IllegalArgumentException - if any of the arguments is outside the credible range
for displays.
InvalidColourMappingException - if the ColourMappings can't be set.public static void savePreferences()
public static float getMinLuminance()
public static float getMaxLuminance()
public static float getGamma()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||