Class AlgorithmSubsample
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.utilities.AlgorithmSubsample
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
Takes in an image and subsamples it to a new set of dimensions. The subsample image is a Gaussian weighted average of
neighboring pixels (voxels) of the original image. For 4D images only the first 3 dimensions are subsampled
- Author:
- Evan McCreedy
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ModelImagePadded image.private double[]Ratios used to translate points in the result image to points in the source image.private booleanDOCUMENT ME!private int[]Extents the resultImage should have.private ModelImageResult image.private float[]Std deviation of the Gaussian function.private ModelImageImage to subsample from.private booleanDOCUMENT ME!private TransMatrixDOCUMENT ME!private booleanWhether to perform trilinear filtering when getting intensities of points on the source image.Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmSubsample(ModelImage src, ModelImage result, int[] newExtents, int[] padExtents, float[] _sigmas, boolean indep, boolean transformVOI, TransMatrix transMatrix, boolean doPad) Setup for a later subsampling of an image. -
Method Summary
Modifier and TypeMethodDescriptionprivate doublecomputeGaussian2D(double locX, double locY, double sigmaX, double sigmaY) Compute the value of the 2D gaussian at a point.private doublecomputeGaussian3D(double locX, double locY, double locZ, double sigmaX, double sigmaY, double sigmaZ) Computes the gaussian weights for a particular point.private voidComputes the image scaling ratios.voidfinalize()Prepares this class for destruction.private float[]getNearestNeighborPos2D(float x, float y) Translates a point from the result image to the source image.private float[]getNearestNeighborPos3D(float x, float y, float z) Translates a point from the result image to the source image.Return the result image (or null if not created yet).private floatgetTriLinearVal3D(float x, float y, float z, int t, int channelIndex, ModelSimpleImage src) Version of get that performs tri-linear interpoloation.private floatgetTriLinearVal3D(float x, float y, float z, int channelIndex, ModelSimpleImage src) Version of get that performs tri-linear interpoloation.private floatgetValue2D(float x, float y, float z, int channelIndex, ModelSimpleImage src) Get the value of a 2D point.private floatgetValue3D(float x, float y, float z, int t, int channelIndex, ModelSimpleImage src) Get the value of a 4D point.private floatgetValue3D(float x, float y, float z, int channelIndex, ModelSimpleImage src) Get the value of a 3D point.private static StringmakeImageName(String image_name, String ext) Helper method for making the result image's name.private ModelImagepadImage(ModelImage kImage, int[] padExtents) voidSubsample the image.private ModelSimpleImagesubsample2D(int nImages) Subsample a 2D image.private ModelSimpleImagePerform the subsampling.private ModelSimpleImagePerform the subsampling.private voidtransform25DVOI(ModelImage image, float[] imgBuffer, TransMatrix xfrm) Transforms and resamples a 2D or 25D VOI using nearest neighbor interpolation.private voidtransform3DVOI(ModelImage image, float[] imgBuffer, TransMatrix xfrm) Transforms and resamples a 3D VOI using nearest neighbor interpolation.Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpenedMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
posRatios
private double[] posRatiosRatios used to translate points in the result image to points in the source image. -
processIndep
private boolean processIndepDOCUMENT ME! -
resultExtents
private int[] resultExtentsExtents the resultImage should have. -
resultImage
Result image. -
paddedImage
Padded image. -
sigmas
private float[] sigmasStd deviation of the Gaussian function. -
srcImage
Image to subsample from. -
transformVOI
private boolean transformVOIDOCUMENT ME! -
transMatrix
DOCUMENT ME! -
trilinearFlag
private boolean trilinearFlagWhether to perform trilinear filtering when getting intensities of points on the source image.
-
-
Constructor Details
-
AlgorithmSubsample
public AlgorithmSubsample(ModelImage src, ModelImage result, int[] newExtents, int[] padExtents, float[] _sigmas, boolean indep, boolean transformVOI, TransMatrix transMatrix, boolean doPad) Setup for a later subsampling of an image.- Parameters:
src- image to be subsampledresult- image created by subsamplingnewExtents- dimensions of the result image to be sampled into_sigmas- x, y, and z scales for the gaussian functionindep- process slices independently (cannot change the z dimension)transformVOI- if true transform the VOIstransMatrix- transformation matrix
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
getResultImage
Return the result image (or null if not created yet).- Returns:
- the subsampled image
-
runAlgorithm
public void runAlgorithm()Subsample the image.- Specified by:
runAlgorithmin classAlgorithmBase
-
computeGaussian2D
private double computeGaussian2D(double locX, double locY, double sigmaX, double sigmaY) Compute the value of the 2D gaussian at a point.- Parameters:
locX- x location of the value to computelocY- y location of the value to computesigmaX- standard deviation of the guassian in the x dimensionsigmaY- standard deviation of the guassian in the y dimension- Returns:
- the value of the 2D gaussian at the given point
-
computeGaussian3D
private double computeGaussian3D(double locX, double locY, double locZ, double sigmaX, double sigmaY, double sigmaZ) Computes the gaussian weights for a particular point. Written by Paul Hemler in AlgorithmVesselSegmenation.- Parameters:
locX- distance to go in the x dir from the pointlocY- distance to go in the y dir from the pointlocZ- distance to go in the z dir from the pointsigmaX- stddev of the gaussian function in the x dirsigmaY- stddev of the gaussian function in the y dirsigmaZ- stddev of the gaussian function in the z dir- Returns:
- the gaussian weight coeff.
-
computeRatios
private void computeRatios()Computes the image scaling ratios. -
getNearestNeighborPos2D
private float[] getNearestNeighborPos2D(float x, float y) Translates a point from the result image to the source image.- Parameters:
x- x coordinate of point to be translatedy- y coordinate of point to be translated- Returns:
- the translated point on the source image
-
getNearestNeighborPos3D
private float[] getNearestNeighborPos3D(float x, float y, float z) Translates a point from the result image to the source image.- Parameters:
x- x coordinate of point to be translatedy- y coordinate of point to be translatedz- z coordinate of point to be translated- Returns:
- the translated point on the source image
-
getTriLinearVal3D
Version of get that performs tri-linear interpoloation. Note: does NOT perform bounds checking.- Parameters:
x- x coordinatey- y coordinatez- z coordinatechannelIndex- color channelsrc- image to get intensity value from- Returns:
- the tri-linear interpolated value
-
getTriLinearVal3D
private float getTriLinearVal3D(float x, float y, float z, int t, int channelIndex, ModelSimpleImage src) Version of get that performs tri-linear interpoloation. Note: does NOT perform bounds checking.- Parameters:
x- x coordinatey- y coordinatez- z coordinatet- t coordinatechannelIndex- color channelsrc- image to get intensity value from- Returns:
- the tri-linear interpolated value
-
getValue2D
Get the value of a 2D point.- Parameters:
x- x coordinatey- y coordinatez- z coordinate (0 if really 2D)channelIndex- color channelsrc- image to sample from- Returns:
- the point's value
-
getValue3D
Get the value of a 3D point.- Parameters:
x- x coordinatey- y coordinatez- z coordinatechannelIndex- color channelsrc- image to sample from- Returns:
- the point's value
-
getValue3D
Get the value of a 4D point.- Parameters:
x- x coordinatey- y coordinatez- z coordinatet- DOCUMENT ME!channelIndex- color channelsrc- image to sample from- Returns:
- the point's value
-
subsample2D
Subsample a 2D image.- Parameters:
nImages- the number of 2D images to subsample (1 if really 2D)- Returns:
- the subsampled image
-
subsample3D
Perform the subsampling. Create a result image with the extents given into the constuctor. Then, for each point in the result image, find point which corresponds to it in the source image. Add up weighted intensities of the neighbors of this point in the source image and the intensity of the point itself. Store this value in the point of the result image. Once all points in the result image have been visted, return the result image.- Returns:
- resampled image
-
subsample4D
Perform the subsampling. Create a result image with the extents given into the constuctor. Then, for each point in the result image, find point which corresponds to it in the source image. Add up weighted intensities of the neighbors of this point in the source image and the intensity of the point itself. Store this value in the point of the result image. Once all points in the result image have been visted, return the result image. Does not subsample in fourth time dimension - 3.5D operation- Returns:
- resampled image
-
transform25DVOI
Transforms and resamples a 2D or 25D VOI using nearest neighbor interpolation.- Export VOIs as a mask image
- Transform mask
- Extract VOI contours from mask image and put in new image.
- Parameters:
image- Image where VOIs are storedimgBuffer- Image arrayxfrm- Transformation matrix to be applied
-
transform3DVOI
Transforms and resamples a 3D VOI using nearest neighbor interpolation.- Export VOIs as a mask image
- Transform mask
- Extract VOI contours from mask image and put in new image.
- Parameters:
image- Image where VOIs are storedimgBuffer- Image arrayxfrm- Transformation matrix to be applied
-
padImage
-
makeImageName
Helper method for making the result image's name. Strips the current extension from the original name, adds the given extension, and returns the new name.- Parameters:
image_name- the original image's nameext- Extension to add which gives information about what algorithm was performed on the image.- Returns:
- The new image name.
-