Package gov.nih.mipav.model.structures
Class ModelSimpleImage
java.lang.Object
gov.nih.mipav.model.structures.ModelSerialCloneable
gov.nih.mipav.model.structures.ModelSimpleImage
- All Implemented Interfaces:
Serializable,Cloneable
This is very simple class to store a float type image of up to four dimensions. For speed all class variables are
public. This class is used extensively in Registration algorithms where we needs many copies of the image where the
data does not need to be visible to the UserInterface. With the data array as public speed is achieved but at a cost
that the buffer is always of the type float.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloatX coordinate value of the center of mass for the image.floatY coordinate value of the center of mass for the image.floatZ coordinate value of the center of mass for the image.float[]Data buffer that is used to store the image.intSize of the data buffer (number of pixels in image).int[]The dimensionality of the dataset.booleanIndicates whether is image is a color image or not.floatMaximum intensity values of image.floatMaximum intensity values of image.floatMaximum intensity values of image.floatMaximum intensity values of image.floatMinimum intensity values of image.floatMinimum intensity values of image.floatMinimum intensity values of image.floatMinimum intensity values of image.add simple image name for AAM model only.intNumber of dimensions of the image.float[]Voxel resolutions (typically x,y,z(slice spacing),t).private static final longUse serialVersionUID for interoperability.intNumber of volumes in the dataset.floatResolution in the time dimension.intNumber of pixels in x dimension.floatX pixel resolution.intNumber of pixels in y dimension.floatY pixel resolution.intNumber of pixels in z dimension.floatZ voxel resolution. -
Constructor Summary
ConstructorsConstructorDescriptionAdd the empty default contructor.ModelSimpleImage(int[] dimExtents) Creates a class to hold the minimum information about an image - the extents with the resolutions defaulted to 1.ModelSimpleImage(int[] dimExtents, float[] voxRes) Creates a class to hold the minimum information about an image - the extents and the resolutions.ModelSimpleImage(int[] dimExtents, float[] voxRes, boolean isColor) Creates a class to hold the minimum information about an image - the extents, the resolutions.ModelSimpleImage(int[] dimExtents, float[] voxRes, ModelImage image) Creates a class to hold the minimum information about an image - the extents, the resolutions, and optionally, the image data.ModelSimpleImage(int[] dimExtents, float[] voxRes, ModelImage image, int timeSlice) Creates a class to hold the minimum information about an image - the extents, the resolutions, and the image data.ModelSimpleImage(ModelImage image) Creates a class to hold the minimum information about an image - the extents, the resolutions, and optionall, the image data.ModelSimpleImage(ModelImage image, int timeSlice) Creates a class to hold the minimum information about an image - the extents, the resolutions, and the image data. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalculates the min and max values for the image array.voidcalculateCenterOfMass2D(boolean voxelResol) Calculates the center of mass (gravity) of a 2D image using the intensity of each pixel as a weighting value.voidcalculateCenterOfMass3D(boolean voxelResol) Calculates the center of mass (gravity) of a 3D image.voidCB(double y1, double y2, double d, double[] result) Binary interpolation callCreate a new image with the same dimensions as this image which contains the intensity value from this image if it is a color image or which contains the same values if the image is already an intensity image.createIntensityImage(float fScaleR, float fScaleG, float fScaleB) Create a new image with the same dimensions as this image which contains the intensity value from this image if it is a color image or which contains the same values if the image is already an intensity image.createMappedImage2d(ModelSimpleImage kImageMapX, ModelSimpleImage kImageMapY) Create a mapping of this image.createMappedImage3d(ModelSimpleImage kImageMapX, ModelSimpleImage kImageMapY, ModelSimpleImage kImageMapZ) Create a mapping of this image.intDepth()Used by AAM appearance model to get dimensionvoiddisposeLocal(boolean gcFlag) Nulls the data fields so that memory can be recovered.voidexportData(float[] buffer, int start, int end) Simple accessor to copy data from this class's data buffer.final voidFillPixels(float value) In model simple image, fill pixel with given intensity value.protected voidfinalize()Calls disposeLocal of this class to ensure this class nulls the references to global class variables so that memory will be recovered.final floatgetBiLinear(float x, float y) Version of get that performs bi-linear interpoloation.getName()Get the simple image namefinal floatgetTriLinear(float x, float y, float z) Version of get that performs tri-linear interpoloation.final floatgetValue(int x, int y) Get the value at the x, y position of the data array.intHeight()Used by AAM appearance model to get dimensionvoidimportData(float[] buffer, int start, int end) For AAM model only, import buffer to the simple image data.doublePixel1(float x, float y) Used by AAM appearance model to get bilinear interpolation.ReadBandedFile(String szFilename) Temporary function to handle AAM image file IO for AAM own testing cases.Temporary function to handle AAM image file IO for AAM own testing cases.voidSet the simple image namefinal voidsetValue(int x, int y, float value) Set the value at the x, y position of the data array.Takes a simple image and subsamples it by 2.subSample2dBy2(boolean isColor) Takes a simple image and subsamples it by 2.subSample2dBy2(ModelSimpleImage resultImage) Takes a simple image and subsamples it by 2.subSample2dBy2(ModelSimpleImage resultImage, boolean isColor) Takes a simple image and subsamples it by 2.Takes a simple image and subsamples it by 2.subsample3dBy2(boolean isColor) Takes a simple 3D image and subsamples it by 2.Takes a simple 3D image and subsamples each image plane (XY) by 2.subsample3dBy2XY(boolean isColor) Takes a simple 3D image and subsamples each image plane (XY) by 2.subSample3dBy2XY(ModelSimpleImage resultImage) Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.subSample3dBy2XY(ModelSimpleImage resultImage, boolean isColor) Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.toString()Returns a readable representation of this simple image.intWidth()Used by AAM appearance model to get dimensionMethods inherited from class gov.nih.mipav.model.structures.ModelSerialCloneable
clone, nativeClone
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
cMassX
public float cMassXX coordinate value of the center of mass for the image. -
cMassY
public float cMassYY coordinate value of the center of mass for the image. -
cMassZ
public float cMassZZ coordinate value of the center of mass for the image. -
data
public float[] dataData buffer that is used to store the image. -
dataSize
public int dataSizeSize of the data buffer (number of pixels in image). -
extents
public int[] extentsThe dimensionality of the dataset. -
isColor
public boolean isColorIndicates whether is image is a color image or not. -
max
public float maxMaximum intensity values of image. -
maxR
public float maxRMaximum intensity values of image. -
maxG
public float maxGMaximum intensity values of image. -
maxB
public float maxBMaximum intensity values of image. -
min
public float minMinimum intensity values of image. -
minR
public float minRMinimum intensity values of image. -
minG
public float minGMinimum intensity values of image. -
minB
public float minBMinimum intensity values of image. -
nDims
public int nDimsNumber of dimensions of the image. -
resolutions
public float[] resolutionsVoxel resolutions (typically x,y,z(slice spacing),t). -
tDim
public int tDimNumber of volumes in the dataset. Typically t represents time. -
tRes
public float tResResolution in the time dimension. -
xDim
public int xDimNumber of pixels in x dimension. -
xRes
public float xResX pixel resolution. -
yDim
public int yDimNumber of pixels in y dimension. -
yRes
public float yResY pixel resolution. -
zDim
public int zDimNumber of pixels in z dimension. -
zRes
public float zResZ voxel resolution. -
name
add simple image name for AAM model only.
-
-
Constructor Details
-
ModelSimpleImage
public ModelSimpleImage()Add the empty default contructor. AAM appearance model needs to call the default one for local image processing. -
ModelSimpleImage
Creates a class to hold the minimum information about an image - the extents, the resolutions, and optionall, the image data.- Parameters:
image- ModelImage structure where the input image data is stored. In this particular constructor, this parameter must not be null as the extents and resolutions are derived from the input image.
-
ModelSimpleImage
public ModelSimpleImage(int[] dimExtents) Creates a class to hold the minimum information about an image - the extents with the resolutions defaulted to 1. A data array of float type will be allocated where the size is defined by the dimExtents[].- Parameters:
dimExtents- Extents of the image; must be non null.
-
ModelSimpleImage
Creates a class to hold the minimum information about an image - the extents, the resolutions, and the image data. A data array of float type will be allocated where the size is defined by the ModelImage. Used for a 4D image to make a 3D ModelSimpleImage.- Parameters:
image- ModelImage Structure where the input image data is stored. In this particular call, this parameter must not be null as the extents and resolutions are derived from the input image.timeSlice- Time slice to export.
-
ModelSimpleImage
public ModelSimpleImage(int[] dimExtents, float[] voxRes) Creates a class to hold the minimum information about an image - the extents and the resolutions. A data array of float type will be allocated where the size is defined by the dimExtents[].- Parameters:
dimExtents- Extents of the image; must be non null.voxRes- Resolutions of the image; must be non null.
-
ModelSimpleImage
Creates a class to hold the minimum information about an image - the extents, the resolutions, and optionally, the image data. A data array of float type will be allocated where the size is defined by the dimExtents[].- Parameters:
dimExtents- Extents of the image; must be non null.voxRes- Resolutions of the image; must be non null.image- Structure where image data is stored; can be null. If it is null, the buffer associated with this class will be empty. The ModelImage is not otherwise saved or referenced within this class.
-
ModelSimpleImage
public ModelSimpleImage(int[] dimExtents, float[] voxRes, boolean isColor) Creates a class to hold the minimum information about an image - the extents, the resolutions. A data array of float type will be allocated where the size is defined by the dimExtents[].- Parameters:
dimExtents- Extents of the image; must be non null.voxRes- Resolutions of the image; must be non null.isColor- If true, indicates that this image is a color image (i.e. ARGB).
-
ModelSimpleImage
Creates a class to hold the minimum information about an image - the extents, the resolutions, and the image data. A data array of float type will be allocated where the size is defined by the dimExtents[]. Used for a 4D image to make a 3D ModelSimpleImage.- Parameters:
dimExtents- Extents of the image; must be non null.voxRes- Resolutions of the image; must be non null.image- Structure where image data is stored; can be null. If it is null, the buffer associated with this class will be empty. The ModelImage is not otherwise saved within this class.timeSlice- Time slice to export into the 3D data array.
-
-
Method Details
-
calcMinMax
public void calcMinMax()Calculates the min and max values for the image array. -
calculateCenterOfMass2D
public void calculateCenterOfMass2D(boolean voxelResol) Calculates the center of mass (gravity) of a 2D image using the intensity of each pixel as a weighting value.- Parameters:
voxelResol- if true multiply the center of mass by voxel resolutions.
-
calculateCenterOfMass3D
public void calculateCenterOfMass3D(boolean voxelResol) Calculates the center of mass (gravity) of a 3D image. In image space where the upper left hand corner of the image is 0,0,0. The x axis goes left to right, y axis goes top to bottom and z axis goes into the screen. (i.e. the right hand rule). The intensity of each voxel is used as a weighting value.- Parameters:
voxelResol- if true multiply the center of mass by voxel resolutions.
-
createIntensityImage
Create a new image with the same dimensions as this image which contains the intensity value from this image if it is a color image or which contains the same values if the image is already an intensity image. Scale factors are equally weighted for each of the RGB channels.- Returns:
- ModelSimpleImage New instance created with intensity values only.
-
createIntensityImage
Create a new image with the same dimensions as this image which contains the intensity value from this image if it is a color image or which contains the same values if the image is already an intensity image. Scale factors are specified for how to compute the intensity image as a linear combination of the RGB channels.- Parameters:
fScaleR- Scale factor to apply to the red color channel.fScaleG- Scale factor to apply to the green color channel.fScaleB- Scale factor to apply to the blue color channel.- Returns:
- ModelSimpleImage New instance created with intensity values only.
-
createMappedImage2d
public ModelSimpleImage createMappedImage2d(ModelSimpleImage kImageMapX, ModelSimpleImage kImageMapY) Create a mapping of this image. The mapping is defined by a set of floating point coordinates for each sample in the image. The coordinates are actually stored in separate images, one for each dimension. The number dimensions and the resolutions of these coordinate images must be the same so that either one can be used to determine the dimensions and resolutions of the new image where the mapped source image values will be stored using bilinear interpolation.- Parameters:
kImageMapX- ModelSimpleImage Image contains the x coordinate for the mapping. Each value in the image must be in the range [0,1].kImageMapY- ModelSimpleImage Image contains the y coordinate for the mapping. Each value in the image must be in the range [0,1].- Returns:
- ModelSimpleImage A new instance created with the mapping of this image.
-
createMappedImage3d
public ModelSimpleImage createMappedImage3d(ModelSimpleImage kImageMapX, ModelSimpleImage kImageMapY, ModelSimpleImage kImageMapZ) Create a mapping of this image. The mapping is defined by a set of floating point coordinates for each sample in the image. The coordinates are actually stored in separate images, one for each dimension. The number dimensions and the resolutions of these coordinate images must be the same so that either one can be used to determine the dimensions and resolutions of the new image where the mapped source image values will be stored using trilinear interpolation.- Parameters:
kImageMapX- ModelSimpleImage Image contains the x coordinate for the mapping. Each value in the image must be in the range [0,1].kImageMapY- ModelSimpleImage Image contains the y coordinate for the mapping. Each value in the image must be in the range [0,1].kImageMapZ- ModelSimpleImage Image contains the z coordinate for the mapping. Each value in the image must be in the range [0,1].- Returns:
- ModelSimpleImage A new instance created with the mapping of this image.
-
disposeLocal
public void disposeLocal(boolean gcFlag) Nulls the data fields so that memory can be recovered.- Parameters:
gcFlag- if true the garbage collector is called.
-
exportData
public void exportData(float[] buffer, int start, int end) Simple accessor to copy data from this class's data buffer.- Parameters:
buffer- destination bufferstart- the starting pointer where data is to be copy from the source bufferend- the ending pointer where in the source buffer
-
getValue
public final float getValue(int x, int y) Get the value at the x, y position of the data array.- Parameters:
x- input x pixel coordinatey- input y pixel coordinate- Returns:
- data value at the given position.
-
setValue
public final void setValue(int x, int y, float value) Set the value at the x, y position of the data array.- Parameters:
x- input x pixel coordinate.y- input y pixel coordinatevalue- data value.
-
getBiLinear
public final float getBiLinear(float x, float y) Version of get that performs bi-linear interpoloation. Note - does NOT perform bounds checking- Parameters:
x- input x coordinatey- input y coordinate- Returns:
- the bilinear interpolated value for x,y.
-
getTriLinear
public final float getTriLinear(float x, float y, float z) Version of get that performs tri-linear interpoloation. Note - does NOT perform bounds checking- Parameters:
x- x coordinatey- y coordinatez- z coordinate- Returns:
- the trilinear interpolated value for x,y,z.
-
subSample2dBy2
Takes a simple image and subsamples it by 2. Linear interpolation is used.- Returns:
- Subsampled image.
-
subSample2dBy2
Takes a simple image and subsamples it by 2. Linear interpolation is used.- Parameters:
isColor- If true, indicates that this image is a color image (i.e. ARGB).- Returns:
- Subsampled image.
-
subSample2dBy2
Takes a simple image and subsamples it by 2. Linear interpolation is used.- Parameters:
resultImage- The subsampled data will be stored in this object.- Returns:
- Subsampled image.
-
subSample2dBy2
Takes a simple image and subsamples it by 2. Linear interpolation is used.- Parameters:
resultImage- The subsampled data will be stored in this object.isColor- If true, indicates that this image is a color image (i.e. ARGB).- Returns:
- Subsampled image.
-
subsample3dBy2
Takes a simple image and subsamples it by 2. Linear interpolation is used.- Returns:
- Subsampled image.
-
subsample3dBy2
Takes a simple 3D image and subsamples it by 2. Linear interpolation is used.- Parameters:
isColor- If true, indicates that this image is a color image (i.e. ARGB).- Returns:
- Subsampled image.
-
subsample3dBy2XY
Takes a simple 3D image and subsamples each image plane (XY) by 2. Linear interpolation is used.- Returns:
- Subsampled image.
-
subsample3dBy2XY
Takes a simple 3D image and subsamples each image plane (XY) by 2. Linear interpolation is used.- Parameters:
isColor- If true, indicates that this image is a color image (i.e. ARGB).- Returns:
- Subsampled image.
-
subSample3dBy2XY
Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.- Parameters:
resultImage- The subsampled data will be stored in this object.- Returns:
- Subsampled image.
-
subSample3dBy2XY
Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.- Parameters:
resultImage- The subsampled data will be stored in this object.isColor- If true, indicates that this image is a color image (i.e. ARGB).- Returns:
- Subsampled image.
-
toString
Returns a readable representation of this simple image. -
finalize
Calls disposeLocal of this class to ensure this class nulls the references to global class variables so that memory will be recovered. -
Width
public int Width()Used by AAM appearance model to get dimension- Returns:
- x dimension
-
Height
public int Height()Used by AAM appearance model to get dimension- Returns:
- y dimension
-
Depth
public int Depth()Used by AAM appearance model to get dimension- Returns:
- z dimension
-
CB
public void CB(double y1, double y2, double d, double[] result) Binary interpolation call- Parameters:
y1-y2-d-result-
-
Pixel1
public double Pixel1(float x, float y) Used by AAM appearance model to get bilinear interpolation.- Returns:
- interpolation value.
-
SetName
Set the simple image name- Parameters:
_name-
-
getName
Get the simple image name- Returns:
-
FillPixels
public final void FillPixels(float value) In model simple image, fill pixel with given intensity value.- Parameters:
value-
-
importData
public void importData(float[] buffer, int start, int end) For AAM model only, import buffer to the simple image data.- Parameters:
buffer-start-end-
-
ReadBandedFile
Temporary function to handle AAM image file IO for AAM own testing cases. Lately this function will be removed.- Parameters:
szFilename-- Returns:
-
ReadFile
Temporary function to handle AAM image file IO for AAM own testing cases. Lately this function will be removed.- Parameters:
szFilename-- Returns:
-