annotool.io
Class DataInput

java.lang.Object
  extended by annotool.io.DataInput

public class DataInput
extends java.lang.Object

The class that wraps the data.


Field Summary
static int COLOR_256
           
static int COLOR_RGB
           
static int DIRECTORYMODE
           
static int GRAY16
           
static int GRAY32
           
static int GRAY8
           
static int ROIANNOMODE
           
static int ROIMODE
           
static int TARGETFILEMODE
           
 
Constructor Summary
DataInput(ij.ImagePlus image, java.util.HashMap<java.lang.String,ij.gui.Roi> roiList, java.util.HashMap<java.lang.String,java.lang.String> classMap, java.lang.String channel, int depth, int newwidth, int newheight)
          Creates DataInput object in ROI input method.
DataInput(java.lang.String directory, java.lang.String[] files, java.lang.String ext, java.lang.String channel)
          This constructor takes no target file and is strictly for ROI Annotation mode.
DataInput(java.lang.String directory, java.lang.String ext, java.lang.String channel, boolean useDirStructureForTarget)
          This constructor takes a directory hierarchy that has image of different classes There is no need of the target file in this case.
DataInput(java.lang.String directory, java.lang.String ext, java.lang.String channel, java.lang.String targetFile)
          This constructor takes the target file (in addition to image dir, ext, channel) to populate the label related information.
DataInput(java.lang.String directory, java.lang.String ext, java.lang.String channel, java.lang.String targetFile, int newwidth, int newheight)
          The constructor takes the target file and resize the (2D) images based on the dimension passed in If the images are 3D, it resizes each slice.
 
Method Summary
 java.util.ArrayList getAllStacksOfOneImage(int imageindex)
          Get one image or ROI with all the stacks.
 java.util.ArrayList<java.lang.String> getAnnotations()
           
 java.lang.String getChannel()
           
 java.lang.String[] getChildren()
           
 java.util.HashMap<java.lang.String,java.lang.String> getClassNames()
           
 java.lang.Object getData(int imgIndex, int stackIndex)
          Get the array of the image (2D slice) of a given stackIndex The type of the Object depends on the image type
 int getDepth()
          This method is preferred since it covers both ROI and non-ROI cases This returns the depth if ROI, and the stack size for non-ROI.
 int[] getDepthList()
           
 int getHeight()
          It is the height of the first image (or ROI).
 int[] getHeightList()
           
 ij.ImagePlus getImagePlus(int i)
          Return the ImagePlus object of the given image index.
 int getImageType()
           
 int getLength()
           
 int getMode()
           
 ij.ImagePlus getROIImagePlus(int i)
           
 java.util.ArrayList<java.lang.Object> getStackData(int stackIndex)
          Deprecated.
 int getStackSize()
          This is the stack size of the first image in the case of image set.
 int[][] getTargets()
           
 int getWidth()
          It is the width of the first image (or ROI).
 int[] getWidthList()
           
 boolean is3D()
           
 boolean isColor()
           
 boolean isDirectoryMode()
           
 boolean ofSameSize()
          If all images are of the same size, return true; otherwise, return false.
static java.lang.Object openOneImage(ij.ImagePlus imgp, int stackIndex, java.lang.String channel, int width, int height)
           
 void setChannel(java.lang.String channel)
          To set channel for an already constructed object.
 void setDataNull()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRAY8

public static final int GRAY8
See Also:
Constant Field Values

GRAY16

public static final int GRAY16
See Also:
Constant Field Values

GRAY32

public static final int GRAY32
See Also:
Constant Field Values

COLOR_256

public static final int COLOR_256
See Also:
Constant Field Values

COLOR_RGB

public static final int COLOR_RGB
See Also:
Constant Field Values

TARGETFILEMODE

public static final int TARGETFILEMODE
See Also:
Constant Field Values

DIRECTORYMODE

public static final int DIRECTORYMODE
See Also:
Constant Field Values

ROIMODE

public static final int ROIMODE
See Also:
Constant Field Values

ROIANNOMODE

public static final int ROIANNOMODE
See Also:
Constant Field Values
Constructor Detail

DataInput

public DataInput(java.lang.String directory,
                 java.lang.String ext,
                 java.lang.String channel,
                 java.lang.String targetFile,
                 int newwidth,
                 int newheight)
          throws java.lang.Exception
The constructor takes the target file and resize the (2D) images based on the dimension passed in If the images are 3D, it resizes each slice.

Throws:
java.lang.Exception

DataInput

public DataInput(java.lang.String directory,
                 java.lang.String ext,
                 java.lang.String channel,
                 java.lang.String targetFile)
          throws java.lang.Exception
This constructor takes the target file (in addition to image dir, ext, channel) to populate the label related information. In the Annotation mode, the target file can be null. The channel can also be set to null if it is a B/W image set.

Throws:
java.lang.Exception

DataInput

public DataInput(java.lang.String directory,
                 java.lang.String[] files,
                 java.lang.String ext,
                 java.lang.String channel)
          throws java.lang.Exception
This constructor takes no target file and is strictly for ROI Annotation mode.

Throws:
java.lang.Exception

DataInput

