ImageScience 3.0.0

imagescience.image
Class ColorImage

java.lang.Object
  extended by imagescience.image.Image
      extended by imagescience.image.ColorImage

public class ColorImage
extends Image

An image containing up to 5D elements of type int representing aRGB-color values. The color components are stored in an int as follows:

Element values are taken in the unsigned sense, and therefore the get methods always return numbers in the range [0,255] if a single component is activated (using method component(int)). Insertion of floating-point numbers in any of these components by using the set methods is done by first clipping to the range [0,255] and then rounding to the nearest 8-bit integer value. It is also possible (by setting the active component to FULL) to get and set the full 32-bit integer value rather than a single component.


Field Summary
static int ALPHA
          The alpha component (stored in bits 24-31).
static int BLUE
          The blue component (stored in bits 0-7).
static int FULL
          The full 32-bit integer value.
static int GREEN
          The green component (stored in bits 8-15).
static int RED
          The red component (stored in bits 16-23).
 
Constructor Summary
ColorImage(Dimensions dims)
          Dimensions constructor.
ColorImage(Image image)
          Copy constructor.
ColorImage(Image image, Borders borders)
          Copy constructor that allows adding borders.
ColorImage(ij.ImagePlus imageplus)
          Wrapper constructor.
 
Method Summary
 Image border(Borders borders)
          Returns a bordered copy of this image.
 int component()
          Indicates the currently active component.
 void component(int component)
          Sets the active component.
 Image duplicate()
          Duplicates this image.
 Image get()
          Returns the currently active component as a new Image.
 double get(Coordinates coords)
          Returns the value of the image element at the given coordinates.
 void get(Coordinates coords, double[] values)
          Reads values in one dimension from the image into the array.
 void get(Coordinates coords, double[][] values)
          Reads values in two dimensions from the image into the array.
 void get(Coordinates coords, double[][][] values)
          Reads values in three dimensions from the image into the array.
 void get(Coordinates coords, double[][][][] values)
          Reads values in four dimensions from the image into the array.
 void get(Coordinates coords, double[][][][][] values)
          Reads values in all five dimensions from the image into the array.
 void get(Coordinates coords, float[] values)
          Reads values in one dimension from the image into the array.
 void get(Coordinates coords, float[][] values)
          Reads values in two dimensions from the image into the array.
 void get(Coordinates coords, float[][][] values)
          Reads values in three dimensions from the image into the array.
 void get(Coordinates coords, float[][][][] values)
          Reads values in four dimensions from the image into the array.
 void get(Coordinates coords, float[][][][][] values)
          Reads values in all five dimensions from the image into the array.
 ij.ImagePlus imageplus()
          Returns this image in the form of an ImagePlus object.
 int memory()
          Returns the amount of memory occupied by the image data.
 void mirror(Borders borders)
          Sets the image elements in the borders by mirroring the remainder of the image.
 void set(Borders borders, double value)
          Sets every image element in the borders to the given value.
 void set(Coordinates coords, double value)
          Sets the image element at the given coordinates to the given value.
 void set(Coordinates coords, double[] values)
          Writes values in one dimension from the array into the image.
 void set(Coordinates coords, double[][] values)
          Writes values in two dimensions from the array into the image.
 void set(Coordinates coords, double[][][] values)
          Writes values in three dimensions from the array into the image.
 void set(Coordinates coords, double[][][][] values)
          Writes values in four dimensions from the array into the image.
 void set(Coordinates coords, double[][][][][] values)
          Writes values in all five dimensions from the array into the image.
 void set(Coordinates coords, float[] values)
          Writes values in one dimension from the array into the image.
 void set(Coordinates coords, float[][] values)
          Writes values in two dimensions from the array into the image.
 void set(Coordinates coords, float[][][] values)
          Writes values in three dimensions from the array into the image.
 void set(Coordinates coords, float[][][][] values)
          Writes values in four dimensions from the array into the image.
 void set(Coordinates coords, float[][][][][] values)
          Writes values in all five dimensions from the array into the image.
 void set(double value)
          Sets every image element to the given value.
 void set(Image image)
          Sets the currently active component to the given image.
 java.lang.String type()
          Returns the image type.
 
Methods inherited from class imagescience.image.Image
absolute, add, add, aspects, aspects, axes, axes, create, dimensions, divide, divide, elements, extrema, id, invert, maximum, minimum, multiply, multiply, name, name, power, square, squareroot, subtract, subtract, wrap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALPHA

public static final int ALPHA
The alpha component (stored in bits 24-31).

See Also:
Constant Field Values

RED

public static final int RED
The red component (stored in bits 16-23).

See Also:
Constant Field Values

GREEN

public static final int GREEN
The green component (stored in bits 8-15).

See Also:
Constant Field Values

