de.unihalle.informatik.MiToBo.segmentation.levelset.nonPDE
Class MTBLevelsetMembership

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.segmentation.levelset.nonPDE.MTBLevelsetMembership

@ALDParametrizedClass
public class MTBLevelsetMembership
extends de.unihalle.informatik.Alida.operator.ALDData

A class to hold a level set function where only the memership to a phase is required and represented. Background pixels gets phase BG_PHASE, object phases start with BG_PHASE+1. The implementation asserts that all phases > BG_PHASE are indeed object phases. Value INVALID_PHASE is reserved for invalid pixels.


Field Summary
static byte BG_PHASE
          Level set function value to represent the background phase
static byte INVALID_PHASE
          Level set function value to represent invalid pixels
static int MAX_ALLOWED_NUM_PHASES
          Maximal number of phases which may be represented including background phase.
private  int numPhases
           
private  byte[][][] phi
           
private  int[] sizePhases
           
private  int sizeX
           
private  int sizeY
           
private  int sizeZ
           
private  int sumSizeObject
           
 
Constructor Summary
MTBLevelsetMembership(int sizeX, int sizeY, int sizeZ)
          Constructs a two phase level set function which is initialiazed with a circle or sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.
MTBLevelsetMembership(int sizeX, int sizeY, int sizeZ, MTBImage invalidImg)
          Constructs a two phase level set function which is initialiazed with a circle or sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.
MTBLevelsetMembership(int sizeX, int sizeY, int sizeZ, MTBImage img, int threshold, MTBImage invalidImg)
          Creates a two phase level set function from an image via thresholding.
MTBLevelsetMembership(int sizeX, int sizeY, MTBRegion2DSet regions, MTBImage invalidImg, boolean multiphase)
          Constructor for given size which is initialized from a MTBRegion2DSet for a 2D level set function.
MTBLevelsetMembership(int sizeX, int sizeY, java.util.Vector<MTBRegion2D> regions, MTBImage invalidImg, boolean multiphase)
          Constructor for given size which is initialized from a list of 2D regions for a 2D level set function.
MTBLevelsetMembership(MTBImage initLabelImg, MTBImage invalidImg)
          Constructor for a two phase level set function from a label image.
MTBLevelsetMembership(MTBImage initLabelImg, MTBImage invalidImg, boolean multiphase)
          Constructor for a level set function from a label image.
MTBLevelsetMembership(MTBLevelsetMembership phi)
          Creates a copy of phi.
 
Method Summary
 void changePhase(int x, int y, byte phase)
          Change a pixel to a new phase.
 void changePhase(int x, int y, int z, byte phase)
          Change a pixel/voxel to a new phase.
 MTBImageByte getMTBImage()
          Creates a bi-level MTBImageByte of the level set function.
 MTBImageByte getMTBImageLabel()
          Creates a MTBImageByte of the level set function.
 int getNumPhases()
          Return .e. number phases.
 byte getPhase(int x, int y)
          Return phase for a pixel/voxel, z coordinate defaults to zero
 byte getPhase(int x, int y, int z)
          Return phase for a pixel/voxel
 byte getPhaseCheckXY(int x, int y)
          Return phase for a pixel checking limits of all coordinates.
 byte getPhaseCheckXYZ(int x, int y, int z)
          Return phase for a pixel/voxel checking limits of all coordinates.
 int getPixelInside()
          Return number of pixels of all object phases.
 int getPixelOutside()
          Return number of pixels of background phase.
 int getSizePhase(byte phase)
          Return the size, i.e. number of pixel/voxels of a phase.
 int getSizeX()
          Return X size of the level set function.
 int getSizeY()
          Return Y size of the level set function.
 int getSizeZ()
          Return Z size of the level set function.
private  void initFromLabels(MTBImage initLabelImg, MTBImage invalidImg, boolean multiphase)
          Helper for constructors from a label image.
private  void initLevelset(MTBImage invalidImg)
          Helper to initialize a two phase level set function of size as given by invalidImg with a circle/sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.
