#include <itkConstantPadImageFilter.h>
#include <itkImageSliceIteratorWithIndex.h>
+namespace clitk {
+
//--------------------------------------------------------------------
template<class ImageType>
-void clitk::ComputeBBFromImageRegion(typename ImageType::Pointer image,
- typename ImageType::RegionType region,
- typename itk::BoundingBox<unsigned long,
- ImageType::ImageDimension>::Pointer bb) {
+void ComputeBBFromImageRegion(typename ImageType::Pointer image,
+ typename ImageType::RegionType region,
+ typename itk::BoundingBox<unsigned long,
+ ImageType::ImageDimension>::Pointer bb) {
typedef typename ImageType::IndexType IndexType;
IndexType firstIndex;
IndexType lastIndex;
//--------------------------------------------------------------------
template<int Dimension>
-void clitk::ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo,
- typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1,
- typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2) {
+void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo,
+ typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1,
+ typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2) {
typedef itk::BoundingBox<unsigned long, Dimension> BBType;
typedef typename BBType::PointType PointType;
//--------------------------------------------------------------------
template<class ImageType>
-void clitk::ComputeRegionFromBB(typename ImageType::Pointer image,
- const typename itk::BoundingBox<unsigned long,
- ImageType::ImageDimension>::Pointer bb,
- typename ImageType::RegionType & region) {
+void ComputeRegionFromBB(typename ImageType::Pointer image,
+ const typename itk::BoundingBox<unsigned long,
+ ImageType::ImageDimension>::Pointer bb,
+ typename ImageType::RegionType & region) {
// Types
typedef typename ImageType::IndexType IndexType;
typedef typename ImageType::PointType PointType;
//--------------------------------------------------------------------
template<class ImageType, class TMaskImageType>
typename ImageType::Pointer
-clitk::SetBackground(const ImageType * input,
- const TMaskImageType * mask,
- typename TMaskImageType::PixelType maskBG,
- typename ImageType::PixelType outValue,
- bool inPlace) {
- typedef clitk::SetBackgroundImageFilter<ImageType, TMaskImageType, ImageType>
+SetBackground(const ImageType * input,
+ const TMaskImageType * mask,
+ typename TMaskImageType::PixelType maskBG,
+ typename ImageType::PixelType outValue,
+ bool inPlace) {
+ typedef SetBackgroundImageFilter<ImageType, TMaskImageType, ImageType>
SetBackgroundImageFilterType;
typename SetBackgroundImageFilterType::Pointer setBackgroundFilter
= SetBackgroundImageFilterType::New();
//--------------------------------------------------------------------
template<class ImageType>
-int clitk::GetNumberOfConnectedComponentLabels(typename ImageType::Pointer input,
- typename ImageType::PixelType BG,
- bool isFullyConnected) {
+int GetNumberOfConnectedComponentLabels(typename ImageType::Pointer input,
+ typename ImageType::PixelType BG,
+ bool isFullyConnected) {
// Connected Component label
typedef itk::ConnectedComponentImageFilter<ImageType, ImageType> ConnectFilterType;
typename ConnectFilterType::Pointer connectFilter = ConnectFilterType::New();
*/
template<class ImageType>
typename ImageType::Pointer
-clitk::Labelize(const ImageType * input,
- typename ImageType::PixelType BG,
- bool isFullyConnected,
- int minimalComponentSize) {
+Labelize(const ImageType * input,
+ typename ImageType::PixelType BG,
+ bool isFullyConnected,
+ int minimalComponentSize) {
// InternalImageType for storing large number of component
typedef itk::Image<int, ImageType::ImageDimension> InternalImageType;
*/
template<class ImageType>
typename ImageType::Pointer
-clitk::LabelizeAndCountNumberOfObjects(const ImageType * input,
- typename ImageType::PixelType BG,
- bool isFullyConnected,
- int minimalComponentSize,
- int & nb) {
+LabelizeAndCountNumberOfObjects(const ImageType * input,
+ typename ImageType::PixelType BG,
+ bool isFullyConnected,
+ int minimalComponentSize,
+ int & nb) {
// InternalImageType for storing large number of component
typedef itk::Image<int, ImageType::ImageDimension> InternalImageType;
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::RemoveLabels(typename ImageType::Pointer input,
- typename ImageType::PixelType BG,
- std::vector<typename ImageType::PixelType> & labelsToRemove) {
+RemoveLabels(typename ImageType::Pointer input,
+ typename ImageType::PixelType BG,
+ std::vector<typename ImageType::PixelType> & labelsToRemove) {
typename ImageType::Pointer working_image = input;
for (unsigned int i=0; i <labelsToRemove.size(); i++) {
- typedef clitk::SetBackgroundImageFilter<ImageType, ImageType> SetBackgroundImageFilterType;
+ typedef SetBackgroundImageFilter<ImageType, ImageType> SetBackgroundImageFilterType;
typename SetBackgroundImageFilterType::Pointer setBackgroundFilter = SetBackgroundImageFilterType::New();
setBackgroundFilter->SetInput(input);
setBackgroundFilter->SetInput2(input);
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::KeepLabels(const ImageType * input,
- typename ImageType::PixelType BG,
- typename ImageType::PixelType FG,
- typename ImageType::PixelType firstKeep,
- typename ImageType::PixelType lastKeep,
- bool useLastKeep) {
+KeepLabels(const ImageType * input,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ typename ImageType::PixelType firstKeep,
+ typename ImageType::PixelType lastKeep,
+ bool useLastKeep) {
typedef itk::BinaryThresholdImageFilter<ImageType, ImageType> BinarizeFilterType;
typename BinarizeFilterType::Pointer binarizeFilter = BinarizeFilterType::New();
binarizeFilter->SetInput(input);
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::LabelizeAndSelectLabels(typename ImageType::Pointer input,
- typename ImageType::PixelType BG,
- typename ImageType::PixelType FG,
- bool isFullyConnected,
- int minimalComponentSize,
- LabelizeParameters<typename ImageType::PixelType> * param)
+LabelizeAndSelectLabels(typename ImageType::Pointer input,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool isFullyConnected,
+ int minimalComponentSize,
+ LabelizeParameters<typename ImageType::PixelType> * param)
{
typename ImageType::Pointer working_image;
working_image = Labelize<ImageType>(input, BG, isFullyConnected, minimalComponentSize);
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::ResizeImageLike(typename ImageType::Pointer input,
- typename ImageType::Pointer like,
- typename ImageType::PixelType backgroundValue)
+ResizeImageLike(typename ImageType::Pointer input,
+ typename ImageType::Pointer like,
+ typename ImageType::PixelType backgroundValue)
{
- typedef clitk::CropLikeImageFilter<ImageType> CropFilterType;
+ typedef CropLikeImageFilter<ImageType> CropFilterType;
typename CropFilterType::Pointer cropFilter = CropFilterType::New();
cropFilter->SetInput(input);
cropFilter->SetCropLikeImage(like);
//--------------------------------------------------------------------
template<class MaskImageType>
typename MaskImageType::Pointer
-clitk::SliceBySliceRelativePosition(const MaskImageType * input,
- const MaskImageType * object,
- int direction,
- double threshold,
- std::string orientation,
- bool uniqueConnectedComponent,
- double spacing,
- bool inverseflag)
+SliceBySliceRelativePosition(const MaskImageType * input,
+ const MaskImageType * object,
+ int direction,
+ double threshold,
+ std::string orientation,
+ bool uniqueConnectedComponent,
+ double spacing,
+ bool inverseflag)
{
- typedef clitk::SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
+ typedef SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
sliceRelPosFilter->VerboseStepFlagOff();
sliceRelPosFilter->WriteStepFlagOff();
//--------------------------------------------------------------------
template<class ImageType>
bool
-clitk::FindExtremaPointInAGivenDirection(const ImageType * input,
- typename ImageType::PixelType bg,
- int direction, bool opposite,
- typename ImageType::PointType & point)
+FindExtremaPointInAGivenDirection(const ImageType * input,
+ typename ImageType::PixelType bg,
+ int direction, bool opposite,
+ typename ImageType::PointType & point)
{
typename ImageType::PointType dummy;
- return clitk::FindExtremaPointInAGivenDirection(input, bg, direction,
- opposite, dummy, 0, point);
+ return FindExtremaPointInAGivenDirection(input, bg, direction,
+ opposite, dummy, 0, point);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class ImageType>
bool
-clitk::FindExtremaPointInAGivenDirection(const ImageType * input,
- typename ImageType::PixelType bg,
- int direction, bool opposite,
- typename ImageType::PointType refpoint,
- double distanceMax,
- typename ImageType::PointType & point)
+FindExtremaPointInAGivenDirection(const ImageType * input,
+ typename ImageType::PixelType bg,
+ int direction, bool opposite,
+ typename ImageType::PointType refpoint,
+ double distanceMax,
+ typename ImageType::PointType & point)
{
/*
loop over input pixels, store the index in the fg that is max
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::CropImageAbove(typename ImageType::Pointer image,
- int dim, double min,
- bool autoCrop,
- typename ImageType::PixelType BG)
+CropImageAbove(typename ImageType::Pointer image,
+ int dim, double min,
+ bool autoCrop,
+ typename ImageType::PixelType BG)
{
- return clitk::CropImageAlongOneAxis<ImageType>(image, dim,
- image->GetOrigin()[dim],
- min,
- autoCrop, BG);
+ return CropImageAlongOneAxis<ImageType>(image, dim,
+ image->GetOrigin()[dim],
+ min,
+ autoCrop, BG);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::CropImageBelow(typename ImageType::Pointer image,
- int dim, double max,
- bool autoCrop,
- typename ImageType::PixelType BG)
+CropImageBelow(typename ImageType::Pointer image,
+ int dim, double max,
+ bool autoCrop,
+ typename ImageType::PixelType BG)
{
typename ImageType::PointType p;
image->TransformIndexToPhysicalPoint(image->GetLargestPossibleRegion().GetIndex()+
image->GetLargestPossibleRegion().GetSize(), p);
- return clitk::CropImageAlongOneAxis<ImageType>(image, dim, max, p[dim], autoCrop, BG);
+ return CropImageAlongOneAxis<ImageType>(image, dim, max, p[dim], autoCrop, BG);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::CropImageAlongOneAxis(typename ImageType::Pointer image,
- int dim, double min, double max,
- bool autoCrop,
- typename ImageType::PixelType BG)
+CropImageAlongOneAxis(typename ImageType::Pointer image,
+ int dim, double min, double max,
+ bool autoCrop,
+ typename ImageType::PixelType BG)
{
// Compute region size
typename ImageType::RegionType region;
// Auto Crop
if (autoCrop) {
- result = clitk::AutoCrop<ImageType>(result, BG);
+ result = AutoCrop<ImageType>(result, BG);
}
return result;
}
//--------------------------------------------------------------------
template<class ImageType>
void
-clitk::ComputeCentroids(typename ImageType::Pointer image,
+ComputeCentroids(typename ImageType::Pointer image,
typename ImageType::PixelType BG,
std::vector<typename ImageType::PointType> & centroids)
{
//--------------------------------------------------------------------
template<class ImageType>
void
-clitk::ExtractSlices(typename ImageType::Pointer image,
- int direction,
- std::vector<typename itk::Image<typename ImageType::PixelType,
- ImageType::ImageDimension-1>::Pointer > & slices)
+ExtractSlices(typename ImageType::Pointer image,
+ int direction,
+ std::vector<typename itk::Image<typename ImageType::PixelType,
+ ImageType::ImageDimension-1>::Pointer > & slices)
{
- typedef clitk::ExtractSliceFilter<ImageType> ExtractSliceFilterType;
+ typedef ExtractSliceFilter<ImageType> ExtractSliceFilterType;
typedef typename ExtractSliceFilterType::SliceType SliceType;
typename ExtractSliceFilterType::Pointer
extractSliceFilter = ExtractSliceFilterType::New();
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::JoinSlices(std::vector<typename itk::Image<typename ImageType::PixelType,
- ImageType::ImageDimension-1>::Pointer > & slices,
- typename ImageType::Pointer input,
- int direction) {
+JoinSlices(std::vector<typename itk::Image<typename ImageType::PixelType,
+ ImageType::ImageDimension-1>::Pointer > & slices,
+ typename ImageType::Pointer input,
+ int direction) {
typedef typename itk::Image<typename ImageType::PixelType, ImageType::ImageDimension-1> SliceType;
typedef itk::JoinSeriesImageFilter<SliceType, ImageType> JoinSeriesFilterType;
typename JoinSeriesFilterType::Pointer joinFilter = JoinSeriesFilterType::New();
//--------------------------------------------------------------------
template<class ImageType>
void
-clitk::PointsUtils<ImageType>::Convert2DTo3D(const PointType2D & p,
- ImagePointer image,
- const int slice,
- PointType3D & p3D)
+PointsUtils<ImageType>::Convert2DTo3D(const PointType2D & p,
+ ImagePointer image,
+ const int slice,
+ PointType3D & p3D)
{
p3D[0] = p[0];
p3D[1] = p[1];
//--------------------------------------------------------------------
template<class ImageType>
void
-clitk::PointsUtils<ImageType>::Convert2DTo3DList(const MapPoint2DType & map,
- ImagePointer image,
- VectorPoint3DType & list)
+PointsUtils<ImageType>::Convert2DTo3DList(const MapPoint2DType & map,
+ ImagePointer image,
+ VectorPoint3DType & list)
{
typename MapPoint2DType::const_iterator iter = map.begin();
while (iter != map.end()) {
//--------------------------------------------------------------------
template<class ImageType>
void
-clitk::WriteListOfLandmarks(std::vector<typename ImageType::PointType> points,
- std::string filename)
+WriteListOfLandmarks(std::vector<typename ImageType::PointType> points,
+ std::string filename)
{
std::ofstream os;
openFileForWriting(os, filename);
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::Dilate(typename ImageType::Pointer image,
- double radiusInMM,
- typename ImageType::PixelType BG,
- typename ImageType::PixelType FG,
- bool extendSupport)
+Dilate(typename ImageType::Pointer image,
+ double radiusInMM,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport)
{
typename ImageType::SizeType r;
for(uint i=0; i<ImageType::ImageDimension; i++)
r[i] = (uint)lrint(radiusInMM/image->GetSpacing()[i]);
- return clitk::Dilate<ImageType>(image, r, BG, FG, extendSupport);
+ return Dilate<ImageType>(image, r, BG, FG, extendSupport);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::Dilate(typename ImageType::Pointer image,
- typename ImageType::PointType radiusInMM,
- typename ImageType::PixelType BG,
- typename ImageType::PixelType FG,
- bool extendSupport)
+Dilate(typename ImageType::Pointer image,
+ typename ImageType::PointType radiusInMM,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport)
{
typename ImageType::SizeType r;
for(uint i=0; i<ImageType::ImageDimension; i++)
r[i] = (uint)lrint(radiusInMM[i]/image->GetSpacing()[i]);
- return clitk::Dilate<ImageType>(image, r, BG, FG, extendSupport);
+ return Dilate<ImageType>(image, r, BG, FG, extendSupport);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class ImageType>
typename ImageType::Pointer
-clitk::Dilate(typename ImageType::Pointer image,
- typename ImageType::SizeType radius,
- typename ImageType::PixelType BG,
- typename ImageType::PixelType FG,
- bool extendSupport)
+Dilate(typename ImageType::Pointer image,
+ typename ImageType::SizeType radius,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport)
{
// Create kernel for dilatation
typedef itk::BinaryBallStructuringElement<typename ImageType::PixelType,
//--------------------------------------------------------------------
template<class ValueType, class VectorType>
-void clitk::ConvertOption(std::string optionName, uint given,
- ValueType * values, VectorType & p,
- uint dim, bool required)
+void ConvertOption(std::string optionName, uint given,
+ ValueType * values, VectorType & p,
+ uint dim, bool required)
{
if (required && (given == 0)) {
clitkExceptionMacro("The option --" << optionName << " must be set and have 1 or "
*/
template<class ImageType>
void
-clitk::SliceBySliceSetBackgroundFromLineSeparation(typename ImageType::Pointer input,
- std::vector<typename ImageType::PointType> & lA,
- std::vector<typename ImageType::PointType> & lB,
- typename ImageType::PixelType BG,
- int mainDirection,
- double offsetToKeep)
+SliceBySliceSetBackgroundFromLineSeparation(typename ImageType::Pointer input,
+ std::vector<typename ImageType::PointType> & lA,
+ std::vector<typename ImageType::PointType> & lB,
+ typename ImageType::PixelType BG,
+ int mainDirection,
+ double offsetToKeep)
{
typedef itk::ImageSliceIteratorWithIndex<ImageType> SliceIteratorType;
}
}
//--------------------------------------------------------------------
+}