Skip to content

Commit

Permalink
STYLE: Apply clang format styling
Browse files Browse the repository at this point in the history
  • Loading branch information
blowekamp committed Mar 16, 2020
1 parent d67058d commit d8fac5c
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 257 deletions.
38 changes: 18 additions & 20 deletions include/itkHessianImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ namespace itk
* \ingroup SimpleITKFilters
*/
template <typename TInputImage,
typename TOutputImage = Image< SymmetricSecondRankTensor<
typename NumericTraits< typename TInputImage::PixelType >::RealType,
TInputImage::ImageDimension >,
TInputImage::ImageDimension > >
class HessianImageFilter :
public ImageToImageFilter< TInputImage, TOutputImage>
typename TOutputImage =
Image<SymmetricSecondRankTensor<typename NumericTraits<typename TInputImage::PixelType>::RealType,
TInputImage::ImageDimension>,
TInputImage::ImageDimension>>
class HessianImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(HessianImageFilter);

/** Standard type alias */
using Self = HessianImageFilter;
using Superclass = ImageToImageFilter<TInputImage,TOutputImage>;
using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

Expand All @@ -62,41 +61,40 @@ class HessianImageFilter :

/** Type of the output Image */
using OutputImageType = TOutputImage;
using OutputPixelType = typename OutputImageType::PixelType;
using OutputPixelType = typename OutputImageType::PixelType;
using OutputImageRegionType = typename OutputImageType::RegionType;


/** Run-time type information (and related methods). */
itkTypeMacro( HessianImageFilter, ImageToImageFilter );
/** Run-time type information (and related methods). */
itkTypeMacro(HessianImageFilter, ImageToImageFilter);

/** Method for creation through the object factory. */
itkNewMacro(Self);

void GenerateInputRequestedRegion() override;
void
GenerateInputRequestedRegion() override;


#ifdef ITK_USE_CONCEPT_CHECKING
/** Begin concept checking */
itkConceptMacro(InputHasNumericTraitsCheck,
(Concept::HasNumericTraits<PixelType>));
itkConceptMacro(OutputHasPixelTraitsCheck,
(Concept::HasPixelTraits<OutputPixelType>));
itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<PixelType>));
itkConceptMacro(OutputHasPixelTraitsCheck, (Concept::HasPixelTraits<OutputPixelType>));
/** End concept checking */
#endif

protected:
HessianImageFilter(void);

HessianImageFilter( void );

void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
void
DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
};

} // end namespace itk


#ifndef ITK_MANUAL_INSTANTIATION
#include "itkHessianImageFilter.hxx"
# include "itkHessianImageFilter.hxx"
#endif


#endif //itkHessianImageFilter_h
#endif // itkHessianImageFilter_h
111 changes: 52 additions & 59 deletions include/itkHessianImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,30 @@ namespace itk
* Constructor
*/

template <typename TInputImage, typename TOutputImage >
HessianImageFilter<TInputImage,TOutputImage>
::HessianImageFilter( void )
template <typename TInputImage, typename TOutputImage>
HessianImageFilter<TInputImage, TOutputImage>::HessianImageFilter(void)
{
this->DynamicMultiThreadingOn();
}

