Class LsePdeFilter3
java.lang.Object
gov.nih.mipav.model.algorithms.levelset.LsePdeFilter
gov.nih.mipav.model.algorithms.levelset.LsePdeFilter3
- Direct Known Subclasses:
LseCurvatureFlow3,LseEvolve3,LseGaussianBlur3,LseGradientAnisotropic3
The abstract base class for finite-difference-based solvers for partial differential equations in 3D. This system exists to support level-set evolution for image segmentation.
The internal 3D data and mask images are copies of the inputs to the constructor but padded with a 1-voxel thick border to support filtering on the image boundary. These images are of size (xbound+2)-by-(ybound+2)-by-(zbound+2). The inputs (x,y,z) to access the data and mask avlues are constrained to 0 invalid input: '<'= x invalid input: '<' xbound, 0 invalid input: '<'= y invalid input: '<' ybound, and 0 invalid input: '<'= z invalid input: '<' zbound. The correct lookups into the padded arrays are handled internally.
- Version:
- 0.1 November 7, 2006
- Author:
- David Eberly
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean[][][]Voxels may be masked out so that the PDE solver does not process them.protected float[][][]Successive iterations of the PDE solver toggle between two buffers.protected float[][][]Successive iterations of the PDE solver toggle between two buffers.protected floatinvFourthDxDy = 1/(4*dx*dy)protected floatinvFourthDxDz = 1/(4*dx*dz)protected floatinvFourthDyDz = 1/(4*dy*dz)protected floathalfInvDx = 1/(2*dx)protected floathalfInvDy = 1/(2*dy)protected floathalfInvDz = 1/(2*dz)protected floatinvDx = 1/dxprotected floatinvDxDx = 1/(dx*dx)protected floatinvDy = 1/dyprotected floatinvDyDy = 1/(dy*dy)protected floatinvDz = 1/dzprotected floatinvDzDz = 1/(dz*dz)protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatTemporary storage for 3x3x3 neighborhood.protected floatThe x-spacing of the image, call it dx.protected floatThe y-spacing of the image, call it dy.protected floatThe z-spacing of the image, call it dz.protected intThe x-bound of the image.protected intThe y-bound of the image.protected intThe z-bound of the image.Fields inherited from class gov.nih.mipav.model.algorithms.levelset.LsePdeFilter
m_eScaleType, m_fBorderValue, m_fMin, m_fOffset, m_fScale, m_fTimeStep, m_iQuantity, NONE, PRESERVE_ZERO, SYMMETRIC, UNIT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLsePdeFilter3(int iXBound, int iYBound, int iZBound, float fXSpacing, float fYSpacing, float fZSpacing, float[] afData, boolean[] abMask, float fBorderValue, int eScaleType) Create a new PDE filter object for 3D images. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAssign values to the 1-voxel-thick image border.protected voidAssign values to the 1-voxel-thick borders that surround unmasked regions.protected voidAssign values to the 1-voxel-thick image border.protected voidAssign values to the 1-voxel-thick borders that surround unmasked regions.final booleangetMask(int iX, int iY, int iZ) Get the mask value at voxel (x,y,z).final floatgetU(int iX, int iY, int iZ) Get the image value at voxel (x,y,z), call it u(x,y,z).final floatgetUx(int iX, int iY, int iZ) Get the first-order x-derivative of the image value at voxel (x,y,z), call it u_x(x,y,z).final floatgetUxx(int iX, int iY, int iZ) Get the second-order x-derivative of the image value at voxel (x,y,z), call it u_xx(x,y,z).final floatgetUxy(int iX, int iY, int iZ) Get the second-order xy-mixed-derivative of the image value at voxel (x,y,z), call it u_xy(x,y,z).final floatgetUxz(int iX, int iY, int iZ) Get the second-order xz-mixed-derivative of the image value at voxel (x,y,z), call it u_xz(x,y,z).final floatgetUy(int iX, int iY, int iZ) Get the first-order y-derivative of the image value at voxel (x,y,z), call it u_y(x,y,z).final floatgetUyy(int iX, int iY, int iZ) Get the second-order y-derivative of the image value at voxel (x,y,z), call it u_yy(x,y,z).final floatgetUyz(int iX, int iY, int iZ) Get the second-order yz-mixed-derivative of the image value at voxel (x,y,z), call it u_yz(x,y,z).final floatgetUz(int iX, int iY, int iZ) Get the first-order z-derivative of the image value at voxel (x,y,z), call it u_z(x,y,z).final floatgetUzz(int iX, int iY, int iZ) Get the second-order z-derivative of the image value at voxel (x,y,z), call it u_zz(x,y,z).final intGet the x-bound for the image.final floatGet the x-spacing for the image.final intGet the y-bound for the image.final floatGet the y-spacing for the image.final intGet the z-bound for the image.final floatGet the z-spacing for the image.protected voidlookUp27(int iX, int iY, int iZ) Copy the source data to temporary storage in order to avoid redundant array accesses.protected voidlookUp7(int iX, int iY, int iZ) Copy the source data to temporary storage in order to avoid redundant array accesses.protected voidSwap the buffers for the next pass of the PDE solver.protected voidRecompute the boundary values when Neumann conditions are in effect.protected voidonUpdate()Iterate over all the voxels and call onUpdate(x,y,z) for each voxel that is not masked out.protected abstract voidonUpdate(int iX, int iY, int iZ) An abstract function that allows per-voxel processing by the PDE solver.Methods inherited from class gov.nih.mipav.model.algorithms.levelset.LsePdeFilter
getBorderValue, getQuantity, getScaleType, getTimeStep, setTimeStep, update
-
Field Details
-
m_iXBound
protected int m_iXBoundThe x-bound of the image. -
m_iYBound
protected int m_iYBoundThe y-bound of the image. -
m_iZBound
protected int m_iZBoundThe z-bound of the image. -
m_fXSpacing
protected float m_fXSpacingThe x-spacing of the image, call it dx. -
m_fYSpacing
protected float m_fYSpacingThe y-spacing of the image, call it dy. -
m_fZSpacing
protected float m_fZSpacingThe z-spacing of the image, call it dz. -
m_fInvDx
protected float m_fInvDxinvDx = 1/dx -
m_fInvDy
protected float m_fInvDyinvDy = 1/dy -
m_fInvDz
protected float m_fInvDzinvDz = 1/dz -
m_fHalfInvDx
protected float m_fHalfInvDxhalfInvDx = 1/(2*dx) -
m_fHalfInvDy
protected float m_fHalfInvDyhalfInvDy = 1/(2*dy) -
m_fHalfInvDz
protected float m_fHalfInvDzhalfInvDz = 1/(2*dz) -
m_fInvDxDx
protected float m_fInvDxDxinvDxDx = 1/(dx*dx) -
m_fFourthInvDxDy
protected float m_fFourthInvDxDyinvFourthDxDy = 1/(4*dx*dy) -
m_fFourthInvDxDz
protected float m_fFourthInvDxDzinvFourthDxDz = 1/(4*dx*dz) -
m_fInvDyDy
protected float m_fInvDyDyinvDyDy = 1/(dy*dy) -
m_fFourthInvDyDz
protected float m_fFourthInvDyDzinvFourthDyDz = 1/(4*dy*dz) -
m_fInvDzDz
protected float m_fInvDzDzinvDzDz = 1/(dz*dz) -
m_fUmmm
protected float m_fUmmmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzmm
protected float m_fUzmmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpmm
protected float m_fUpmmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmzm
protected float m_fUmzmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzzm
protected float m_fUzzmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpzm
protected float m_fUpzmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmpm
protected float m_fUmpmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzpm
protected float m_fUzpmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUppm
protected float m_fUppmTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmmz
protected float m_fUmmzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzmz
protected float m_fUzmzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpmz
protected float m_fUpmzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmzz
protected float m_fUmzzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzzz
protected float m_fUzzzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpzz
protected float m_fUpzzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmpz
protected float m_fUmpzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzpz
protected float m_fUzpzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUppz
protected float m_fUppzTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmmp
protected float m_fUmmpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzmp
protected float m_fUzmpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpmp
protected float m_fUpmpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmzp
protected float m_fUmzpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzzp
protected float m_fUzzpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUpzp
protected float m_fUpzpTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUmpp
protected float m_fUmppTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUzpp
protected float m_fUzppTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_fUppp
protected float m_fUpppTemporary storage for 3x3x3 neighborhood. In the notation m_fUijk, the i, j, and k indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index. -
m_aaafSrc
protected float[][][] m_aaafSrcSuccessive iterations of the PDE solver toggle between two buffers. This is the source buffer, which is the input to the solver. -
m_aaafDst
protected float[][][] m_aaafDstSuccessive iterations of the PDE solver toggle between two buffers. This is the destination buffer, which is the output of the solver. -
m_aaabMask
protected boolean[][][] m_aaabMaskVoxels may be masked out so that the PDE solver does not process them. This is useful for filtering only those voxels in a subimage.
-
-
Constructor Details
-
LsePdeFilter3
protected LsePdeFilter3(int iXBound, int iYBound, int iZBound, float fXSpacing, float fYSpacing, float fZSpacing, float[] afData, boolean[] abMask, float fBorderValue, int eScaleType) Create a new PDE filter object for 3D images.- Parameters:
iXBound- The x-bound of the image.iYBound- The y-bound of the image.iZBound- The z-bound of the image.fXSpacing- The x-spacing of the image.fYSpacing- The y-spacing of the image.fZSpacing- The z-spacing of the image.afData- The image elements, stored in lexicographical order.abMask- The image mask, stored in lexicographical order. A voxel value is processed by the PDE solver only when the mask value is false.fBorderValue- Specifies how to handle the image value. When set to Float.MAX_VALUE, Neumann conditions are in use, in which case zero-valued derivatives are assumed on the image border. Otherwise, Dirichlet conditions are used, in which case the image is assumed to be constant on the border with value specified by fBorderValue.eScaleType- The type of scaling to apply to the input image. The choices are NONE, UNIT, SYMMETRIC, or PRESERVE_ZERO.
-
-
Method Details
-
getXBound
public final int getXBound()Get the x-bound for the image.- Returns:
- The x-bound for the image.
-
getYBound
public final int getYBound()Get the y-bound for the image.- Returns:
- The y-bound for the image.
-
getZBound
public final int getZBound()Get the z-bound for the image.- Returns:
- The z-bound for the image.
-
getXSpacing
public final float getXSpacing()Get the x-spacing for the image.- Returns:
- The x-spacing for the image.
-
getYSpacing
public final float getYSpacing()Get the y-spacing for the image.- Returns:
- The y-spacing for the image.
-
getZSpacing
public final float getZSpacing()Get the z-spacing for the image.- Returns:
- The z-spacing for the image.
-
getU
public final float getU(int iX, int iY, int iZ) Get the image value at voxel (x,y,z), call it u(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The image value, u(x,y,z).
-
getUx
public final float getUx(int iX, int iY, int iZ) Get the first-order x-derivative of the image value at voxel (x,y,z), call it u_x(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The x-derivative of the image value, u_x(x,y,z).
-
getUy
public final float getUy(int iX, int iY, int iZ) Get the first-order y-derivative of the image value at voxel (x,y,z), call it u_y(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The y-derivative of the image value, u_y(x,y,z).
-
getUz
public final float getUz(int iX, int iY, int iZ) Get the first-order z-derivative of the image value at voxel (x,y,z), call it u_z(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The z-derivative of the image value, u_z(x,y,z).
-
getUxx
public final float getUxx(int iX, int iY, int iZ) Get the second-order x-derivative of the image value at voxel (x,y,z), call it u_xx(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The xx-derivative of the image value, u_xx(x,y).
-
getUxy
public final float getUxy(int iX, int iY, int iZ) Get the second-order xy-mixed-derivative of the image value at voxel (x,y,z), call it u_xy(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The xy-derivative of the image value, u_xy(x,y,z).
-
getUxz
public final float getUxz(int iX, int iY, int iZ) Get the second-order xz-mixed-derivative of the image value at voxel (x,y,z), call it u_xz(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The xz-derivative of the image value, u_xz(x,y,z).
-
getUyy
public final float getUyy(int iX, int iY, int iZ) Get the second-order y-derivative of the image value at voxel (x,y,z), call it u_yy(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The yy-derivative of the image value, u_yy(x,y).
-
getUyz
public final float getUyz(int iX, int iY, int iZ) Get the second-order yz-mixed-derivative of the image value at voxel (x,y,z), call it u_yz(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The yz-derivative of the image value, u_yz(x,y,z).
-
getUzz
public final float getUzz(int iX, int iY, int iZ) Get the second-order z-derivative of the image value at voxel (x,y,z), call it u_zz(x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The zz-derivative of the image value, u_zz(x,y).
-
getMask
public final boolean getMask(int iX, int iY, int iZ) Get the mask value at voxel (x,y,z).- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.- Returns:
- The mask value at voxel (x,y,z). Its value is true when that pixel should not be processed by the PDE solver.
-
assignDirichletImageBorder
protected void assignDirichletImageBorder()Assign values to the 1-voxel-thick image border. The border value has been specified during object construction. -
assignNeumannImageBorder
protected void assignNeumannImageBorder()Assign values to the 1-voxel-thick image border. The border values are chosen so that the first-order image derivatives at the border pixels are zero. Thus, the border values are duplicates of the adjacent image values. -
assignDirichletMaskBorder
protected void assignDirichletMaskBorder()Assign values to the 1-voxel-thick borders that surround unmasked regions. The border value has been specified during object construction. -
assignNeumannMaskBorder
protected void assignNeumannMaskBorder()Assign values to the 1-voxel-thick borders that surround unmasked regions. The border values are chosen so that the first-order image derivatives at the border voxels are zero. Thus, the border values are duplicates of the adjacent image values. -
onPreUpdate
protected void onPreUpdate()Recompute the boundary values when Neumann conditions are in effect. If a derived class overrides this, it must call the base-class onPreUpdate first.- Specified by:
onPreUpdatein classLsePdeFilter
-
onUpdate
protected void onUpdate()Iterate over all the voxels and call onUpdate(x,y,z) for each voxel that is not masked out.- Specified by:
onUpdatein classLsePdeFilter
-
onPostUpdate
protected void onPostUpdate()Swap the buffers for the next pass of the PDE solver. If a derived class overrides this, it must call the base-class onPostUpdate last.- Specified by:
onPostUpdatein classLsePdeFilter
-
onUpdate
protected abstract void onUpdate(int iX, int iY, int iZ) An abstract function that allows per-voxel processing by the PDE solver. The voxel (x,y,z) must be in padded coordinates, namely, 1 invalid input: '<'= x invalid input: '<'= xbound, 1 invalid input: '<'= y invalid input: '<'= ybound, and 1 invalid input: '<'= z invalid input: '<'= zbound.- Parameters:
iX- The x-coordinate of the voxel.iY- The y-coordinate of the voxel.iZ- The z-coordinate of the voxel.
-
lookUp7
protected void lookUp7(int iX, int iY, int iZ) Copy the source data to temporary storage in order to avoid redundant array accesses. The copy involves the 7 voxels (x,y,z), (x+1,y,z), (x-1,y,z), (x,y+1,z), (x,y-1,z), (x,y,z+1), and (x,y,z-1). -
lookUp27
protected void lookUp27(int iX, int iY, int iZ) Copy the source data to temporary storage in order to avoid redundant array accesses. The copy involves the 27 pixels in the 3x3x3 neighborhood of (x,y,z).
-