Class LsePdeFilter2
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.levelset.LsePdeFilter
-
- gov.nih.mipav.model.algorithms.levelset.LsePdeFilter2
-
- Direct Known Subclasses:
LseCurvatureFlow2,LseEvolve2,LseGaussianBlur2,LseGradientAnisotropic2
public abstract class LsePdeFilter2 extends LsePdeFilter
The abstract base class for finite-difference-based solvers for partial differential equations in 2D. This system exists to support level-set evolution for image segmentation.
The internal 2D data and mask images are copies of the inputs to the constructor but padded with a 1-pixel thick border to support filtering on the image boundary. These images are of size (xbound+2)-by-(ybound+2). The inputs (x,y) to access the data and mask avlues are constrained to 0 <= x < xbound and 0 <= y < ybound. The correct lookups into the padded arrays are handled internally.
- Version:
- 0.1 November 7, 2006
- Author:
- David Eberly
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean[][]m_aabMaskPixels may be masked out so that the PDE solver does not process them.protected float[][]m_aafDstSuccessive iterations of the PDE solver toggle between two buffers.protected float[][]m_aafSrcSuccessive iterations of the PDE solver toggle between two buffers.protected floatm_fFourthInvDxDyinvFourthDxDy = 1/(4*dx*dy)protected floatm_fHalfInvDxhalfInvDx = 1/(2*dx)protected floatm_fHalfInvDyhalfInvDy = 1/(2*dy)protected floatm_fInvDxinvDx = 1/dxprotected floatm_fInvDxDxinvDxDx = 1/(dx*dx)protected floatm_fInvDyinvDy = 1/dyprotected floatm_fInvDyDyinvDyDy = 1/(dy*dy)protected floatm_fUmmTemporary storage for 3x3 neighborhood.protected floatm_fUmpTemporary storage for 3x3 neighborhood.protected floatm_fUmzTemporary storage for 3x3 neighborhood.protected floatm_fUpmTemporary storage for 3x3 neighborhood.protected floatm_fUppTemporary storage for 3x3 neighborhood.protected floatm_fUpzTemporary storage for 3x3 neighborhood.protected floatm_fUzmTemporary storage for 3x3 neighborhood.protected floatm_fUzpTemporary storage for 3x3 neighborhood.protected floatm_fUzzTemporary storage for 3x3 neighborhood.protected floatm_fXSpacingThe x-spacing of the image, call it dx.protected floatm_fYSpacingThe y-spacing of the image, call it dy.protected intm_iXBoundThe x-bound of the image.protected intm_iYBoundThe y-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
Constructors Modifier Constructor Description protectedLsePdeFilter2(int iXBound, int iYBound, float fXSpacing, float fYSpacing, float[] afData, boolean[] abMask, float fBorderValue, int eScaleType)Create a new PDE filter object for 2D images.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassignDirichletImageBorder()Assign values to the 1-pixel-thick image border.protected voidassignDirichletMaskBorder()Assign values to the 1-pixel-thick borders that surround unmasked regions.protected voidassignNeumannImageBorder()Assign values to the 1-pixel-thick image border.protected voidassignNeumannMaskBorder()Assign values to the 1-pixel-thick borders that surround unmasked regions.booleangetMask(int iX, int iY)Get the mask value at pixel (x,y).floatgetU(int iX, int iY)Get the image value at pixel (x,y), call it u(x,y).floatgetUx(int iX, int iY)Get the first-order x-derivative of the image value at pixel (x,y), call it u_x(x,y).floatgetUxx(int iX, int iY)Get the second-order x-derivative of the image value at pixel (x,y), call it u_xx(x,y).floatgetUxy(int iX, int iY)Get the second-order mixed-derivative of the image value at pixel (x,y), call it u_xy(x,y).floatgetUy(int iX, int iY)Get the first-order y-derivative of the image value at pixel (x,y), call it u_y(x,y).floatgetUyy(int iX, int iY)Get the second-order y-derivative of the image value at pixel (x,y), call it u_yy(x,y).intgetXBound()Get the x-bound for the image.floatgetXSpacing()Get the x-spacing for the image.intgetYBound()Get the y-bound for the image.floatgetYSpacing()Get the y-spacing for the image.protected voidlookUp5(int iX, int iY)Copy the source data to temporary storage in order to avoid redundant array accesses.protected voidlookUp9(int iX, int iY)Copy the source data to temporary storage in order to avoid redundant array accesses.protected voidonPostUpdate()Swap the buffers for the next pass of the PDE solver.protected voidonPreUpdate()Recompute the boundary values when Neumann conditions are in effect.protected voidonUpdate()Iterate over all the pixels and call onUpdate(x,y) for each pixel that is not masked out.protected abstract voidonUpdate(int iX, int iY)An abstract function that allows per-pixel processing by the PDE solver.-
Methods inherited from class gov.nih.mipav.model.algorithms.levelset.LsePdeFilter
getBorderValue, getQuantity, getScaleType, getTimeStep, setTimeStep, update
-
-
-
-
Field Detail
-
m_iXBound
protected int m_iXBound
The x-bound of the image.
-
m_iYBound
protected int m_iYBound
The y-bound of the image.
-
m_fXSpacing
protected float m_fXSpacing
The x-spacing of the image, call it dx.
-
m_fYSpacing
protected float m_fYSpacing
The y-spacing of the image, call it dy.
-
m_fInvDx
protected float m_fInvDx
invDx = 1/dx
-
m_fInvDy
protected float m_fInvDy
invDy = 1/dy
-
m_fHalfInvDx
protected float m_fHalfInvDx
halfInvDx = 1/(2*dx)
-
m_fHalfInvDy
protected float m_fHalfInvDy
halfInvDy = 1/(2*dy)
-
m_fInvDxDx
protected float m_fInvDxDx
invDxDx = 1/(dx*dx)
-
m_fFourthInvDxDy
protected float m_fFourthInvDxDy
invFourthDxDy = 1/(4*dx*dy)
-
m_fInvDyDy
protected float m_fInvDyDy
invDyDy = 1/(dy*dy)
-
m_fUmm
protected float m_fUmm
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUzm
protected float m_fUzm
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUpm
protected float m_fUpm
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUmz
protected float m_fUmz
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUzz
protected float m_fUzz
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUpz
protected float m_fUpz
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUmp
protected float m_fUmp
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUzp
protected float m_fUzp
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_fUpp
protected float m_fUpp
Temporary storage for 3x3 neighborhood. In the notation m_fUij, the i and j indices are in {m,z,p}, referring to subtract 1 (m), no change (z), or add 1 (p) to the appropriate index.
-
m_aafSrc
protected float[][] m_aafSrc
Successive iterations of the PDE solver toggle between two buffers. This is the source buffer, which is the input to the solver.
-
m_aafDst
protected float[][] m_aafDst
Successive iterations of the PDE solver toggle between two buffers. This is the destination buffer, which is the output of the solver.
-
m_aabMask
protected boolean[][] m_aabMask
Pixels may be masked out so that the PDE solver does not process them. This is useful for filtering only those pixels in a subimage.
-
-
Constructor Detail
-
LsePdeFilter2
protected LsePdeFilter2(int iXBound, int iYBound, float fXSpacing, float fYSpacing, float[] afData, boolean[] abMask, float fBorderValue, int eScaleType)Create a new PDE filter object for 2D images.- Parameters:
iXBound- The x-bound of the image.iYBound- The y-bound of the image.fXSpacing- The x-spacing of the image.fYSpacing- The y-spacing of the image.afData- The image elements, stored in lexicographical order.abMask- The image mask, stored in lexicographical order. A pixel 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 Detail
-
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.
-
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.
-
getU
public final float getU(int iX, int iY)Get the image value at pixel (x,y), call it u(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The image value, u(x,y).
-
getUx
public final float getUx(int iX, int iY)Get the first-order x-derivative of the image value at pixel (x,y), call it u_x(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The x-derivative of the image value, u_x(x,y).
-
getUy
public final float getUy(int iX, int iY)Get the first-order y-derivative of the image value at pixel (x,y), call it u_y(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The y-derivative of the image value, u_y(x,y).
-
getUxx
public final float getUxx(int iX, int iY)Get the second-order x-derivative of the image value at pixel (x,y), call it u_xx(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The xx-derivative of the image value, u_xx(x,y).
-
getUxy
public final float getUxy(int iX, int iY)Get the second-order mixed-derivative of the image value at pixel (x,y), call it u_xy(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The xy-derivative of the image value, u_xy(x,y).
-
getUyy
public final float getUyy(int iX, int iY)Get the second-order y-derivative of the image value at pixel (x,y), call it u_yy(x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The yy-derivative of the image value, u_xx(x,y).
-
getMask
public final boolean getMask(int iX, int iY)Get the mask value at pixel (x,y).- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.- Returns:
- The mask value at pixel (x,y). Its value is true when that pixel should not be processed by the PDE solver.
-
assignDirichletImageBorder
protected void assignDirichletImageBorder()
Assign values to the 1-pixel-thick image border. The border value has been specified during object construction.
-
assignNeumannImageBorder
protected void assignNeumannImageBorder()
Assign values to the 1-pixel-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-pixel-thick borders that surround unmasked regions. The border value has been specified during object construction.
-
assignNeumannMaskBorder
protected void assignNeumannMaskBorder()
Assign values to the 1-pixel-thick borders that surround unmasked regions. 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.
-
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 pixels and call onUpdate(x,y) for each pixel 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)An abstract function that allows per-pixel processing by the PDE solver. The pixel (x,y) must be in padded coordinates, namely, 1 <= x <= xbound and 1 <= y <= ybound.- Parameters:
iX- The x-coordinate of the pixel.iY- The y-coordinate of the pixel.
-
lookUp5
protected void lookUp5(int iX, int iY)Copy the source data to temporary storage in order to avoid redundant array accesses. The copy involves the 5 pixels (x,y), (x+1,y), (x-1,y), (x,y+1), and (x,y-1).
-
lookUp9
protected void lookUp9(int iX, int iY)Copy the source data to temporary storage in order to avoid redundant array accesses. The copy involves the 9 pixels in the 3x3 neighborhood of (x,y).
-
-