Skip to content

Commit

Permalink
STYLE: Removed HoughTransform2DCircles default for TRadiusPixelType
Browse files Browse the repository at this point in the history
ITK 4.13 introduced TRadiusPixelType as an extra template parameter
of HoughTransform2DCirclesImageFilter. It had a default argument,
TRadiusPixelType = TOutputPixelType, for ITK4 backward compatibility.
Unfortunately, this default argument is often not the right choice.
For OutputPixelType, an unsigned integer is often preferable, whereas
for RadiusPixelType, a floating point type is often a better choice.

This commit removes the default argument from TRadiusPixelType,
hoping to trigger ITK users to make the most appropriate choice.

Change-Id: I34d8b543815192700ad01c04d9c37df256ae2639
  • Loading branch information
N-Dekker committed Jun 10, 2018
1 parent cac14a7 commit 06afe0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ int main( int argc, char *argv[] )

// Software Guide : BeginCodeSnippet
using PixelType = unsigned char;
using AccumulatorPixelType = float;
using AccumulatorPixelType = unsigned;
using RadiusPixelType = float;
constexpr unsigned int Dimension = 2;
using ImageType = itk::Image< PixelType, Dimension >;
ImageType::IndexType localIndex;
Expand Down Expand Up @@ -113,7 +114,8 @@ int main( int argc, char *argv[] )

using HoughTransformFilterType =
itk::HoughTransform2DCirclesImageFilter<PixelType,
AccumulatorPixelType>;
AccumulatorPixelType,
RadiusPixelType>;
HoughTransformFilterType::Pointer houghFilter
= HoughTransformFilterType::New();
// Software Guide : EndCodeSnippet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ namespace itk
* is recommended, as the estimation of the radius involves floating point
* calculations. Usually, 'double' is the best choice for this pixel type.
*
* By default, TRadiusPixelType = TOutputPixelType, in order to preserve backward
* compatibility with ITK <= 4.12.2.
*
* \ingroup ImageFeatureExtraction
*
* \ingroup ITKImageFeature
*/

template< typename TInputPixelType, typename TOutputPixelType, typename TRadiusPixelType = TOutputPixelType >
template< typename TInputPixelType, typename TOutputPixelType, typename TRadiusPixelType >
class ITK_TEMPLATE_EXPORT HoughTransform2DCirclesImageFilter:
public ImageToImageFilter< Image< TInputPixelType, 2 >, Image< TOutputPixelType, 2 > >
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace
constexpr double radius = 7.0;
CreateCircle<ImageType>(image, center, radius);

using FilterType = itk::HoughTransform2DCirclesImageFilter< PixelType, PixelType >;
using FilterType = itk::HoughTransform2DCirclesImageFilter< PixelType, PixelType, PixelType>;

const FilterType::Pointer filter = FilterType::New();

Expand All @@ -84,7 +84,7 @@ namespace

using ImageType = itk::Image<PixelType>;

using FilterType = itk::HoughTransform2DCirclesImageFilter< PixelType, PixelType >;
using FilterType = itk::HoughTransform2DCirclesImageFilter< PixelType, PixelType, PixelType >;

const FilterType::Pointer filter = FilterType::New();

Expand Down Expand Up @@ -136,9 +136,8 @@ namespace

using OutputPixelType = unsigned long;

// By default, the radius image has the same type as the output image (the accumulator image).
// FilterType2 has 'double' as radius pixel type, allowing a slightly more accurate radius estimation.
using FilterType1 = itk::HoughTransform2DCirclesImageFilter< InputPixelType, OutputPixelType >;
using FilterType1 = itk::HoughTransform2DCirclesImageFilter< InputPixelType, OutputPixelType, unsigned long >;
using FilterType2 = itk::HoughTransform2DCirclesImageFilter< InputPixelType, OutputPixelType, double >;

const FilterType1::Pointer filter1 = FilterType1::New();
Expand Down Expand Up @@ -356,7 +355,7 @@ int itkHoughTransform2DCirclesImageTest( int, char* [] )

// Define the HoughTransform filter
using HoughTransformFilterType = itk::HoughTransform2DCirclesImageFilter< HoughSpacePixelType,
HoughSpacePixelType >;
HoughSpacePixelType, HoughSpacePixelType >;

HoughTransformFilterType::Pointer houghFilter = HoughTransformFilterType::New();

Expand Down

0 comments on commit 06afe0f

Please sign in to comment.