23#include <ThirdPartyWarningsDisable.h>
24#include <boost/unordered_map.hpp>
25#include <ThirdPartyWarningsRestore.h>
53 void setInterpolation(
bool use);
111 unsigned int _getKey(
int x,
int y)
const;
166 const Matrix4& voxelToWorldMatrix,
180 _voxelToWorldMatrix = voxelToWorldMatrix;
196 return _getKey(
cell._topLeftVoxel[0],
cell._topLeftVoxel[1]);
201inline 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.
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.
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.
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 _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.
Class which represents an image, which manages properties of an image and image data which is located...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
CSOSmoothingModes
Enumeration of smoothing modes.
bool shouldReduceCSOToOnlyOneSeedPoint
CSOSmoothingModes smoothingMode
CSOMarchingSquaresCell::vecPoint2D positions