-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
731 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
CemrgApp/Modules/CemrgAppModule/include/CemrgMultilabelSegmentationUtils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*========================================================================= | ||
Program: Medical Imaging & Interaction Toolkit | ||
Language: C++ | ||
Date: $Date$ | ||
Version: $Revision$ | ||
Copyright (c) German Cancer Research Center, Division of Medical and | ||
Biological Informatics. All rights reserved. | ||
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. | ||
This software is distributed WITHOUT ANY WARRANTY; without even | ||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the above copyright notices for more information. | ||
=========================================================================*/ | ||
/*========================================================================= | ||
* | ||
* Four Chamber Tools (inherits CemrgCommandLine) | ||
* | ||
* Cardiac Electromechanics Research Group | ||
* http://www.cemrgapp.com | ||
* [email protected] | ||
* | ||
* This software is distributed WITHOUT ANY WARRANTY or SUPPORT! | ||
* | ||
=========================================================================*/ | ||
|
||
#ifndef CemrgMultilabelSegmentationUtils_h | ||
#define CemrgMultilabelSegmentationUtils_h | ||
|
||
#include <QString> | ||
#include <QJsonObject> | ||
|
||
#include <mitkIOUtil.h> | ||
#include <mitkImage.h> | ||
#include <mitkCommon.h> | ||
|
||
// VTK | ||
#include <vtkSmartPointer.h> | ||
#include <vtkConnectivityFilter.h> | ||
#include <vtkIdList.h> | ||
#include <vtkRegularPolygonSource.h> | ||
|
||
// ITK | ||
#include <itkImage.h> | ||
#include <itkImageRegionIterator.h> | ||
|
||
#include "CemrgCommandLine.h" | ||
|
||
class MITKCEMRGAPPMODULE_EXPORT CemrgMultilabelSegmentationUtils { | ||
typedef itk::Image<uint8_t, 3> ImageType; | ||
typedef itk::ImageRegionIterator<ImageType> IteratorType; | ||
|
||
public: | ||
CemrgMultilabelSegmentationUtils(); | ||
~CemrgMultilabelSegmentationUtils(); | ||
|
||
// Segmentation Utilities | ||
bool CheckExisting(mitk::Image::Pointer seg, int queryLabel); | ||
void ExploreLabelsToSplit(mitk::Image::Pointer seg, std::vector<int>& labels); | ||
mitk::Image::Pointer SplitLabelsOnRepeat(mitk::Image::Pointer seg, int label, unsigned int radius=3); | ||
|
||
mitk::Image::Pointer ReplaceLabel(mitk::Image::Pointer seg, int oldLabel, int newLabel); | ||
inline mitk::Image::Pointer RemoveLabel(mitk::Image::Pointer seg, int label) { return ReplaceLabel(seg, label, 0); }; | ||
|
||
mitk::Image::Pointer ResampleSmoothLabel(mitk::Image::Pointer image, std::vector<double> spacing, double sigmaFraction=0.5, double alphaFraction=3.0); | ||
|
||
mitk::Image::Pointer LabelMaskAndOperation(mitk::Image::Pointer seg, mitk::Image::Pointer mask, int oldLabel, int newLabel); | ||
mitk::Image::Pointer ConnectedComponent(mitk::Image::Pointer seg, std::vector<unsigned int> seedIdx, int label, bool keep=false); | ||
inline mitk::Image::Pointer ConnectedComponentKeep(mitk::Image::Pointer seg, std::vector<unsigned int> seedIdx, int label) { return ConnectedComponent(seg, seedIdx, label, true); }; | ||
mitk::Image::Pointer ExtractLargestComponent(mitk::Image::Pointer seg, int numLabels=1, int outputLabel=1); | ||
mitk::Image::Pointer CleanMultilabelSegmentation(mitk::Image::Pointer seg, int background=0); | ||
|
||
mitk::Image::Pointer DistanceMap(mitk::Image::Pointer seg, int label); | ||
mitk::Image::Pointer Threshold(mitk::Image::Pointer seg, int label, int lower, int upper); | ||
|
||
mitk::Image::Pointer ZerosLike(mitk::Image::Pointer image); | ||
|
||
// helper functions | ||
void GetLabels(mitk::Image::Pointer seg, std::vector<int>& labels, int background=0); | ||
mitk::Image::Pointer ExtractSingleLabel(mitk::Image::Pointer seg, int label, bool binarise=true); | ||
mitk::Image::Pointer ExtractSetOfLabels(mitk::Image::Pointer seg, std::vector<int> labels, bool binarise=true); | ||
mitk::Image::Pointer BwLabelN(mitk::Image::Pointer seg, std::vector<int>& labels, bool openImage=false); | ||
ImageType::Pointer ItkBwLabelN(mitk::Image::Pointer seg, std::vector<int>& labels, bool openImage=false); | ||
|
||
bool GetLabelCentreOfMassIndex(mitk::Image::Pointer seg, int label, std::vector<unsigned int> &cogIndx); | ||
bool GetLabelCentreOfMass(mitk::Image::Pointer seg, int label, std::vector<double> &cog); | ||
|
||
void WorldToIndex(mitk::Image::Pointer image, std::vector<double> world, std::vector<unsigned int>& index); | ||
void IndexToWorld(mitk::Image::Pointer image, std::vector<unsigned int> index, std::vector<double> &world); | ||
|
||
void WorldToIndexOriginSpacing(std::vector<double> world, std::vector<unsigned int>& index, std::vector<double> origin, std::vector<double> spacing); | ||
void IndexToWorldOriginSpacing(std::vector<unsigned int> index, std::vector<double> &world, std::vector<double> origin, std::vector<double> spacing); | ||
|
||
protected: | ||
|
||
private : | ||
}; | ||
#endif // CemrgMultilabelSegmentationUtils_h |
Oops, something went wrong.