|
SimpleITK
|
Computes a list of PolyLineParametricPath objects from the contours in a 2D image. More...
#include <sitkContourExtractor2DImageFilter.h>
Inheritance diagram for itk::simple::ContourExtractor2DImageFilter:
Collaboration diagram for itk::simple::ContourExtractor2DImageFilter:Computes a list of PolyLineParametricPath objects from the contours in a 2D image.
Uses the "marching squares" method to compute a the iso-valued contours of the input 2D image for a given intensity value. Multiple outputs may be produced because an image can have multiple contours at a given level, so it is advised to call GetNumberOfIndexedOutputs() and GetOutput(n) to retrieve all of the contours. The contour value to be extracted can be set with SetContourValue(). Image intensities will be linearly interpolated to provide sub-pixel resolution for the output contours.
The marching squares algorithm is a special case of the marching cubes algorithm [73]. A simple explanation is available here: http://users.polytech.unice.fr/~lingrand/MarchingCubes/algo.html
There is an ambiguous case in the marching squares algorithm: if a given 2x2-pixel square has two high-valued and two low-valued pixels, each pair diagonally adjacent. (Note that high-valued and low-valued are with respect to the contour value sought when LabelContours is false. When LabelContours is true, high-valued means the label being traced and low-valued means any other label.) In this case, the default behavior is that the low-valued pixels are connected into the same contour via an isthmus that separates the high-valued pixels into separate contours. To reverse this, call VertexConnectHighPixelsOn(). Note that when LabelContours is true, the default behavior will leave all four pixels in separate contours. In this case, VertexConnectHighPixels equal to true can instead create contours that are crossing barbells.
Outputs are not guaranteed to be closed paths: contours which intersect the image edge will be left open. All other paths will be closed. (The closedness of a path can be tested by checking whether the beginning point is the same as the end point.)
Produced paths are oriented. Following the path from beginning to end, image intensity values lower than the contour value are to the left of the path and intensity values greater than the contour value are to the right. In other words, the image gradient at a path segment is (approximately) in the direct of that segment rotated right by 90 degrees, because the image intensity values increase from left-to-right across the segment. This means that the generated contours will circle clockwise around "hills" of above-contour-value intensity, and counter-clockwise around "depressions" of below-contour-value intensity. This convention can be reversed by calling ReverseContourOrientationOn().
By default values are interpreted as intensities relative to a contour value. First calling LabelContoursOn() changes this behavior to instead interpret each value as a label. Boundaries are computed for each label separately and all are returned. The value of LabelContours affects the interpretation of VertexConnectHighPixels; see above.
By default the input image's largest possible region will be processed; call SetRequestedRegion() to process a different region, or ClearRequestedRegion() to revert to the default value. Note that the requested regions are usually set on the output; however since paths have no notion of a "region", this must be set at the filter level.
This class was contributed to the Insight Journal by Zachary Pincus. https://doi.org/10.54294/olkmog
Definition at line 80 of file sitkContourExtractor2DImageFilter.h.
Public Types | |
| using | PixelIDTypeList = BasicPixelIDTypeList |
| using | Self = ContourExtractor2DImageFilter |
Public Types inherited from itk::simple::ImageFilter | |
| using | Self = ImageFilter |
Public Types inherited from itk::simple::ProcessObject | |
| using | Self = ProcessObject |
Public Member Functions | |
| ContourExtractor2DImageFilter () | |
| void | Execute (const Image &image1) |
| std::vector< double > | GetContour (unsigned int n) const |
| double | GetContourValue () const |
| bool | GetLabelContours () const |
| std::string | GetName () const |
| unsigned int | GetNumberOfCountours () const |
| bool | GetReverseContourOrientation () const |
| bool | GetVertexConnectHighPixels () const |
| void | LabelContoursOff () |
| void | LabelContoursOn () |
| void | ReverseContourOrientationOff () |
| void | ReverseContourOrientationOn () |
| void | SetContourValue (double ContourValue) |
| void | SetLabelContours (bool LabelContours) |
| void | SetReverseContourOrientation (bool ReverseContourOrientation) |
| void | SetVertexConnectHighPixels (bool VertexConnectHighPixels) |
| std::string | ToString () const |
| void | VertexConnectHighPixelsOff () |
| void | VertexConnectHighPixelsOn () |
| virtual | ~ContourExtractor2DImageFilter () |
Public Member Functions inherited from itk::simple::ImageFilter | |
| ImageFilter () | |
| virtual | ~ImageFilter ()=0 |
Public Member Functions inherited from itk::simple::ProcessObject | |
| virtual void | Abort () |
| virtual int | AddCommand (itk::simple::EventEnum event, const std::function< void()> &func) |
| Directly add a callback to observe an event. | |
| virtual int | AddCommand (itk::simple::EventEnum event, itk::simple::Command &cmd) |
| Add a Command Object to observer the event. | |
| virtual float | GetProgress () const |
| An Active Measurement of the progress of execution. | |
| virtual bool | HasCommand (itk::simple::EventEnum event) const |
| Query of this object has any registered commands for event. | |
| ProcessObject () | |
| virtual void | RemoveAllCommands () |
| Remove all registered commands. | |
| virtual | ~ProcessObject () |
| virtual void | DebugOn () |
| virtual void | DebugOff () |
| virtual bool | GetDebug () const |
| virtual void | SetDebug (bool debugFlag) |
| virtual void | SetNumberOfThreads (unsigned int n) |
| virtual unsigned int | GetNumberOfThreads () const |
| virtual void | SetNumberOfWorkUnits (unsigned int n) |
| virtual unsigned int | GetNumberOfWorkUnits () const |
Private Types | |
| using | MemberFunctionType = void (Self::*)(const Image &image1) |
Private Member Functions | |
| template<class TImageType> | |
| void | ExecuteInternal (const Image &image1) |
Static Private Member Functions | |
| static const detail::MemberFunctionFactory< MemberFunctionType > & | GetMemberFunctionFactory () |
Private Attributes | |
| double | m_ContourValue { 0.0 } |
| std::unique_ptr< itk::ProcessObject, ProcessObjectDeleter > | m_Filter {nullptr} |
| bool | m_LabelContours { false } |
| unsigned int | m_NumberOfCountours { 0 } |
| std::function< std::vector< double >(unsigned int)> | m_pfGetContour |
| bool | m_ReverseContourOrientation { false } |
| bool | m_VertexConnectHighPixels { false } |
Friends | |
| struct | detail::MemberFunctionAddressor< MemberFunctionType > |
Additional Inherited Members | |
Static Public Member Functions inherited from itk::simple::ProcessObject | |
| static bool | GetGlobalDefaultDebug () |
| static void | GlobalDefaultDebugOff () |
| static void | GlobalDefaultDebugOn () |
| static void | SetGlobalDefaultDebug (bool debugFlag) |
| static void | GlobalWarningDisplayOn () |
| static void | GlobalWarningDisplayOff () |
| static void | SetGlobalWarningDisplay (bool flag) |
| static bool | GetGlobalWarningDisplay () |
| static double | GetGlobalDefaultCoordinateTolerance () |
| Access the global tolerance to determine congruent spaces. | |
| static void | SetGlobalDefaultCoordinateTolerance (double) |
| Access the global tolerance to determine congruent spaces. | |
| static double | GetGlobalDefaultDirectionTolerance () |
| Access the global tolerance to determine congruent spaces. | |
| static void | SetGlobalDefaultDirectionTolerance (double) |
| Access the global tolerance to determine congruent spaces. | |
| static bool | SetGlobalDefaultThreader (const std::string &threader) |
| Set/Get the default threader used for process objects. | |
| static std::string | GetGlobalDefaultThreader () |
| Set/Get the default threader used for process objects. | |
| static void | SetGlobalDefaultNumberOfThreads (unsigned int n) |
| static unsigned int | GetGlobalDefaultNumberOfThreads () |
| Set/Get the default threader used for process objects. | |
Protected Member Functions inherited from itk::simple::ImageFilter | |
| void | CheckImageMatchingDimension (const Image &image1, const Image &image2, const std::string &image2Name) |
| void | CheckImageMatchingPixelType (const Image &image1, const Image &image2, const std::string &image2Name) |
| void | CheckImageMatchingSize (const Image &image1, const Image &image2, const std::string &image2Name) |
Protected Member Functions inherited from itk::simple::ProcessObject | |
| virtual unsigned long | AddITKObserver (const itk::EventObject &, itk::Command *) |
| virtual itk::ProcessObject * | GetActiveProcess () |
| virtual void | OnActiveProcessDelete () |
| virtual void | onCommandDelete (const itk::simple::Command *cmd) noexcept |
| virtual void | PreUpdate (itk::ProcessObject *p) |
| virtual void | RemoveITKObserver (EventCommand &e) |
Protected Member Functions inherited from itk::simple::NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
Static Protected Member Functions inherited from itk::simple::ImageFilter | |
| template<class TImageType> | |
| static void | FixNonZeroIndex (TImageType *img) |
Static Protected Member Functions inherited from itk::simple::ProcessObject | |
| template<class TImageType> | |
| static TImageType::ConstPointer | CastImageToITK (const Image &img) |
| template<class TPixelType, unsigned int VImageDimension, unsigned int VLength, template< typename, unsigned int > class TVector> | |
| static Image | CastITKToImage (itk::Image< TVector< TPixelType, VLength >, VImageDimension > *img) |
| template<unsigned int VImageDimension, unsigned int VLength, template< unsigned int > class TVector> | |
| static Image | CastITKToImage (itk::Image< TVector< VLength >, VImageDimension > *img) |
| template<class TImageType> | |
| static Image | CastITKToImage (TImageType *img) |
| static const itk::EventObject & | GetITKEventObject (EventEnum e) |
| template<typename T> | |
| static std::ostream & | ToStringHelper (std::ostream &os, const T &v) |
| static std::ostream & | ToStringHelper (std::ostream &os, const char &v) |
| static std::ostream & | ToStringHelper (std::ostream &os, const signed char &v) |
| static std::ostream & | ToStringHelper (std::ostream &os, const unsigned char &v) |
|
private |
Setup for member function dispatching
Definition at line 201 of file sitkContourExtractor2DImageFilter.h.
Define the pixels types supported by this filter
Definition at line 92 of file sitkContourExtractor2DImageFilter.h.
Definition at line 82 of file sitkContourExtractor2DImageFilter.h.
|
virtual |
Destructor
| itk::simple::ContourExtractor2DImageFilter::ContourExtractor2DImageFilter | ( | ) |
Default Constructor that takes no arguments and initializes default parameters
| void itk::simple::ContourExtractor2DImageFilter::Execute | ( | const Image & | image1 | ) |
Execute the filter on the input image
|
private |
Referenced by detail::MemberFunctionAddressor< MemberFunctionType >.
|
inline |
Get the coordinates of the n-th contour path as a flat vector of doubles in the format (x1, y1, x2, y2, ...). The index n should be less than the number of outputs returned by GetNumberOfOutputs().
This is an active measurement. It may be accessed while the filter is being executing in command call-backs and can be accessed after execution.
Definition at line 186 of file sitkContourExtractor2DImageFilter.h.
References m_pfGetContour.
|
inline |
Set/Get the image intensity value that the contours should follow. This is the equivalent of an iso-value in Marching Squares.
Definition at line 109 of file sitkContourExtractor2DImageFilter.h.
References m_ContourValue.
|
inline |
Return contours for all distinct labels
Definition at line 168 of file sitkContourExtractor2DImageFilter.h.
References m_LabelContours.
|
staticprivate |
|
inlinevirtual |
Name of this class
Implements itk::simple::ProcessObject.
Definition at line 189 of file sitkContourExtractor2DImageFilter.h.
|
inline |
Get the number of contour paths generated. Multiple contours may be produced because an image can have multiple contours at a given level.
This is a measurement. Its value is updated in the Execute methods, so the value will only be valid after an execution.
Definition at line 177 of file sitkContourExtractor2DImageFilter.h.
References m_NumberOfCountours.
|
inline |
Control the orientation of the contours with reference to the image gradient. (See class documentation.)
Definition at line 128 of file sitkContourExtractor2DImageFilter.h.
References m_ReverseContourOrientation.
|
inline |
Control whether high- or low-valued pixels are vertex-connected. Default is for low-valued pixels to be vertex- connected. (See class documentation.)
Definition at line 149 of file sitkContourExtractor2DImageFilter.h.
References m_VertexConnectHighPixels.
|
inline |
Definition at line 163 of file sitkContourExtractor2DImageFilter.h.
References SetLabelContours().
|
inline |
Set the value of LabelContours to true or false respectfully.
Definition at line 161 of file sitkContourExtractor2DImageFilter.h.
References SetLabelContours().
|
inline |
Definition at line 123 of file sitkContourExtractor2DImageFilter.h.
References SetReverseContourOrientation().
|
inline |
Set the value of ReverseContourOrientation to true or false respectfully.
Definition at line 121 of file sitkContourExtractor2DImageFilter.h.
References SetReverseContourOrientation().
|
inline |
Set/Get the image intensity value that the contours should follow. This is the equivalent of an iso-value in Marching Squares.
Definition at line 102 of file sitkContourExtractor2DImageFilter.h.
References m_ContourValue.
|
inline |
Return contours for all distinct labels
Definition at line 156 of file sitkContourExtractor2DImageFilter.h.
References m_LabelContours.
Referenced by LabelContoursOff(), and LabelContoursOn().
|
inline |
Control the orientation of the contours with reference to the image gradient. (See class documentation.)
Definition at line 116 of file sitkContourExtractor2DImageFilter.h.
References m_ReverseContourOrientation.
Referenced by ReverseContourOrientationOff(), and ReverseContourOrientationOn().
|
inline |
Control whether high- or low-valued pixels are vertex-connected. Default is for low-valued pixels to be vertex- connected. (See class documentation.)
Definition at line 136 of file sitkContourExtractor2DImageFilter.h.
References m_VertexConnectHighPixels.
Referenced by VertexConnectHighPixelsOff(), and VertexConnectHighPixelsOn().
|
virtual |
Print ourselves out
Reimplemented from itk::simple::ProcessObject.
|
inline |
Definition at line 143 of file sitkContourExtractor2DImageFilter.h.
References SetVertexConnectHighPixels().
|
inline |
Set the value of VertexConnectHighPixels to true or false respectfully.
Definition at line 141 of file sitkContourExtractor2DImageFilter.h.
References SetVertexConnectHighPixels().
|
friend |
Definition at line 202 of file sitkContourExtractor2DImageFilter.h.
References ExecuteInternal().
|
private |
Definition at line 207 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetContourValue(), and SetContourValue().
|
private |
Definition at line 222 of file sitkContourExtractor2DImageFilter.h.
|
private |
Definition at line 213 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetLabelContours(), and SetLabelContours().
|
private |
Definition at line 217 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetNumberOfCountours().
|
private |
Definition at line 218 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetContour().
|
private |
Definition at line 209 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetReverseContourOrientation(), and SetReverseContourOrientation().
|
private |
Definition at line 211 of file sitkContourExtractor2DImageFilter.h.
Referenced by GetVertexConnectHighPixels(), and SetVertexConnectHighPixels().
1.13.2 |
Privacy Policy