private  void initLevelset(MTBImage img, int threshold, MTBImage invalidImg)
          Initialize a two phase level set function by thresholding an image.
 boolean isValid(MTBImage invalidImg, int x, int y, int z)
          returns true, if pixel/voxel is valid.
 java.lang.String toString()
          Return a string representation.
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BG_PHASE

public static final byte BG_PHASE
Level set function value to represent the background phase

See Also:
Constant Field Values

INVALID_PHASE

public static final byte INVALID_PHASE
Level set function value to represent invalid pixels

See Also:
Constant Field Values

MAX_ALLOWED_NUM_PHASES

public static final int MAX_ALLOWED_NUM_PHASES
Maximal number of phases which may be represented including background phase.

See Also:
Constant Field Values

numPhases

private int numPhases

phi

private byte[][][] phi

sizePhases

private int[] sizePhases

sizeX

private final int sizeX

sizeY

private final int sizeY

sizeZ

private final int sizeZ

sumSizeObject

private int sumSizeObject
Constructor Detail

MTBLevelsetMembership

public MTBLevelsetMembership(int sizeX,
                             int sizeY,
                             int sizeZ)
Constructs a two phase level set function which is initialiazed with a circle or sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.

Parameters:
sizeX -
sizeY -
sizeZ -

MTBLevelsetMembership

public MTBLevelsetMembership(int sizeX,
                             int sizeY,
                             int sizeZ,
                             MTBImage invalidImg)
Constructs a two phase level set function which is initialiazed with a circle or sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
sizeX -
sizeY -
sizeZ -
invalidImg -

MTBLevelsetMembership

public MTBLevelsetMembership(int sizeX,
                             int sizeY,
                             int sizeZ,
                             MTBImage img,
                             int threshold,
                             MTBImage invalidImg)
Creates a two phase level set function from an image via thresholding. All pixels with intensities greater equal the threshold constitute the object phase, other pixels the background.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
sizeX -
sizeY -
sizeZ -
img - Images tp be thresholded
threshold - All pixels with intensities greater equal are object pixels
invalidImg -

MTBLevelsetMembership

public MTBLevelsetMembership(int sizeX,
                             int sizeY,
                             MTBRegion2DSet regions,
                             MTBImage invalidImg,
                             boolean multiphase)
Constructor for given size which is initialized from a MTBRegion2DSet for a 2D level set function. If multiphase is true, each region yields on phase thus the number of regions determines the the number of phases. If multiphase is true, then each region yields on phase thus the number of regions determines the the number of phases. If mutliphase is false, exactly one object phase is populated from all regions. If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
sizeX -
sizeY -
regions - Region2D set to initialize from
invalidImg - pixels which are non zero are assumed invalid
multiphase - if true create one phase for each region, otherwise two phases

MTBLevelsetMembership

public MTBLevelsetMembership(int sizeX,
                             int sizeY,
                             java.util.Vector<MTBRegion2D> regions,
                             MTBImage invalidImg,
                             boolean multiphase)
Constructor for given size which is initialized from a list of 2D regions for a 2D level set function. If multiphase is true, then each region yields on phase thus the number of regions determines the the number of phases. If multiphase is false, exactly one object phase is populated from all regions.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
sizeX -
sizeY -
regions - Vector of regions to initialize from
invalidImg - pixels which are non zero are assumed invalid
multiphase - if true create one phase for each region, otherwise two phases

MTBLevelsetMembership

public MTBLevelsetMembership(MTBImage initLabelImg,
                             MTBImage invalidImg)
Constructor for a two phase level set function from a label image. Label zero is interpreted as background, everything else as foreground, e.g. the only object phase. If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
initLabelImg - Label image for initialization
invalidImg - Image indicating invalid pixels with values <> 0

MTBLevelsetMembership

public MTBLevelsetMembership(MTBImage initLabelImg,
                             MTBImage invalidImg,
                             boolean multiphase)
Constructor for a level set function from a label image. if multiphase is true, then a multi phase level set function is created, where labels ared interpreted as phases (a label of zero indeicated background). Otherwise a two phase level set function is created, where all non zero labels are interpreted as foreground.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
initLabelImg - Label image for initialization
invalidImg - Image indicating invalid pixels with values <> 0