BLUE

public static final int BLUE
The blue component (stored in bits 0-7).

See Also:
Constant Field Values

FULL

public static final int FULL
The full 32-bit integer value.

See Also:
Constant Field Values
Constructor Detail

ColorImage

public ColorImage(Dimensions dims)
Dimensions constructor.

Parameters:
dims - The dimensions of the new image.
Throws:
java.lang.NullPointerException - If dims is null.

ColorImage

public ColorImage(ij.ImagePlus imageplus)
Wrapper constructor.

Parameters:
imageplus - The ImagePlus object whose image data is to be wrapped. The actual image data is not copied but shared.
Throws:
java.lang.IllegalArgumentException - If the image elements of imageplus are not of type int.
java.lang.NullPointerException - If imageplus is null.

ColorImage

public ColorImage(Image image)
Copy constructor.

Parameters:
image - The image to copy from. Image element values are copied using a get method of the given image and the corresponding set method of this image. This enables copying from images that are of different type than this image. Be aware, however, of the value conversion rules of the respective methods when copying from images that are not of the same type as this image.
Throws:
java.lang.NullPointerException - If image is null.

ColorImage

public ColorImage(Image image,
                  Borders borders)
Copy constructor that allows adding borders. Creates a new image whose size in each dimension is equal to that of the given image plus twice the given border size in that dimension.

Parameters:
image - The image to copy from. Image element values are copied using a get method of the given image and the corresponding set method of this image, taking into account the new border sizes. This enables copying from images that are of a different type than this image. Be aware, however, of the value conversion rules of the respective methods when copying from images that are not of the same type as this image.
borders - Specifies the border size in each dimension of the new image.
Throws:
java.lang.NullPointerException - If any of the parameters is null.
Method Detail

border

public Image border(Borders borders)
Description copied from class: Image
Returns a bordered copy of this image.

Specified by:
border in class Image
Parameters:
borders - Specifies the border size in each dimension.
Returns:
A bordered copy of this image. All information is copied to the newly created image and no memory is shared.

component

public int component()
Indicates the currently active component.

Returns:
The currently active component. The returned value is one of the static fields of this class. By default this is FULL.

component

public void component(int component)
Sets the active component.

Parameters:
component - The component to be activated. Must be one of the static fields of this class. The get and set methods consider only the currently active component. By default this is FULL.
Throws:
java.lang.IllegalArgumentException - If component is not one of the static fields of this class.

imageplus

public ij.ImagePlus imageplus()
Description copied from class: Image
Returns this image in the form of an ImagePlus object.

Specified by:
imageplus in class Image
Returns:
A new ImagePlus object of this Image object. The two objects share the actual image data.

type

public java.lang.String type()
Description copied from class: Image
Returns the image type.

Specified by:
type in class Image
Returns:
The image type. The returned String contains the fully qualified name of the subclass which this image is an object of.

memory

public int memory()
Description copied from class: Image
Returns the amount of memory occupied by the image data.

Specified by:
memory in class Image
Returns:
The amount of memory occupied by the image data. The amount is expressed in bytes.

duplicate

public Image duplicate()
Description copied from class: Image
Duplicates this image.

Specified by:
duplicate in class Image
Returns:
A new Image object that is an exact copy of this object. All information is copied and no memory is shared between this and the returned object.

get

public Image get()
Returns the currently active component as a new Image.

Returns:
A new Image containing a copy of the currently active component. If the active component is one of ALPHA, RED, GREEN, BLUE, the returned object is an instance of ByteImage and contains the element values of the corresponding component. If it is FULL, the returned object is an instance of ColorImage and contains a copy of this image.

get

public double get(Coordinates coords)
Description copied from class: Image
Returns the value of the image element at the given coordinates.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the image element whose value is to be obtained. Coordinates must be within the range determined by the image dimensions. For consistency with the other get methods, none of the Cartesian coordinate axes should be active. However, this condition is not strictly necessary in order for this method to behave unambiguously and is therefore not checked, so as to increase efficiency.
Returns:
The value of the image element at the given coordinates.

get

public void get(Coordinates coords,
                double[] values)