/**
* Enlarge Input Requested Region
*/
template< class TInputImage, class TOutputImage >
template <class TInputImage, class TOutputImage>
void
HessianImageFilter< TInputImage, TOutputImage >
::GenerateInputRequestedRegion()
HessianImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()
{
// call the superclass' implementation of this method. this should
// copy the output requested region to the input requested region
Superclass::GenerateInputRequestedRegion();

// get pointers to the input and output
typename InputImageType::Pointer inputPtr =
const_cast< TInputImage * >( this->GetInput() );
typename InputImageType::Pointer inputPtr = const_cast<TInputImage *>(this->GetInput());

if ( !inputPtr )
{
if (!inputPtr)
{
return;
}
}


// the hessaion just needs a 1 radius neighborhood
Expand All @@ -70,16 +67,16 @@ HessianImageFilter< TInputImage, TOutputImage >
inputRequestedRegion = inputPtr->GetRequestedRegion();

// pad the input requested region by the operator radius
inputRequestedRegion.PadByRadius( radius );
inputRequestedRegion.PadByRadius(radius);

// crop the input requested region at the input's largest possible region
if ( inputRequestedRegion.Crop( inputPtr->GetLargestPossibleRegion() ) )
{
if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
{
inputPtr->SetRequestedRegion(inputRequestedRegion);
return;
}
}
else
{
{
// Couldn't crop the region (requested region is outside the largest
// possible region). Throw an exception.

Expand All @@ -92,95 +89,91 @@ HessianImageFilter< TInputImage, TOutputImage >
e.SetDescription("Requested region is (at least partially) outside the largest possible region.");
e.SetDataObject(inputPtr);
throw e;
}
}
}

/**
* Threaded Data Generation
*/
template <typename TInputImage, typename TOutputImage >
template <typename TInputImage, typename TOutputImage>
void
HessianImageFilter<TInputImage,TOutputImage>
::DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread)
HessianImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
const OutputImageRegionType & outputRegionForThread)
{
const TInputImage *input = this->GetInput();
const TInputImage * input = this->GetInput();

const unsigned int ImageDimension = TInputImage::ImageDimension;

TOutputImage *output = this->GetOutput();
TOutputImage * output = this->GetOutput();


using HessianType = typename OutputImageType::PixelType;
ImageRegionIterator<OutputImageType> oit;

itk::Size<ImageDimension> radius;
radius.Fill( 1 );
radius.Fill(1);
unsigned long center;
unsigned long stride[ImageDimension];

typename TInputImage::SpacingType spacing = input->GetSpacing();


// compute the boundary faces of our region
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< TInputImage >::FaceListType faceList;
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< TInputImage > bC;
faceList = bC( input, outputRegionForThread, radius );
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType faceList;
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
faceList = bC(input, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< TInputImage >::FaceListType::iterator fit;
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;

using NeighborhoodType = ConstNeighborhoodIterator< TInputImage >;
using NeighborhoodType = ConstNeighborhoodIterator<TInputImage>;

// get center and dimension strides for iterator neighborhoods
NeighborhoodType it( radius, input, *faceList.begin() );
center = it.Size()/2;
for ( unsigned int i = 0; i < ImageDimension; ++i )
{
NeighborhoodType it(radius, input, *faceList.begin());
center = it.Size() / 2;
for (unsigned int i = 0; i < ImageDimension; ++i)
{
stride[i] = it.GetStride(i);
}
}

// process each of the region "faces"
for ( fit = faceList.begin(); fit != faceList.end(); ++fit )
{
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
{
// set up the iterator for the "face" and let the automatic
// boundary condition detection work as needed
it = NeighborhoodType( radius, input, *fit);
it = NeighborhoodType(radius, input, *fit);

oit = ImageRegionIterator<OutputImageType>( output, *fit );
oit = ImageRegionIterator<OutputImageType>(output, *fit);

while ( !it.IsAtEnd() )
{
while (!it.IsAtEnd())
{
// symetric hessian
HessianType H;


//Calculate 2nd order derivative on the diaganal
for ( unsigned int i = 0; i < ImageDimension; i++ )
{
H(i,i) = it.GetPixel(center + stride[i]) + it.GetPixel(center - stride[i])
- 2.0 * it.GetPixel(center);
H(i,i) /= spacing[i] * spacing[i];
}
// Calculate 2nd order derivative on the diaganal
for (unsigned int i = 0; i < ImageDimension; i++)
{
H(i, i) = it.GetPixel(center + stride[i]) + it.GetPixel(center - stride[i]) - 2.0 * it.GetPixel(center);
H(i, i) /= spacing[i] * spacing[i];
}

//Calculate the 2nd derivatives
for ( unsigned int i = 0; i < ImageDimension - 1; i++ )
// Calculate the 2nd derivatives
for (unsigned int i = 0; i < ImageDimension - 1; i++)
{
for (unsigned int j = i + 1; j < ImageDimension; j++)
{
for ( unsigned int j = i + 1; j < ImageDimension; j++ )
{
H(i,j) = ( it.GetPixel(center - stride[i] - stride[j])
- it.GetPixel(center - stride[i] + stride[j])
- it.GetPixel(center + stride[i] - stride[j])
+ it.GetPixel(center + stride[i] + stride[j])
) / ( 4.0 * spacing[i] * spacing[j] );
}
H(i, j) = (it.GetPixel(center - stride[i] - stride[j]) - it.GetPixel(center - stride[i] + stride[j]) -
it.GetPixel(center + stride[i] - stride[j]) + it.GetPixel(center + stride[i] + stride[j])) /
(4.0 * spacing[i] * spacing[j]);
}
}

oit.Set( H );
oit.Set(H);

++oit;
++it;
}
}

}
}

} // end namespace itk
Expand Down
31 changes: 15 additions & 16 deletions include/itkObjectnessMeasureImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ namespace itk
* \f[
* V_{\sigma}=
* \begin{cases}
* (1-e^{-\frac{R_A^2}{2\alpha^2}}) \cdot e^{\frac{R_B^2}{2\beta^2}} \cdot (1-e^{-\frac{S^2}{2\gamma^2}}) & \text{if } \lambda_2<0 \text{ and } \lambda_3<0 \text{,}\\
* 0 & \text{otherwise}
* \end{cases}
* \f]
* (1-e^{-\frac{R_A^2}{2\alpha^2}}) \cdot e^{\frac{R_B^2}{2\beta^2}} \cdot (1-e^{-\frac{S^2}{2\gamma^2}}) &
* \text{if } \lambda_2<0 \text{ and } \lambda_3<0 \text{,}\\ 0 & \text{otherwise} \end{cases} \f]
*
* \par References
* Antiga, L. Generalizing vesselness with respect to dimensionality and shape. https://hdl.handle.net/1926/576
Expand All @@ -72,20 +70,19 @@ namespace itk
*
* \ingroup SimpleITKFilters
*/
template< typename TInputImage, typename TOutputImage >
class ObjectnessMeasureImageFilter
: public ImageToImageFilter< TInputImage, TOutputImage >
template <typename TInputImage, typename TOutputImage>
class ObjectnessMeasureImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(ObjectnessMeasureImageFilter);