MTBLevelsetMembership

public MTBLevelsetMembership(MTBLevelsetMembership phi)
Creates a copy of phi.

Parameters:
phi - levelset function to copy
Method Detail

changePhase

public void changePhase(int x,
                        int y,
                        byte phase)
Change a pixel to a new phase. Note: validity of phase is NOT checked.

Parameters:
x -
y -
phase -

changePhase

public void changePhase(int x,
                        int y,
                        int z,
                        byte phase)
Change a pixel/voxel to a new phase. Note: validity of phase is NOT checked.

Parameters:
x -
y -
z -
phase -

getMTBImage

public MTBImageByte getMTBImage()
Creates a bi-level MTBImageByte of the level set function. Background and invalid pixels get intensity 0, object pixels intensity 255.

Returns:
MTBImage

getMTBImageLabel

public MTBImageByte getMTBImageLabel()
Creates a MTBImageByte of the level set function. Background and invalid pixels get value 0, the object phases get values starting with 1

Returns:
MTBImageByte

getNumPhases

public int getNumPhases()
Return .e. number phases.


getPhase

public byte getPhase(int x,
                     int y)
Return phase for a pixel/voxel, z coordinate defaults to zero

Parameters:
x -
y -

getPhase

public byte getPhase(int x,
                     int y,
                     int z)
Return phase for a pixel/voxel

Parameters:
x -
y -
z -

getPhaseCheckXY

public byte getPhaseCheckXY(int x,
                            int y)
Return phase for a pixel checking limits of all coordinates. If coordinates are invalid, INVALID_PHASE is returned.

Parameters:
x -
y -
Returns:
phase

getPhaseCheckXYZ

public byte getPhaseCheckXYZ(int x,
                             int y,
                             int z)
Return phase for a pixel/voxel checking limits of all coordinates. If coordinates are invalid, INVALID_PHASE is returned.

Parameters:
x -
y -
z -
Returns:
phase

getPixelInside

public int getPixelInside()
Return number of pixels of all object phases.


getPixelOutside

public int getPixelOutside()
Return number of pixels of background phase.


getSizePhase

public int getSizePhase(byte phase)
Return the size, i.e. number of pixel/voxels of a phase.


getSizeX

public int getSizeX()
Return X size of the level set function.


getSizeY

public int getSizeY()
Return Y size of the level set function.


getSizeZ

public int getSizeZ()
Return Z size of the level set function.


initFromLabels

private void initFromLabels(MTBImage initLabelImg,
                            MTBImage invalidImg,
                            boolean multiphase)
Helper for constructors from a label image. If multiphase is true, then a multi phase level set function is created, where labels are interpreted as phases (a label of zero indicates background). The set of occurring in the label image are mapped to a contiguous interval of phases (starting with BG_PHASE). The label 0 is mapped to BG_PHASE

Otherwise a two phase level set function is created, where all non zero labels are interpreted as foreground.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
initLabelImg - Label image for initialization
invalidImg - Image indicating invalid pixels with values <> 0
multiphase - Construct multi or two phase level set function iff true or false, resp.

initLevelset

private void initLevelset(MTBImage invalidImg)
Helper to initialize a two phase level set function of size as given by invalidImg with a circle/sphere of radius 0.5*(sizeX+sizeY+sizeZ)/3.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid


initLevelset

private void initLevelset(MTBImage img,
                          int threshold,
                          MTBImage invalidImg)
Initialize a two phase level set function by thresholding an image. All pixels with intensities greater equal the threshold constitute the object phase, other pixels the background.

If invalidImg is non null, than pixels <> zero in invalidImg are invalid

Parameters:
threshold -
threshold - All pixels with intensities greater equal are object pixels
invalidImg -

isValid

public boolean isValid(MTBImage invalidImg,
                       int x,
                       int y,
                       int z)
returns true, if pixel/voxel is valid. Valid pixels are define as zero pixels (i.e. invalid pixels are marks with phase not equal to zero

Parameters:
invalidImg -
x -
y -
z -

toString

public java.lang.String toString()
Return a string representation.

Overrides:
toString in class java.lang.Object