ITK  6.0.0
Insight Toolkit
itkVectorConnectedComponentImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkVectorConnectedComponentImageFilter_h
29#define itkVectorConnectedComponentImageFilter_h
30
31#include "itkMath.h"
32#include "itkNumericTraits.h"
34
35namespace itk
36{
37namespace Functor
38{
50template <typename TInput>
52{
53public:
55
57
58 void
59 SetDistanceThreshold(const typename TInput::ValueType & thresh)
60 {
61 m_Threshold = thresh;
62 }
63 typename TInput::ValueType
65 {
66 return (m_Threshold);
67 }
68
69 bool
71 {
72 return true;
73 }
74
76
77 bool
78 operator()(const TInput & a, const TInput & b) const
79 {
80 using RealValueType = typename NumericTraits<typename TInput::ValueType>::RealType;
81 RealValueType dotProduct{};
82 for (unsigned int i = 0; i < NumericTraits<TInput>::GetLength(a); ++i)
83 {
84 dotProduct += a[i] * b[i];
85 }
86 return (static_cast<typename TInput::ValueType>(1.0 - itk::Math::abs(dotProduct)) <= m_Threshold);
87 }
88
89protected:
90 typename TInput::ValueType m_Threshold{};
91};
92} // end namespace Functor
93
104template <typename TInputImage, typename TOutputImage, typename TMaskImage = TInputImage>
106 : public ConnectedComponentFunctorImageFilter<TInputImage,
107 TOutputImage,
108 Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
109 TMaskImage>
110{
111public:
112 ITK_DISALLOW_COPY_AND_MOVE(VectorConnectedComponentImageFilter);
113
118 TOutputImage,
120 TMaskImage>;
123
125 itkNewMacro(Self);
126
128 itkOverrideGetNameOfClassMacro(VectorConnectedComponentImageFilter);
129
130 using InputValueType = typename TInputImage::PixelType::ValueType;
131
132 virtual void
134 {
135 this->GetFunctor().SetDistanceThreshold(thresh);
136 }
137
138 virtual InputValueType
140 {
141 return (this->GetFunctor().GetDistanceThreshold());
142 }
143
144#ifdef ITK_USE_CONCEPT_CHECKING
145 // Begin concept checking
146 itkConceptMacro(InputValueHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
147 itkConceptMacro(InputValyeTypeIsFloatingCheck, (Concept::IsFloatingPoint<InputValueType>));
148 // End concept checking
149#endif
150
151protected:
154};
155} // end namespace itk
156
157#endif
A generic connected components filter that labels the objects in an arbitrary image.
A connected components filter that labels the objects in a vector image. Two vectors are pointing sim...
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SimilarVectorsFunctor)
bool operator==(const SimilarVectorsFunctor &) const
bool operator()(const TInput &a, const TInput &b) const
void SetDistanceThreshold(const typename TInput::ValueType &thresh)
Base class for all process objects that output image data.
Define additional traits for native types such as int or float.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
A connected components filter that labels the objects in a vector image. Two vectors are pointing sim...
typename TInputImage::PixelType::ValueType InputValueType
virtual void SetDistanceThreshold(const InputValueType &thresh)
~VectorConnectedComponentImageFilter() override=default
#define itkConceptMacro(name, concept)
bool abs(bool x)
Definition: itkMath.h:840
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....