/** Standard class type alias. */
using Self = ObjectnessMeasureImageFilter;

using Superclass = ImageToImageFilter< TInputImage, TOutputImage >;
using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;

using Pointer = SmartPointer< Self >;
using ConstPointer = SmartPointer< const Self >;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

using InputImageType = typename Superclass::InputImageType;
using OutputImageType = typename Superclass::OutputImageType;
Expand Down Expand Up @@ -145,11 +142,14 @@ class ObjectnessMeasureImageFilter
~ObjectnessMeasureImageFilter() override;


void EnlargeOutputRequestedRegion(DataObject *output) override;
void
EnlargeOutputRequestedRegion(DataObject * output) override;

void GenerateData() override;
void
GenerateData() override;

void PrintSelf(std::ostream & os, Indent indent) const override;
void
PrintSelf(std::ostream & os, Indent indent) const override;

private:
double m_Alpha;
Expand All @@ -158,14 +158,13 @@ class ObjectnessMeasureImageFilter
unsigned int m_ObjectDimension;
bool m_BrightObject;
bool m_ScaleObjectnessMeasure;

};

}
} // namespace itk


#ifndef ITK_MANUAL_INSTANTIATION
#include "itkObjectnessMeasureImageFilter.hxx"
# include "itkObjectnessMeasureImageFilter.hxx"
#endif

#endif // itkObjectnessMeasureImageFilter_h
Loading

0 comments on commit d8fac5c

Please sign in to comment.