de.unihalle.informatik.MiToBo.core.datatypes.images
Class MTBImage

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.images.MTBImage
All Implemented Interfaces:
MTBImageManipulator, java.awt.event.KeyListener, java.util.EventListener
Direct Known Subclasses:
MTBImageByte, MTBImageDouble, MTBImageFloat, MTBImageInt, MTBImageRGB, MTBImageShort

public abstract class MTBImage
extends de.unihalle.informatik.Alida.operator.ALDData
implements MTBImageManipulator, java.awt.event.KeyListener

Abstract wrapper class for easy access to hyperstacks. Indices range is different from ImageJ. Here, indices in each dimension range from 0 to (dimSize - 1), while ImageJ stack indices range from 1 to dimSize. Subclasses implement the wrapper for different types.

Author:
gress

Nested Class Summary
protected static class MTBImage.FactoryMethod
          methods to create new image from an existing one. used in MTBImageFactory
 class MTBImage.MTBImageFactory
          A class for creating MTBImages which implements the MTBOperator.
static class MTBImage.MTBImageType
          MiToBo image types
 
Field Summary
protected  ij.measure.Calibration calibration
          calibration object (from ImageJ)
protected  int m_currentC
          current c-coordinate, for 3D only access functions
protected  int m_currentSliceIdx
          index of the current slice, this has nothing to do with the ij.ImageStack's current slice
protected  int m_currentT
          current t-coordinate, for 3D only access functions
protected  ij.ImagePlus m_img
          the underlying ImagePlus object
protected  ij.ImageStack m_imgStack
          reference to the ImageStack object of the underlying ImagePlus object
protected  int m_sizeC
          size of c-dimension
protected  int m_sizeStack
          stacksize
protected  int m_sizeT
          size of t-dimension
protected  int m_sizeX
          size of x-dimension
protected  int m_sizeY
          size of y-dimension
protected  int m_sizeZ
          size of z-dimension
protected  java.lang.String m_title
          image title
protected  MTBImage.MTBImageType m_type
          MiToBo image type
static java.lang.String UNTITLED
          Title string for new and untitled images
protected  java.lang.String xml
          File description XML string if available
 
Constructor Summary
protected MTBImage()
          Constructor for initializing an empty image (dimension sizes = -1).
protected MTBImage(ij.ImagePlus img)
          Constructor.
 
Method Summary
 void adoptSliceLabels(MTBImage src)
          Copy slice labels from src to this
 void close()
          Close the displayed ImagePlus
 MTBImage convertType(MTBImage.MTBImageType type, boolean scaleDown)
          Create an image of given type from this image's values.
 MTBImage convertType(MTBOperator callingOperator, MTBImage.MTBImageType type, boolean scaleDown)
          Create an image of given type from this image's values.
 void copyPhysicalProperties(MTBImage sourceImg)
          Copy physical properties like stepsizes and units from sourceImg to this.
static MTBImage createMTBImage(ij.ImagePlus img)
          Factory method to create MTBImage objects.
static MTBImage createMTBImage(int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC, MTBImage.MTBImageType type)
          Factory method to create MTBImage objects with value 0 at each coordinate.