Description copied from class: Image
Reads values in one dimension from the image into the array. The dimension from which values are read is determined by the currently active Cartesian coordinate axis. Exactly one axis must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinate corresponding to the active axis is allowed to be outside the range determined by the image size in the corresponding dimension. Out-of-range positions in the active dimension are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                double[][] values)
Description copied from class: Image
Reads values in two dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly two axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                double[][][] values)
Description copied from class: Image
Reads values in three dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly three axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                double[][][][] values)
Description copied from class: Image
Reads values in four dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly four axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                double[][][][][] values)
Description copied from class: Image
Reads values in all five dimensions from the image into the array. All five axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. Coordinates are allowed to be outside the range determined by the image size. Out-of-range positions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                float[] values)
Description copied from class: Image
Reads values in one dimension from the image into the array. The dimension from which values are read is determined by the currently active Cartesian coordinate axis. Exactly one axis must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinate corresponding to the active axis is allowed to be outside the range determined by the image size in the corresponding dimension. Out-of-range positions in the active dimension are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                float[][] values)
Description copied from class: Image
Reads values in two dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly two axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                float[][][] values)
Description copied from class: Image
Reads values in three dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly three axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                float[][][][] values)
Description copied from class: Image
Reads values in four dimensions from the image into the array. The dimensions from which values are read are determined by the currently active Cartesian coordinate axes. Exactly four axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually read but simply skipped.
values - The array to which the image values are copied.

get

public void get(Coordinates coords,
                float[][][][][] values)
Description copied from class: Image
Reads values in all five dimensions from the image into the array. All five axes must be active in order for this method to work.

Specified by:
get in class Image
Parameters:
coords - The coordinates of the starting position in the image for reading image values into the array. Coordinates are allowed to be outside the range determined by the image size. Out-of-range positions are not actually read but simply skipped.
values - The array to which the image values are copied.

set

public void set(Image image)
Sets the currently active component to the given image.

Parameters:
image - The image to set the currently active component to. Image element values are copied using a get method of the given image and the corresponding set method of this image. Be aware of the value conversion rules of the respective methods.
Throws:
java.lang.IllegalStateException - If the size of the given image is not equal to that of this image in every dimension.
java.lang.NullPointerException - If image is null.

set

public void set(double value)
Description copied from class: Image
Sets every image element to the given value.

Specified by:
set in class Image
Parameters:
value - The value to which every image element is to be set.

mirror

public void mirror(Borders borders)
Description copied from class: Image
Sets the image elements in the borders by mirroring the remainder of the image.

Specified by:
mirror in class Image
Parameters:
borders - Specifies the size of the border in each dimension.

set

public void set(Borders borders,
                double value)
Description copied from class: Image
Sets every image element in the borders to the given value.

Specified by:
set in class Image
Parameters:
borders - Specifies the size of the border in each dimension.
value - The value to which every border element is to be set.

set

public void set(Coordinates coords,
                double value)
Description copied from class: Image
Sets the image element at the given coordinates to the given value.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the image element to be set. Coordinates must be within the range determined by the image size. For consistency with the other set methods, none of the Cartesian coordinate axes should be active. However, this condition is not strictly necessary in order for this method to behave unambiguously and is therefore not checked, so as to increase efficiency.
value - The value to which the image element is to be set.

set

public void set(Coordinates coords,
                double[] values)
Description copied from class: Image
Writes values in one dimension from the array into the image. The dimension into which values are written is determined by the currently active Cartesian coordinate axis. Exactly one axis must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinate corresponding to the active axis is allowed to be outside the range determined by the image size in the corresponding dimension. Out-of-range positions in the active dimension are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                double[][] values)
Description copied from class: Image
Writes values in two dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly two axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                double[][][] values)
Description copied from class: Image
Writes values in three dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly three axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                double[][][][] values)
Description copied from class: Image
Writes values in four dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly four axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                double[][][][][] values)
Description copied from class: Image
Writes values in all five dimensions from the array into the image. All five axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. Coordinates are allowed to be outside the range determined by the image size. Out-of-range positions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                float[] values)
Description copied from class: Image
Writes values in one dimension from the array into the image. The dimension into which values are written is determined by the currently active Cartesian coordinate axis. Exactly one axis must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinate corresponding to the active axis is allowed to be outside the range determined by the image size in the corresponding dimension. Out-of-range positions in the active dimension are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                float[][] values)
Description copied from class: Image
Writes values in two dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly two axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                float[][][] values)
Description copied from class: Image
Writes values in three dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly three axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                float[][][][] values)
Description copied from class: Image
Writes values in four dimensions from the array into the image. The dimensions into which values are written are determined by the currently active Cartesian coordinate axes. Exactly four axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. The coordinates corresponding to the active axes are allowed to be outside the range determined by the image size in the corresponding dimensions. Out-of-range positions in the active dimensions are not actually written but simply skipped.
values - The array from which values are copied to the image.

set

public void set(Coordinates coords,
                float[][][][][] values)
Description copied from class: Image
Writes values in all five dimensions from the array into the image. All five axes must be active in order for this method to work.

Specified by:
set in class Image
Parameters:
coords - The coordinates of the starting position in the image for writing values into the image. Coordinates are allowed to be outside the range determined by the image size. Out-of-range positions are not actually written but simply skipped.
values - The array from which values are copied to the image.

ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.