23 #include <ThirdPartyWarningsDisable.h>
24 #include <boost/unordered_map.hpp>
25 #include <ThirdPartyWarningsRestore.h>
53 void setInterpolation(
bool use);
55 void setImage(
float* image,
int imgSizeX,
int imgSizeY);
59 void setFunction(
CSOFunction* implicitFunction,
const Matrix4& voxelToWorldMatrix,
int startX,
int startY,
int imgSizeX,
int imgSizeY,
int voxelZPosition);
66 void findAllIsoLines(
float isoValue,
bool takeShortestPath, std::vector<CSOMarchingSquaresCell::vecPoint2D>& vecPositions);
99 void _createCell(
int topLeftVoxel[2], std::set<unsigned int>& cellsVisited, std::queue<CSOMarchingSquaresCell>& cellFront);
111 unsigned int _getKey(
int x,
int y)
const;
151 inline void CSOMarchingSquares::setImage(
float* image,
int imgSizeX,
int imgSizeY)
154 _imageSizeX = imgSizeX;
155 _imageSizeY = imgSizeY;
165 inline void CSOMarchingSquares::setFunction(
CSOFunction* implicitFunction,
166 const Matrix4& voxelToWorldMatrix,
167 int startX,
int startY,
168 int imgSizeX,
int imgSizeY,
173 _imageSizeX = imgSizeX;
174 _imageSizeY = imgSizeY;
179 _function = implicitFunction;
180 _voxelToWorldMatrix = voxelToWorldMatrix;
182 _voxelZPosition = voxelZPosition;
187 inline void CSOMarchingSquares::setInterpolation(
bool useInterpolation)
189 _bInterpolatePoints = useInterpolation;
201 inline unsigned int CSOMarchingSquares::_getKey(
int x,
int y)
const
203 return 1 + x-_startX + ((1 + y-_startY) * (_imageSizeX+_startX+1));
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Base class for distance functions for application in the marching cubes algorithm.
int getToDirection(int fromDir) const
Returns the direction for this cell to go to coming from fromDir.
int _topLeftVoxel[2]
The position of the top left voxel in voxel coordinates.
std::vector< Vector2 > vecPoint2D
Defines a 2D point vector.
This class implements the Marching Squares algorithm to find isolines on 2D image slices.
Matrix4 _voxelToWorldMatrix
The voxelToWorld matrix.
float * _image
Pointer to input image.
int _imageSizeX
The x extent of the input image.
int _startY
Starting voxel y (function).
int _voxelZPosition
The z-position of the voxels.
boost::unordered_map< int, double > _existingValues
A map holding all computed image/function values.
bool _findNearestIsoCell(int voxelPos[2], CSOMarchingSquaresCell &cell)
Searches for the first cell that is an iso cell starting from [voxelPos[0], voxelPos[1]]....
float _getValueAt(int x, int y)
Returns the value of the image or function at the given position.
void _createCell(int topLeftVoxel[2], CSOMarchingSquaresCell &cell)
Create a new cell at position topLeftVoxel[2].
int _imageSizeY
The y extent of the input image.
void _findStartPosition(int &startX, int &startY)
Searches for a starting position such that startX/startY make up the top-left voxel position of a cel...
bool fillCSO(FillCSOParameters ¶meters)
Fills the given CSO with seed points according to the given list of points.
void reset()
Resets the state of the object.
CSOMarchingSquares()
Constructor.
void _createCell(int topLeftVoxel[2], CSOMarchingSquaresCell &cell, float values[4], char cellConfig)
Create a new cell at position topLeftVoxel[2].
void findIsoLine(int startPosX, int startPosY, float isoValue, bool takeShortestPath, CSOMarchingSquaresCell::vecPoint2D &positions)
Looks for an isoline on the image.
bool _isInImage(int x, int y) const
Returns whether the x,y coordinates are within the image.
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...
~CSOMarchingSquares()
Destructor.
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.
int _walkToCell(const CSOMarchingSquaresCell &fromCell, int fromDir, CSOMarchingSquaresCell &toCell)
Create a cell toCell from the cell fromCell coming from fromDir.
CSOFunction * _function
An implicit function.
int _startX
Starting voxel x (function).
bool _bInterpolatePoints
Should the contour be interpolated bi-linearly?
float _isoValue
The iso value to find the iso line for.
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 vecto...
bool _findNearestIsoCell(int voxelPosX, int voxelPosY, CSOMarchingSquaresCell &cell)
Searches for the first cell that is an iso cell starting from [voxelPosX, voxelPosY]....
The CSO represents a contour segmentation object.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
CSOSmoothingModes
Enumeration of smoothing modes.
bool shouldReduceCSOToOnlyOneSeedPoint
CSOSmoothingModes smoothingMode
CSOMarchingSquaresCell::vecPoint2D positions