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
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 invalid input: '<'= x invalid input: '<' xbound and 0 invalid input: '<'= y invalid input: '<' ybound. 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[][]Pixels 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 floathalfInvDx = 1/(2*dx)protected floathalfInvDy = 1/(2*dy)protected floatinvDx = 1/dxprotected floatinvDxDx = 1/(dx*dx)protected floatinvDy = 1/dyprotected floatinvDyDy = 1/(dy*dy)protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatTemporary storage for 3x3 neighborhood.protected floatThe x-spacing of the image, call it dx.protected floatThe y-spacing of the image, call it dy.protected intThe x-bound of the image.protected intThe 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
ConstructorsModifierConstructorDescriptionprotectedLsePdeFilter2(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
Modifier and TypeMethodDescriptionprotected voidAssign values to the 1-pixel-thick image border.protected voidAssign values to the 1-pixel-thick borders that surround unmasked regions.protected voidAssign values to the 1-pixel-thick image border.protected voidAssign values to the 1-pixel-thick borders that surround unmasked regions.final booleangetMask(int iX, int iY) Get the mask value at pixel (x,y).final floatgetU(int iX, int iY) Get the image value at pixel (x,y), call it u(x,y).final 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).final 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).final 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).final 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).final 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).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.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 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 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 Details
-
m_iXBound
protected int m_iXBoundThe x-bound of the image. -
m_iYBound
protected int m_iYBoundThe y-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_fInvDx
protected float m_fInvDxinvDx = 1/dx -
m_fInvDy
protected float m_fInvDyinvDy = 1/dy -
m_fHalfInvDx
protected float m_fHalfInvDxhalfInvDx = 1/(2*dx) -
m_fHalfInvDy
protected float m_fHalfInvDyhalfInvDy = 1/(2*dy) -
m_fInvDxDx
protected float m_fInvDxDxinvDxDx = 1/(dx*dx) -
m_fFourthInvDxDy
protected float m_fFourthInvDxDyinvFourthDxDy = 1/(4*dx*dy) -
m_fInvDyDy
protected float m_fInvDyDyinvDyDy = 1/(dy*dy) -
m_fUmm
protected float m_fUmmTemporary 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_fUzmTemporary 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_fUpmTemporary 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_fUmzTemporary 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_fUzzTemporary 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_fUpzTemporary 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_fUmpTemporary 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_fUzpTemporary 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_fUppTemporary 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_aafSrcSuccessive 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_aafDstSuccessive 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_aabMaskPixels 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 Details
-
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 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.
-
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 invalid input: '<'= x invalid input: '<'= xbound and 1 invalid input: '<'= y invalid input: '<'= 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).
-