public DataInput(ij.ImagePlus image,
                 java.util.HashMap<java.lang.String,ij.gui.Roi> roiList,
                 java.util.HashMap<java.lang.String,java.lang.String> classMap,
                 java.lang.String channel,
                 int depth,
                 int newwidth,
                 int newheight)
          throws java.lang.Exception
Creates DataInput object in ROI input method.

Parameters:
image -
roiList - HashMap with roi names for keys and Roi objects for values
classMap - HashMap with roi names for keys and corresponding class names for values
channel - r, g or b
depth - for 3D ROI
newwidth - only if need to resize
newheight - only if need to resize
Throws:
java.lang.Exception

DataInput

public DataInput(java.lang.String directory,
                 java.lang.String ext,
                 java.lang.String channel,
                 boolean useDirStructureForTarget)
          throws java.lang.Exception
This constructor takes a directory hierarchy that has image of different classes There is no need of the target file in this case. The subdirectory names are assumed to be the names of the classes. The channel can be set to null if it is a B/W image set.

Throws:
java.lang.Exception
Method Detail

getStackData

public java.util.ArrayList<java.lang.Object> getStackData(int stackIndex)
                                                   throws java.lang.Exception
Deprecated. A lot of memory for large sets. Not recommended. return the pixel data -- The algorithm needs to use a mask to avoid sign extension such as data[i][j]&0xff (for byte) stackIndex: between 1 and stackSize.

Throws:
java.lang.Exception

getData

public java.lang.Object getData(int imgIndex,
                                int stackIndex)
                         throws java.lang.Exception
Get the array of the image (2D slice) of a given stackIndex The type of the Object depends on the image type

Parameters:
imgIndex - start from 0
stackIndex - start from 1.
Returns:
Throws:
java.lang.Exception

getLength

public int getLength()
              throws java.lang.Exception
Throws:
java.lang.Exception

getWidth

public int getWidth()
             throws java.lang.Exception
It is the width of the first image (or ROI).

Returns:
int
Throws:
java.lang.Exception

getHeight

public int getHeight()
              throws java.lang.Exception
It is the height of the first image (or ROI).

Returns:
int
Throws:
java.lang.Exception

getStackSize

public int getStackSize()
                 throws java.lang.Exception
This is the stack size of the first image in the case of image set. In the case of ROI, this is the stack size of the entire image.

Returns:
Throws:
java.lang.Exception

getDepth

public int getDepth()
             throws java.lang.Exception
This method is preferred since it covers both ROI and non-ROI cases This returns the depth if ROI, and the stack size for non-ROI. In the case of 3D ROI, it is 1+. If 2D ROI: should be the fault depth from ROI input dialog: 1; If not a ROI: the depth instance is 0 (from default value of DataInput), so the stackSize of the image is returned.

Returns:
int depth
Throws:
java.lang.Exception

getChildren

public java.lang.String[] getChildren()
                               throws java.lang.Exception
Throws:
java.lang.Exception

is3D

public boolean is3D()

isColor

public boolean isColor()

setDataNull

public void setDataNull()

getImagePlus

public ij.ImagePlus getImagePlus(int i)
                          throws java.lang.Exception
Return the ImagePlus object of the given image index. In the case of ROI, the parameter is ignored and the entire image is returned. In the case of RGB, the image of the channel is wrapped into an image and returned.

Parameters:
i - The index of the image to be returned. (Ignored in ROI mode.)
Returns:
The ith image in the case of image set. Or the entire image in the case of ROI.
Throws:
java.lang.Exception

getROIImagePlus

public ij.ImagePlus getROIImagePlus(int i)
                             throws java.lang.Exception
Throws:
java.lang.Exception

getImageType

public int getImageType()

ofSameSize

public boolean ofSameSize()
If all images are of the same size, return true; otherwise, return false.

Returns:
boolean

getAllStacksOfOneImage

public java.util.ArrayList getAllStacksOfOneImage(int imageindex)
                                           throws java.lang.Exception
Get one image or ROI with all the stacks. Each item in the ArrayList is a stack. Intended for 3D images. The stack index for the returned ArrayList starts from 0.

Parameters:
imageindex -
Returns:
an ArrayList of 3D data array.
Throws:
java.lang.Exception

getWidthList

public int[] getWidthList()
                   throws java.lang.Exception
Throws:
java.lang.Exception

getHeightList

public int[] getHeightList()
                    throws java.lang.Exception
Throws:
java.lang.Exception

getDepthList

public int[] getDepthList()
                   throws java.lang.Exception
Throws:
java.lang.Exception

getTargets

public int[][] getTargets()

getAnnotations

public java.util.ArrayList<java.lang.String> getAnnotations()

getClassNames

public java.util.HashMap<java.lang.String,java.lang.String> getClassNames()

setChannel

public void setChannel(java.lang.String channel)
To set channel for an already constructed object. This will clear the existing data if the channel is changed.

Parameters:
channel -

getChannel

public java.lang.String getChannel()

isDirectoryMode

public boolean isDirectoryMode()

getMode

public int getMode()

openOneImage

public static java.lang.Object openOneImage(ij.ImagePlus imgp,
                                            int stackIndex,
                                            java.lang.String channel,
                                            int width,
                                            int height)
                                     throws java.lang.Exception
Throws:
java.lang.Exception