DefaultImageS

public class DefaultImageS implements ImageS

The default implementation of the ImageS interface. The default implementation currently wraps ImageJ1’s ImageStack class. See https://imagej.nih.gov/ij/developer/api/ij/ImagePlus.html for more information.

Author:Kyle M. Douglass

Constructors

DefaultImageS

public DefaultImageS(int width, int height)

Creates a new and empty DefaultImageS.

DefaultImageS

public DefaultImageS(int[][] pixels)

Creates a new DefaultImageS object from a 2D array of ints. The first index of the input array should correspond to x; the second corresponds to y.

Parameters:
  • pixels – The 2D array of pixel values.

DefaultImageS

public DefaultImageS(float[][] pixels)

Creates a new DefaultImageS object from a 2D array of floats. The first index of the input array should correspond to x; the second corresponds to y.

Parameters:
  • pixels – The 2D array of pixel values.

Methods

addImage

public void addImage(short[][] image)

Adds a 2D array of shorts to the dataset.

Parameters:
  • image – A 2D array of shorts.

addImage

public void addImage(int[][] image)

Converts a 2D array of ints to 16-bit shorts and adds it to the dataset.

Parameters:
  • image – A 2D array of ints indexed by xy.
Throws:

addImage

public void addImage(float[][] image)

Converts a 2D array of floats to 16-bit shorts and adds it to the dataset.

Parameters:
  • image – A 2D array of floats indexed by xy.
Throws:

concatenate

public void concatenate(ImageS dataset)

Appends another ImageS dataset to the end of this one.

Parameters:
  • dataset – The images to add to the dataset.

getBitDepth

public int getBitDepth()

getHeight

public int getHeight()

Returns the height of the images in the dataset.

Returns:The height of the images in the dataset.

getPixelData

public short[] getPixelData(int index)

Returns the pixel data at the given index as a 1D array.

Parameters:
  • index – The index of the corresponding slice.
Returns:

The pixel data at the provided index.

getSize

public int getSize()

Returns the number of images in the dataset.

Returns:The number of images in the dataset.

getSlice

public int getSlice()

Gets the active slice of the dataset (0-indexed). This is the image that will be displayed in the viewer.

Returns:The index of the active slice.

getTitle

public String getTitle()

Returns the title of the image stack.

Returns:The title of the image stack.

getWidth

public int getWidth()

Returns the width of the images in the dataset.

Returns:The width of the images in the dataset.

saveAsTiffStack

public void saveAsTiffStack(File file)

Saves the images to a TIFF file.

serializeToArray

public byte[] serializeToArray()

Serializes the image stack to a TIFF-encoded byte array.

Returns:A TIFF-encoded byte array.

serializeToBuffer

public ByteBuffer serializeToBuffer()

Returns a buffer containing the dataset in a TIFF-encoded byte array.

Returns:A buffer containing the dataset in a TIFF-encoded byte array.

setSlice

public void setSlice(int index)

Sets the active slice of the dataset (0-indexed). This is the image that will be displayed in the viewer.

Parameters:
  • index – The index of the slice to activate.

setTitle

public void setTitle(String title)

Sets the title of the image stack.

Parameters:
  • title – The title of the image stack.

updateView

public void updateView()

Updates the dataset viewer to show the currently active slice.

view

public void view()

Displays the images in a ImagePlus window.