protected static MTBImage createMTBImageByte(int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC, byte[][] data)
           
 void drawLine2D(int xstart, int ystart, int xend, int yend, int value)
          Draws a 2D line into the current slice of the image.
 void drawPoint2D(int x, int y, int z, int value, int mode)
          Draws a point at given position into the x-y-plane.
 MTBImage duplicate()
          Duplicates the object.
 MTBImage duplicate(MTBOperator callingOperator)
          Duplicates the object.
 boolean equals(MTBImage img)
          Test if this object and img are of same type, have same size and same values
 boolean equalSize(MTBImage img)
          Test if this object and img have the same size in x-, y-, z-, t- and c-dimension
 void fillBlack()
           
 void fillWhite()
           
 ij.measure.Calibration getCalibration()
          Get the calibration object.
 MTBImage getCurrentSlice()
          Get a copy of the current slice.
 MTBImage getCurrentSlice(MTBOperator callingOperator)
          Get a copy of the current slice.
 int[] getCurrentSliceCoords()
          Get the current slice coordinates (z,t,c) (for functions that work on a slice only, this has nothing to do with the ij.ImageStack's current slice)
 int getCurrentSliceIndex()
          Get the current slice index (for functions that work on a slice only, this has nothing to do with the ij.ImageStack's current slice)
 java.lang.String getCurrentSliceLabel()
          Get the slice label of the slice specified by the current slice index
 int[] getCurrentZStackCoords()
          Get the current z-stack coordinates. [0]=t-coordinate, [1]=c-coordinate.
 MTBImage getImagePart(int x, int y, int z, int t, int c, int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC)
          Get a copy of a part of this image as new MTBImage.
 MTBImage getImagePart(MTBOperator callingOperator, int x, int y, int z, int t, int c, int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC)
          Get a copy of a part of this image as new MTBImage.
abstract  ij.ImagePlus getImagePlus()
          Get an ImagePlus object.
abstract  double[] getMinMaxDouble()
          Get minimum and maximum value of the image as double
abstract  int[] getMinMaxInt()
          Get minimum and maximum value of the image as int
 int getSizeC()
          Get size of c(hannel)-dimension
 int getSizeStack()
          Get size of the underlying (ImageJ) stack which corresponds to the number of slices
 int getSizeT()
          Get size of t(ime)-dimension
 int getSizeX()
          Get size of x-dimension
 int getSizeY()
          Get size of y-dimension
 int getSizeZ()
          Get size of z-dimension
 MTBImage getSlice(int z, int t, int c)
          Get a copy of the specified slice.
 MTBImage getSlice(MTBOperator callingOperator, int z, int t, int c)
          Get a copy of the specified slice.
 java.lang.String getSliceLabel(int z, int t, int c)
          Get the slice label of the slice specified by (z,t,c)
 double getStepsizeT()
          Get the stepsize in t-dimension (timestep)
 double getStepsizeX()
          Get the physical size of a voxel (stepsize) in x-dimension
 double getStepsizeY()
          Get the physical size of a voxel (stepsize) in y-dimension
 double getStepsizeZ()
          Get the physical size of a voxel (stepsize) in z-dimension
 java.lang.String getTitle()
          Get the image's title
static java.lang.String getTitleRunning(java.lang.String title)
          Return a unique title for the copy of an image, i.e. a running number is appended/incremented.
 MTBImage.MTBImageType getType()
          Get MiToBo image type
 double getTypeMax()
          Return the maximum value that the current type can handle
 double getTypeMin()
          Return the minimum value that the current type can handle
static java.lang.String getTypeName(int type)
          Deprecated. 
 java.lang.String getUnitT()
          Get the unit of the t-dimension
 java.lang.String getUnitX()
          Get the unit of the x-dimension
 java.lang.String getUnitY()
          Get the unit of the y-dimension
 java.lang.String getUnitZ()
          Get the unit of the z-dimension
abstract  double getValueDouble(int x, int y)
          Get the value of the current slice at coordinate (x,y) as an Double
abstract  double getValueDouble(int x, int y, int z)
          Get the value of the current slice at coordinate (x,y,z) as an Double
abstract  double getValueDouble(int x, int y, int z, int t, int c)
          Get the value of the 5D image at coordinate (x,y,z,t,c) as a Double
abstract  int getValueInt(int x, int y)
          Get the value of the current slice at coordinate (x,y) as an Integer
abstract  int getValueInt(int x, int y, int z)
          Get the value of the current z-stack coordinate (x,y,z) as an Integer
abstract  int getValueInt(int x, int y, int z, int t, int c)
          Get the value of the 5D image at coordinate (x,y,z,t,c) as an Integer
 java.lang.String getXML()
          Get the XML file description string if one was available.
 boolean hasImagePlus()
           
static boolean isValidType(MTBImage.MTBImageType type)
          Deprecated. 
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
static MTBImage.MTBImageType ordinalToType(int enumIdx)
          Return the corresponding MTBImageType for its index in the enum.
abstract  void putValueDouble(int x, int y, double value)
          Set the value of the current slice at coordinate (x,y) using a Double
abstract  void putValueDouble(int x, int y, int z, double value)
          Set the value of the current slice at coordinate (x,y,z) using a Double
abstract  void putValueDouble(int x, int y, int z, int t, int c, double value)
          Set the value of the 5D image at coordinate (x,y,z,t,c) using a Double
abstract  void putValueInt(int x, int y, int value)
          Set the value of the current slice at coordinate (x,y) using an Integer
abstract  void putValueInt(int x, int y, int z, int value)
          Set the value of the current slice at coordinate (x,y,z) using an Integer
abstract  void putValueInt(int x, int y, int z, int t, int c, int value)
          Set the value of the 5D image at coordinate (x,y,z,t,c) using an Integer
 MTBImageDouble scaleValues(int c, int t, double curMin, double curMax, double scaleMin, double scaleMax)
          Method to scale the intensity values (range [curMin, curMax]) of the image to a given range [scaleMin, scaleMax].
 void setCalibration(ij.measure.Calibration calibration)
          Set the calibration object (see getCalibration() for further information).
 void setCurrentSlice(MTBImageManipulator src)
          Copy the values of the source to the current slice
 void setCurrentSliceCoords(int z, int t, int c)
          Set the current slice for functions that work on a slice only (this has nothing to do with the ij.ImageStack's current slice)
 void setCurrentSliceIndex(int stackindex)
          Set the current slice for functions that work on a slice only (this has nothing to do with the ij.ImageStack's current slice) Stack indices range from 0 to N-1 (unlike ImageJ, where stack indices range from 1 to N)
 void setCurrentSliceLabel(java.lang.String label)
          Set the slice label of the slice specified by the current slice index
 void setCurrentZStackCoordinates(int t, int c)
          Set the current z-stack coordinates for functions that work on (spatial) 3D only.
 void setImagePart(MTBImageManipulator src, int x, int y, int z, int t, int c)
          Set a part of this image to the values of the source
 void setSlice(MTBImageManipulator src, int z, int t, int c)
          Copy the value of source to the specified slice
 void setSliceLabel(java.lang.String label, int z, int t, int c)
          Set the slice label of the slice specified by (z,t,c)
 void setStepsizeT(double stepsize)
          Set the stepsize in t-dimension (timestep)
 void setStepsizeX(double stepsize)
          Set the physical size of a voxel (stepsize) in x-dimension
 void setStepsizeY(double stepsize)
          Set the physical size of a voxel (stepsize) in y-dimension
 void setStepsizeZ(double stepsize)
          Set the physical size of a voxel (stepsize) in z-dimension
 void setTitle(java.lang.String title)
          Set the image's title.
 void setUnitT(java.lang.String unit)
          Set the unit of the t-dimension
 void setUnitX(java.lang.String unit)
          Set the unit of the x-dimension
 void setUnitY(java.lang.String unit)
          Set the unit of the y-dimension
 void setUnitZ(java.lang.String unit)
          Set the unit of the z-dimension
 void setXML(java.lang.String xml)
          Set the XML file description string if one was available
 void show()
          Display the image as an ImagePlus.
static MTBImage.MTBImageType stringToType(java.lang.String s)
          For a given String, return the corresponding MTBImageType.
 java.lang.String toString()
          Returns the String "IMG("title of the image")"
 void updateAndRepaintWindow()
          Update and repaint the image window if the image is displayed by ImageJ
protected abstract  void updateImagePlus()
          Should be used to create or update ImagePlus data if the MTBImage is not using an ImagePlus to store the data (MTB_INT, MTB_DOUBLE, MTB_RGB).
protected  void updateImageSize_ImgToProp()
          Update the image size in the properties hashtable from the image's size
protected  void updatePhysProperties_ImgToProp()
          Update physical properties (stepsizes, units) in the properties hashtable from its member variables
protected  void updatePhysProperties_PropToImg()
          Update physical properties (stepsizes, units) of the image (member variables) from its properties hashtable
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

calibration

protected ij.measure.Calibration calibration
calibration object (from ImageJ)


m_currentC

protected int m_currentC
current c-coordinate, for 3D only access functions


m_currentSliceIdx

protected int m_currentSliceIdx
index of the current slice, this has nothing to do with the ij.ImageStack's current slice


m_currentT

protected int m_currentT
current t-coordinate, for 3D only access functions


m_img

protected ij.ImagePlus m_img
the underlying ImagePlus object


m_imgStack

protected ij.ImageStack m_imgStack
reference to the ImageStack object of the underlying ImagePlus object


m_sizeC

protected int m_sizeC
size of c-dimension


m_sizeStack

protected int m_sizeStack
stacksize


m_sizeT

protected int m_sizeT
size of t-dimension


m_sizeX

protected int m_sizeX
size of x-dimension


m_sizeY

protected int m_sizeY
size of y-dimension


m_sizeZ

protected int m_sizeZ
size of z-dimension


m_title

protected java.lang.String m_title
image title


m_type

protected MTBImage.MTBImageType m_type
MiToBo image type


UNTITLED

public static final java.lang.String UNTITLED
Title string for new and untitled images

See Also:
Constant Field Values

xml

protected java.lang.String xml
File description XML string if available

Constructor Detail

MTBImage

protected MTBImage()
Constructor for initializing an empty image (dimension sizes = -1). Current slice index, current z-stack coordinates are all initialized to 0. Needed for non-ImageJ types, which cannot be represented by an ImagePlus (e.g. Double)

Parameters:
wrapped - ImagePlus object

MTBImage

protected MTBImage(ij.ImagePlus img)
Constructor. Initializes the sizes corresponding to the underlying ImagePlus. Current slice index, current z-stack coordinates are all initialized to 0. If a Calibration object is present in the ImagePlus, physical pixel sizes and units are assigned.

Parameters:
wrapped - ImagePlus object
Method Detail

adoptSliceLabels

public void adoptSliceLabels(MTBImage src)
                      throws java.lang.IllegalArgumentException
Copy slice labels from src to this

Parameters:
src -
Throws:
java.lang.IllegalArgumentException

close

public void close()
Close the displayed ImagePlus


convertType

public MTBImage convertType(MTBImage.MTBImageType type,
                            boolean scaleDown)
Create an image of given type from this image's values. Information is lost if a type of less precision is used! This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history. If you need to specify the calling operator, use getImagePart(MTBOperator, ...)

Parameters:
type - new image's type (see static final fields for types)
scaleDown - If true, the data is scaled down to fit in the range of the new image type values, if the new image type is of less precision. If false, the values are simply casted.
Returns:
new image of given type or null if the operation was not successful

convertType

public MTBImage convertType(MTBOperator callingOperator,
                            MTBImage.MTBImageType type,
                            boolean scaleDown)
Create an image of given type from this image's values. Information is lost if a type of less precision is used! This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history.

Parameters:
callingOperator - the MTBOperator, which calls this method
type - new image's type (see static final fields for types)
scaleDown - If true, the data is scaled down to fit in the range of the new image type values, if the new image type is of less precision. If false, the values are simply casted.
Returns:
new image of given type or null if the operation was not successful

copyPhysicalProperties

public void copyPhysicalProperties(MTBImage sourceImg)
Copy physical properties like stepsizes and units from sourceImg to this.

Parameters:
sourceImg -

createMTBImage

public static MTBImage createMTBImage(ij.ImagePlus img)
                               throws java.lang.IllegalArgumentException
Factory method to create MTBImage objects. Checks the image type and returns the appropriate subclass object (MTBImageByte, MTBImageShort, ...) If the ImagePlus already contains a MTBImage in its properties, this MTBImage is returned

Parameters:
img - ImagePlus object to wrap
Returns:
MTBImage subclass object
Throws:
java.lang.IllegalArgumentException - for unsupported types

createMTBImage

public static MTBImage createMTBImage(int sizeX,
                                      int sizeY,
                                      int sizeZ,
                                      int sizeT,
                                      int sizeC,
                                      MTBImage.MTBImageType type)
                               throws java.lang.IllegalArgumentException
Factory method to create MTBImage objects with value 0 at each coordinate.

Parameters:
sizeX - size in x-dimension
sizeY - size in y-dimension
sizeZ - size in z-dimension
sizeT - size in t-dimension
sizeC - size in c-dimension
type - image type (one of MTB_BYTE, MTB_SHORT, MTB_INT, MTB_FLOAT, MTB_DOUBLE)
Returns:
MTBImage subclass object
Throws:
java.lang.IllegalArgumentException

createMTBImageByte

protected static MTBImage createMTBImageByte(int sizeX,
                                             int sizeY,
                                             int sizeZ,
                                             int sizeT,
                                             int sizeC,
                                             byte[][] data)
                                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

drawLine2D

public void drawLine2D(int xstart,
                       int ystart,
                       int xend,
                       int yend,
                       int value)
Draws a 2D line into the current slice of the image.

MTBImages are 5D, but here t- and c-dimensions are ignored. This function implements the Bresenham algorithm. Code was 'stolen' from Wikipedia, http://de.wikipedia.org/wiki/Bresenham-Algorithmus, and then translated into Java (German comments where kept).

Parameters:
xstart - x-coordinate of start point.
ystart - y-coordinate of start point.
xend - x-coordinate of end point.
yend - y-coordinate of end point.
value - Color/gray-scale value of the polygon.

drawPoint2D

public void drawPoint2D(int x,
                        int y,
                        int z,
                        int value,
                        int mode)
Draws a point at given position into the x-y-plane.

MTBImages are 5D, but here t- and c-dimensions are ignored.

Parameters:
x - x-coordinate of point.
y - y-coordinate of point.
z - z-coordinate of point.
value - Color/gray-scale value to be used.
mode - Shape of the point (0 = one pixel, 1 = X, 2 = cross)

duplicate

public MTBImage duplicate()
Duplicates the object. That means also a copy of the underlying ImagePlus (or other data structure) is created. The method uses the internal MTBImageFactory, which extends MTBOperator, thus the duplicated image will keep its history. The reference to the calling operator is set to null, use duplicate(MTBOperator) if you need to specify the calling operator.

Returns:
MTBImage of the same type

duplicate

public MTBImage duplicate(MTBOperator callingOperator)
Duplicates the object. That means also a copy of the underlying ImagePlus (or other data structure) is created. The method uses the internal MTBImageFactory, which extends MTBOperator, thus the duplicated image will keep its history.

Parameters:
callingOperator - the MTBOperator, which calls this method
Returns:
MTBImage of the same type

equals

public boolean equals(MTBImage img)
Test if this object and img are of same type, have same size and same values

Parameters:
img - image to compare with
Returns:
true if same type, size and values

equalSize

public boolean equalSize(MTBImage img)
Test if this object and img have the same size in x-, y-, z-, t- and c-dimension

Parameters:
img - image to compare with
Returns:
true if this object and img have the same size, else false

fillBlack

public void fillBlack()

fillWhite

public void fillWhite()

getCalibration

public ij.measure.Calibration getCalibration()
Get the calibration object. The MTBImage and the underlying ImagePlus (if available) share the same Calibration object. This object stores information about physical pixel size, world coordinates (it can return world coordinate for a specified pixel coordinate) etc.


getCurrentSlice

public MTBImage getCurrentSlice()
Get a copy of the current slice. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history. If you need to specify the calling operator, use getCurrentSlice(MTBOperator)

Returns:
copy of current slice or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException

getCurrentSlice

public MTBImage getCurrentSlice(MTBOperator callingOperator)
Get a copy of the current slice. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history.

Parameters:
callingOperator - the MTBOperator, which calls this method
Returns:
copy of current slice or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException

getCurrentSliceCoords

public int[] getCurrentSliceCoords()
Get the current slice coordinates (z,t,c) (for functions that work on a slice only, this has nothing to do with the ij.ImageStack's current slice)

Returns:
(z,t,c)-coordinate of the current slice. [0]= z-coordinate, [1]= t-coordinate, [2]= c-coordinate

getCurrentSliceIndex

public int getCurrentSliceIndex()
Get the current slice index (for functions that work on a slice only, this has nothing to do with the ij.ImageStack's current slice)

Returns:
(z,t,c)-coordinate of the current slice. [0]= z-coordinate, [1]= t-coordinate, [2]= c-coordinate

getCurrentSliceLabel

public java.lang.String getCurrentSliceLabel()
Get the slice label of the slice specified by the current slice index

Returns:

getCurrentZStackCoords

public int[] getCurrentZStackCoords()
Get the current z-stack coordinates. [0]=t-coordinate, [1]=c-coordinate. They are independent of the current slice index.

Returns:
array with the current t and c coordinates ([0]= t-coordinate, [1]= c-coordinate)

getImagePart

public MTBImage getImagePart(int x,
                             int y,
                             int z,
                             int t,
                             int c,
                             int sizeX,
                             int sizeY,
                             int sizeZ,
                             int sizeT,
                             int sizeC)
                      throws java.lang.IllegalArgumentException
Get a copy of a part of this image as new MTBImage. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history. If you need to specify the calling operator, use getImagePart(MTBOperator, ...)

Parameters:
x - x-coordinate where the first value is copied from
y - y-coordinate where the first value is copied from
z - z-coordinate where the first value is copied from
t - t-coordinate where the first value is copied from
c - c-coordinate where the first value is copied from
sizeX - size of the copied part in x-dimension
sizeY - size of the copied part in y-dimension
sizeZ - size of the copied part in z-dimension
sizeT - size of the copied part in t-dimension
sizeC - size of the copied part in c-dimension
Returns:
new MTBImage with values equal to the specified part or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException - if image boundaries are exceeded in any way

getImagePart

public MTBImage getImagePart(MTBOperator callingOperator,
                             int x,
                             int y,
                             int z,
                             int t,
                             int c,
                             int sizeX,
                             int sizeY,
                             int sizeZ,
                             int sizeT,
                             int sizeC)
                      throws java.lang.IllegalArgumentException
Get a copy of a part of this image as new MTBImage. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history.

Parameters:
callingOperator - the MTBOperator, which calls this method
x - x-coordinate where the first value is copied from
y - y-coordinate where the first value is copied from
z - z-coordinate where the first value is copied from
t - t-coordinate where the first value is copied from
c - c-coordinate where the first value is copied from
sizeX - size of the copied part in x-dimension
sizeY - size of the copied part in y-dimension
sizeZ - size of the copied part in z-dimension
sizeT - size of the copied part in t-dimension
sizeC - size of the copied part in c-dimension
Returns:
new MTBImage with values equal to the specified part or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException - if image boundaries are exceeded in any way

getImagePlus

public abstract ij.ImagePlus getImagePlus()
Get an ImagePlus object. For ImageJ-types (MTB_BYTE, MTB_SHORT, MTB_FLOAT) with underlying ImagePlus object, a reference to this ImagePlus is returned. For Non-ImageJ-types (MTB_INT, MTB_DOUBLE) an ImagePlus object is created for displaying but with definite LOSS OF INFORMATION. The ImagePlus object's properties contain a reference to the MTBImage under the key "MTBImage", which can be retrieved by the following code: (MTBImage)(ImagePlus.getProperty("MTBImage")) ;

Returns:
ImagePlus object

getMinMaxDouble

public abstract double[] getMinMaxDouble()
Get minimum and maximum value of the image as double

Returns:
min at double[0], max at double[1]

getMinMaxInt

public abstract int[] getMinMaxInt()
Get minimum and maximum value of the image as int

Returns:
min at int[0], max at int[1]

getSizeC

public int getSizeC()
Get size of c(hannel)-dimension

Specified by:
getSizeC in interface MTBImageManipulator
Returns:
size of c(hannel)-dimension

getSizeStack

public int getSizeStack()
Get size of the underlying (ImageJ) stack which corresponds to the number of slices

Returns:
size of c(hannel)-dimension

getSizeT

public int getSizeT()
Get size of t(ime)-dimension

Specified by:
getSizeT in interface MTBImageManipulator
Returns:
size of t(ime)-dimension

getSizeX

public int getSizeX()
Get size of x-dimension

Specified by:
getSizeX in interface MTBImageManipulator
Returns:
size of x-dimension

getSizeY

public int getSizeY()
Get size of y-dimension

Specified by:
getSizeY in interface MTBImageManipulator
Returns:
size of y-dimension

getSizeZ

public int getSizeZ()
Get size of z-dimension

Specified by:
getSizeZ in interface MTBImageManipulator
Returns:
size of z-dimension

getSlice

public MTBImage getSlice(int z,
                         int t,
                         int c)
                  throws java.lang.IllegalArgumentException
Get a copy of the specified slice. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history. If you need to specify the calling operator, use getSlice(MTBOperator, ...)

Parameters:
z -
t -
c -
Returns:
copy of specified slice or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException - if z, c or t do not match the image size

getSlice

public MTBImage getSlice(MTBOperator callingOperator,
                         int z,
                         int t,
                         int c)
                  throws java.lang.IllegalArgumentException
Get a copy of the specified slice. This method uses the internal MTBImageFactory, which extends MTBOperator, thus the new image will share the history.

Parameters:
callingOperator - the MTBOperator, which calls this method
z -
t -
c -
Returns:
copy of specified slice or null if the operation was not successful
Throws:
java.lang.IllegalArgumentException - if z, c or t do not match the image size

getSliceLabel

public java.lang.String getSliceLabel(int z,
                                      int t,
                                      int c)
Get the slice label of the slice specified by (z,t,c)

Parameters:
z -
t -
c -
Returns:

getStepsizeT

public double getStepsizeT()
Get the stepsize in t-dimension (timestep)

Specified by:
getStepsizeT in interface MTBImageManipulator
Returns:
time stepsize

getStepsizeX

public double getStepsizeX()
Get the physical size of a voxel (stepsize) in x-dimension

Specified by:
getStepsizeX in interface MTBImageManipulator
Returns:
physical voxel size in x-dimension

getStepsizeY

public double getStepsizeY()
Get the physical size of a voxel (stepsize) in y-dimension

Specified by:
getStepsizeY in interface MTBImageManipulator
Returns:
physical voxel size in y-dimension

getStepsizeZ

public double getStepsizeZ()
Get the physical size of a voxel (stepsize) in z-dimension

Specified by:
getStepsizeZ in interface MTBImageManipulator
Returns:
physical voxel size in z-dimension

getTitle

public java.lang.String getTitle()
Get the image's title

Specified by:
getTitle in interface MTBImageManipulator
Returns:

getTitleRunning

public static java.lang.String getTitleRunning(java.lang.String title)
Return a unique title for the copy of an image, i.e. a running number is appended/incremented. For example, if "TITLE" is the original title, then "TITLE-1" is the return title. If "TITLE-2" is entered, then "TITLE-3" is returned. File extensions are considered: "TITLE.tif" results in "TITLE-1.tif". If ImageJ's WindowManager is available, displayed images are also considered to determine the highest running number.

Parameters:
title - of the original image
Returns:
title used for the copy of an image

getType

public MTBImage.MTBImageType getType()
Get MiToBo image type

Specified by:
getType in interface MTBImageManipulator
Returns:
image type (MTBImage.MTB_BYTE, MTBImage.MTB_SHORT, MTBImage.MTB_INT, MTBImage.MTB_FLOAT, MTBImage.MTB_DOUBLE)

getTypeMax

public double getTypeMax()
Return the maximum value that the current type can handle

Returns:

getTypeMin

public double getTypeMin()
Return the minimum value that the current type can handle

Returns:

getTypeName

@Deprecated
public static java.lang.String getTypeName(int type)
Deprecated. 

Returns type identifier for given id.

Parameters:
type - Numerical identifier for image.
Returns:
Identifier string, null is non-existent.

getUnitT

public java.lang.String getUnitT()
Get the unit of the t-dimension

Specified by:
getUnitT in interface MTBImageManipulator
Returns:
String of t-dimension's unit

getUnitX

public java.lang.String getUnitX()
Get the unit of the x-dimension

Specified by:
getUnitX in interface MTBImageManipulator
Returns:
String of x-dimension's unit

getUnitY

public java.lang.String getUnitY()
Get the unit of the y-dimension

Specified by:
getUnitY in interface MTBImageManipulator
Returns:
String of y-dimension's unit

getUnitZ

public java.lang.String getUnitZ()
Get the unit of the z-dimension

Specified by:
getUnitZ in interface MTBImageManipulator
Returns:
String of z-dimension's unit

getValueDouble

public abstract double getValueDouble(int x,
                                      int y)
Get the value of the current slice at coordinate (x,y) as an Double

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
Returns:
voxel value

getValueDouble

public abstract double getValueDouble(int x,
                                      int y,
                                      int z)
Get the value of the current slice at coordinate (x,y,z) as an Double

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
Returns:
voxel value

getValueDouble

public abstract double getValueDouble(int x,
                                      int y,
                                      int z,
                                      int t,
                                      int c)
Get the value of the 5D image at coordinate (x,y,z,t,c) as a Double

Specified by:
getValueDouble in interface MTBImageManipulator
Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
t - t-coordinate ranging from 0 to (sizeT - 1)
c - c-coordinate ranging from 0 to (sizeC - 1)
Returns:
voxel value

getValueInt

public abstract int getValueInt(int x,
                                int y)
Get the value of the current slice at coordinate (x,y) as an Integer

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
Returns:
voxel value

getValueInt

public abstract int getValueInt(int x,
                                int y,
                                int z)
Get the value of the current z-stack coordinate (x,y,z) as an Integer

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
Returns:
voxel value

getValueInt

public abstract int getValueInt(int x,
                                int y,
                                int z,
                                int t,
                                int c)
Get the value of the 5D image at coordinate (x,y,z,t,c) as an Integer

Specified by:
getValueInt in interface MTBImageManipulator
Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
t - t-coordinate ranging from 0 to (sizeT - 1)
c - c-coordinate ranging from 0 to (sizeC - 1)
Returns:
voxel value

getXML

public java.lang.String getXML()
Get the XML file description string if one was available. The MTBImage and the underlying ImagePlus (if available) share the same XML String. The string is found in the FileInfo object of the ImagePlus by the key "xml".

Returns:

hasImagePlus

public boolean hasImagePlus()

isValidType

@Deprecated
public static boolean isValidType(MTBImage.MTBImageType type)
Deprecated. 

Checks if the given type identifier is valid.

Parameters:
type - Integer specifying a MTBImage type.
Returns:
True, if type integer is valid.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

ordinalToType

public static MTBImage.MTBImageType ordinalToType(int enumIdx)
Return the corresponding MTBImageType for its index in the enum. If this index doesn't exist, null is returned

Parameters:
s - String must be one of "MTB_BYTE", "MTB_SHORT", "MTB_INT", "MTB_FLOAT", "MTB_DOUBLE", "MTB_RGB"
Returns:

putValueDouble

public abstract void putValueDouble(int x,
                                    int y,
                                    double value)
Set the value of the current slice at coordinate (x,y) using a Double

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
value - to set the voxel to

putValueDouble

public abstract void putValueDouble(int x,
                                    int y,
                                    int z,
                                    double value)
Set the value of the current slice at coordinate (x,y,z) using a Double

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
value - to set the voxel to

putValueDouble

public abstract void putValueDouble(int x,
                                    int y,
                                    int z,
                                    int t,
                                    int c,
                                    double value)
Set the value of the 5D image at coordinate (x,y,z,t,c) using a Double

Specified by:
putValueDouble in interface MTBImageManipulator
Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
t - t-coordinate ranging from 0 to (sizeT - 1)
c - c-coordinate ranging from 0 to (sizeC - 1)
value - to set the voxel to

putValueInt

public abstract void putValueInt(int x,
                                 int y,
                                 int value)
Set the value of the current slice at coordinate (x,y) using an Integer

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
value - to set the voxel to

putValueInt

public abstract void putValueInt(int x,
                                 int y,
                                 int z,
                                 int value)
Set the value of the current slice at coordinate (x,y,z) using an Integer

Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
value - to set the voxel to

putValueInt

public abstract void putValueInt(int x,
                                 int y,
                                 int z,
                                 int t,
                                 int c,
                                 int value)
Set the value of the 5D image at coordinate (x,y,z,t,c) using an Integer

Specified by:
putValueInt in interface MTBImageManipulator
Parameters:
x - x-coordinate ranging from 0 to (sizeX - 1)
y - y-coordinate ranging from 0 to (sizeY - 1)
z - z-coordinate ranging from 0 to (sizeZ - 1)
t - t-coordinate ranging from 0 to (sizeT - 1)
c - c-coordinate ranging from 0 to (sizeC - 1)
value - to set the voxel to

scaleValues

public MTBImageDouble scaleValues(int c,
                                  int t,
                                  double curMin,
                                  double curMax,
                                  double scaleMin,
                                  double scaleMax)
                           throws java.lang.IllegalArgumentException
Method to scale the intensity values (range [curMin, curMax]) of the image to a given range [scaleMin, scaleMax]. In general curMin < curMax, curMin != curMax and scaleMin < scaleMax is required.

Parameters:
c - current c-coordinate of channel dimension
t - current t-coordinate of time dimension
curMin - minimal intensity value of the current image
curMax - maximal intensity value of the current image
scaleMin - new minimal intensity value of the scaled image
scaleMax - new maximal intensity value of the scaled image
Returns:
Image with scaled intensity values in range [scaleMin, scaleMax].
Throws:
java.lang.IllegalArgumentException - on illegal scaling values

setCalibration

public void setCalibration(ij.measure.Calibration calibration)
Set the calibration object (see getCalibration() for further information).

Parameters:
calibration -

setCurrentSlice

public void setCurrentSlice(MTBImageManipulator src)
                     throws java.lang.IllegalArgumentException
Copy the values of the source to the current slice

Parameters:
src -
Throws:
java.lang.IllegalArgumentException

setCurrentSliceCoords

public void setCurrentSliceCoords(int z,
                                  int t,
                                  int c)
Set the current slice for functions that work on a slice only (this has nothing to do with the ij.ImageStack's current slice)


setCurrentSliceIndex

public void setCurrentSliceIndex(int stackindex)
Set the current slice for functions that work on a slice only (this has nothing to do with the ij.ImageStack's current slice) Stack indices range from 0 to N-1 (unlike ImageJ, where stack indices range from 1 to N)

Parameters:
stackindex - index of the slice in the underlying (ImageJ) stack

setCurrentSliceLabel

public void setCurrentSliceLabel(java.lang.String label)
Set the slice label of the slice specified by the current slice index

Parameters:
label -

setCurrentZStackCoordinates

public void setCurrentZStackCoordinates(int t,
                                        int c)
Set the current z-stack coordinates for functions that work on (spatial) 3D only. The coordinates are not checked for their validity. They are independent of the current slice index. E.g. after setting z-stack coordinates to 't' and 'c', the functions getValueInt(x,y,z) is equivalent to getValueInt(x,y,z,'t','c').

Parameters:
t - current t-coordinate
c - current c-coordinate

setImagePart

public void setImagePart(MTBImageManipulator src,
                         int x,
                         int y,
                         int z,
                         int t,
                         int c)
                  throws java.lang.IllegalArgumentException
Set a part of this image to the values of the source

Parameters:
src - source MTBImage (or MTBImageWindow)
x - x-coordinate where the first value is copied to
y - y-coordinate where the first value is copied to
z - z-coordinate where the first value is copied to
t - t-coordinate where the first value is copied to
c - c-coordinate where the first value is copied to
Throws:
java.lang.IllegalArgumentException - if image boundaries are exceeded in any way

setSlice

public void setSlice(MTBImageManipulator src,
                     int z,
                     int t,
                     int c)
              throws java.lang.IllegalArgumentException
Copy the value of source to the specified slice

Parameters:
src -
z -
t -
c -
Throws:
java.lang.IllegalArgumentException

setSliceLabel

public void setSliceLabel(java.lang.String label,
                          int z,
                          int t,
                          int c)
Set the slice label of the slice specified by (z,t,c)

Parameters:
label -
z -
t -
c -

setStepsizeT

public void setStepsizeT(double stepsize)
Set the stepsize in t-dimension (timestep)

Parameters:
stepsize -

setStepsizeX

public void setStepsizeX(double stepsize)
Set the physical size of a voxel (stepsize) in x-dimension

Parameters:
stepsize -

setStepsizeY

public void setStepsizeY(double stepsize)
Set the physical size of a voxel (stepsize) in y-dimension

Parameters:
stepsize -

setStepsizeZ

public void setStepsizeZ(double stepsize)
Set the physical size of a voxel (stepsize) in z-dimension

Parameters:
stepsize -

setTitle

public void setTitle(java.lang.String title)
Set the image's title.

Parameters:
title - New title for image.
Throws:
MTBImageException

setUnitT

public void setUnitT(java.lang.String unit)
Set the unit of the t-dimension

Parameters:
unit - String of t-dimension unit

setUnitX

public void setUnitX(java.lang.String unit)
Set the unit of the x-dimension

Parameters:
unit - String of x-dimension unit

setUnitY

public void setUnitY(java.lang.String unit)
Set the unit of the y-dimension

Parameters:
unit - String of y-dimension unit

setUnitZ

public void setUnitZ(java.lang.String unit)
Set the unit of the z-dimension

Parameters:
unit - String of z-dimension unit

setXML

public void setXML(java.lang.String xml)
Set the XML file description string if one was available

Parameters:
xml -

show

public void show()
Display the image as an ImagePlus. Keep in mind that the MiToBo image types MTB_INT and MTB_DOUBLE have no equivalent ImageJ types. Thus this function creates an ImagePlus object of a reduced precision type (short/float) for display. These ImagePlus objects do NOT share data and thus are uncoupled of the MTBImage. You can find the MTBImage in the ImagePlus' properties with the key "MTBImage"


stringToType

public static MTBImage.MTBImageType stringToType(java.lang.String s)
For a given String, return the corresponding MTBImageType. If the String doesn't match any type, null is returned

Parameters:
s - String must be one of "MTB_BYTE", "MTB_SHORT", "MTB_INT", "MTB_FLOAT", "MTB_DOUBLE", "MTB_RGB"
Returns:

toString

public java.lang.String toString()
Returns the String "IMG("title of the image")"

Overrides:
toString in class java.lang.Object

updateAndRepaintWindow

public void updateAndRepaintWindow()
Update and repaint the image window if the image is displayed by ImageJ


updateImagePlus

protected abstract void updateImagePlus()
Should be used to create or update ImagePlus data if the MTBImage is not using an ImagePlus to store the data (MTB_INT, MTB_DOUBLE, MTB_RGB). For the other types, changes are made to the underlying ImagePlus directly, thus this method should do nothing.


updateImageSize_ImgToProp

protected void updateImageSize_ImgToProp()
Update the image size in the properties hashtable from the image's size


updatePhysProperties_ImgToProp

protected void updatePhysProperties_ImgToProp()
Update physical properties (stepsizes, units) in the properties hashtable from its member variables


updatePhysProperties_PropToImg

protected void updatePhysProperties_PropToImg()
Update physical properties (stepsizes, units) of the image (member variables) from its properties hashtable