MeVisLab Toolbox Reference
|
This class implements the Marching Squares algorithm to find isolines on 2D image slices. More...
#include <CSOMarchingSquares.h>
Classes | |
struct | FillCSOParameters |
Public Member Functions | |
CSOMarchingSquares () | |
Constructor. | |
~CSOMarchingSquares () | |
Destructor. | |
void | reset () |
Resets the state of the object. | |
void | setInterpolation (bool use) |
Specifies whether the algorithm should interpolate the contour bi-linearly. | |
void | setImage (float *image, int imgSizeX, int imgSizeY) |
Sets the 2D image to track/find contours on. | |
void | setFunction (CSOFunction *implicitFunction, const Matrix4 &voxelToWorldMatrix, int startX, int startY, int imgSizeX, int imgSizeY, int voxelZPosition) |
Sets a 3D interpolation function, an image size and voxel size and a fixed z-offset. | |
void | findIsoLine (int startPosX, int startPosY, float isoValue, bool takeShortestPath, CSOMarchingSquaresCell::vecPoint2D &positions) |
Looks for an isoline on the image . | |
void | findAllIsoLines (float isoValue, bool takeShortestPath, std::vector< CSOMarchingSquaresCell::vecPoint2D > &vecPositions) |
Finds all contours on the image with isovalue isovalue . Returns them in a vector of 2D position vectors. | |
bool | fillCSO (FillCSOParameters ¶meters) |
Fills the given CSO with seed points according to the given list of points. | |
Protected Member Functions | |
void | _findStartPosition (int &startX, int &startY) |
Searches for a starting position such that startX/startY make up the top-left voxel position of a cell which is intersected by the isoline. | |
bool | _findNearestIsoCell (int voxelPosX, int voxelPosY, CSOMarchingSquaresCell &cell) |
Searches for the first cell that is an iso cell starting from [voxelPosX , voxelPosY ]. Returns true if a cell was found, i.e. cell is valid. | |
bool | _findNearestIsoCell (int voxelPos[2], CSOMarchingSquaresCell &cell) |
Searches for the first cell that is an iso cell starting from [voxelPos [0], voxelPos [1]]. Returns true if a cell was found, i.e. cell is valid. | |
void | _trackIsoCell (CSOMarchingSquaresCell startCell, const int initialFromDir, CSOMarchingSquaresCell::vecPoint2D &positions, std::vector< std::array< unsigned char, 2 > > *cellsVisitedDirections=nullptr) |
Tracks the isoline starting from the startCell . | |
void | _createCell (int topLeftVoxel[2], CSOMarchingSquaresCell &cell) |
Create a new cell at position topLeftVoxel [2]. | |
void | _createCell (int topLeftVoxel[2], std::set< unsigned int > &cellsVisited, std::queue< CSOMarchingSquaresCell > &cellFront) |
Create a new cell at position topLeftVoxel [2], keeps track whether this cell has already been created. | |
void | _createCell (int topLeftVoxel[2], CSOMarchingSquaresCell &cell, float values[4], char cellConfig) |
Create a new cell at position topLeftVoxel [2]. | |
int | _walkToCell (const CSOMarchingSquaresCell &fromCell, int fromDir, CSOMarchingSquaresCell &toCell) |
Create a cell toCell from the cell fromCell coming from fromDir . | |
int | _getPossibleEnterDirection (const CSOMarchingSquaresCell &cell) const |
unsigned int | _getKey (const CSOMarchingSquaresCell &cell) const |
Returns the key for a cell. E.g. for hashtables. | |
unsigned int | _getKey (int x, int y) const |
Returns the key for a position for hashtables. | |
float | _getValueAt (int x, int y) |
Returns the value of the image or function at the given position. | |
bool | _isInImage (int x, int y) const |
Returns whether the x,y coordinates are within the image. | |
Protected Attributes | |
float * | _image |
Pointer to input image. | |
int | _imageSizeX |
The x extent of the input image. | |
int | _imageSizeY |
The y extent of the input image. | |
int | _startX |
Starting voxel x (function). | |
int | _startY |
Starting voxel y (function). | |
float | _isoValue |
The iso value to find the iso line for. | |
CSOFunction * | _function |
An implicit function. | |
int | _voxelZPosition |
The z-position of the voxels. | |
Matrix4 | _voxelToWorldMatrix |
The voxelToWorld matrix. | |
bool | _bInterpolatePoints |
Should the contour be interpolated bi-linearly? | |
boost::unordered_map< int, double > | _existingValues |
A map holding all computed image/function values. | |
This class implements the Marching Squares algorithm to find isolines on 2D image slices.
One can either find an iso line starting from a start point or find all contours on that slice.
Definition at line 38 of file CSOMarchingSquares.h.
ml::CSOMarchingSquares::CSOMarchingSquares | ( | ) |
Constructor.
ml::CSOMarchingSquares::~CSOMarchingSquares | ( | ) |
Destructor.
|
protected |
Create a new cell at position topLeftVoxel
[2].
|
protected |
Create a new cell at position topLeftVoxel
[2].
|
protected |
Create a new cell at position topLeftVoxel
[2], keeps track whether this cell has already been created.
|
protected |
Searches for the first cell that is an iso cell starting from [voxelPos
[0], voxelPos
[1]]. Returns true if a cell was found, i.e. cell
is valid.
|
protected |
Searches for the first cell that is an iso cell starting from [voxelPosX
, voxelPosY
]. Returns true if a cell was found, i.e. cell
is valid.
Searches for a starting position such that startX/startY make up the top-left voxel position of a cell which is intersected by the isoline.
|
inlineprotected |
Returns the key for a cell. E.g. for hashtables.
Definition at line 194 of file CSOMarchingSquares.h.
References mlrange_cast().
Returns the key for a position for hashtables.
Definition at line 201 of file CSOMarchingSquares.h.
|
inlineprotected |
Definition at line 208 of file CSOMarchingSquares.h.
References mlrange_cast().
Returns the value of the image or function at the given position.
Returns whether the x,y coordinates are within the image.
|
protected |
Tracks the isoline starting from the startCell
.
If this is not an iso-cell (i.e. the isoline intersects this cell) it just returns. One can optionally pass a map where to save all visited cells.
|
protected |
Create a cell toCell
from the cell fromCell
coming from fromDir
.
So this method first looks for the direction leaving the fromCell coming from the direction fromDir
.
toCell
bool ml::CSOMarchingSquares::fillCSO | ( | FillCSOParameters & | parameters | ) |
Fills the given CSO with seed points according to the given list of points.
void ml::CSOMarchingSquares::findAllIsoLines | ( | float | isoValue, |
bool | takeShortestPath, | ||
std::vector< CSOMarchingSquaresCell::vecPoint2D > & | vecPositions ) |
Finds all contours on the image
with isovalue isovalue
. Returns them in a vector of 2D position vectors.
void ml::CSOMarchingSquares::findIsoLine | ( | int | startPosX, |
int | startPosY, | ||
float | isoValue, | ||
bool | takeShortestPath, | ||
CSOMarchingSquaresCell::vecPoint2D & | positions ) |
Looks for an isoline on the image
.
It starts searching for a starting cell using the startPos parameters and then tracks this cell. All contour points are pushed back to the positions vector.
void ml::CSOMarchingSquares::reset | ( | ) |
Resets the state of the object.
|
inline |
Sets a 3D interpolation function, an image size and voxel size and a fixed z-offset.
NOTE that this approach supports an axial scanning of the function only at the moment; if this class should scan in sagittal or coronal direction as well, some extra flag needs to be provided.
Definition at line 165 of file CSOMarchingSquares.h.
References mlrange_cast().
Sets the 2D image to track/find contours on.
Definition at line 151 of file CSOMarchingSquares.h.
References mlrange_cast().
Specifies whether the algorithm should interpolate the contour bi-linearly.
Definition at line 187 of file CSOMarchingSquares.h.
References mlrange_cast().
|
protected |
Should the contour be interpolated bi-linearly?
Definition at line 143 of file CSOMarchingSquares.h.
A map holding all computed image/function values.
Definition at line 146 of file CSOMarchingSquares.h.
|
protected |
An implicit function.
Definition at line 136 of file CSOMarchingSquares.h.
|
protected |
Pointer to input image.
Definition at line 122 of file CSOMarchingSquares.h.
|
protected |
The x extent of the input image.
Definition at line 124 of file CSOMarchingSquares.h.
|
protected |
The y extent of the input image.
Definition at line 126 of file CSOMarchingSquares.h.
|
protected |
The iso value to find the iso line for.
Definition at line 134 of file CSOMarchingSquares.h.
|
protected |
Starting voxel x (function).
Definition at line 129 of file CSOMarchingSquares.h.
|
protected |
Starting voxel y (function).
Definition at line 131 of file CSOMarchingSquares.h.
|
protected |
The voxelToWorld matrix.
Definition at line 140 of file CSOMarchingSquares.h.
|
protected |
The z-position of the voxels.
Definition at line 138 of file CSOMarchingSquares.h.