Skip to content

Commit 37e67ec

Browse files
Lee NewbergLeengit
authored andcommitted
STYLE: Add additional type safety
1 parent c97b165 commit 37e67ec

File tree

3 files changed

+98
-96
lines changed

3 files changed

+98
-96
lines changed

include/itkStructurePreservingColorNormalizationFilter.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter<TI
164164
{
165165
using PixelType = TPixelType;
166166
using ValueType = typename PixelType::ValueType;
167-
static constexpr SizeValueType NumberOfDimensions = -1;
168-
static constexpr SizeValueType NumberOfColors = -1;
169-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = -1;
170-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = -1;
167+
static constexpr SizeValueType NumberOfDimensions = -1; // unsigned int value!
168+
static constexpr SizeValueType NumberOfColors = -1; // unsigned int value!
169+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ -1 };
170+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ -1 };
171171
static PixelType
172-
pixelInstance(unsigned numberOfDimensions)
172+
pixelInstance(unsigned int numberOfDimensions)
173173
{
174-
return PixelType{ numberOfDimensions };
174+
return PixelType(numberOfDimensions);
175175
}
176176
};
177177
// For the case that the number of colors is implicitly set to 1 at
@@ -183,12 +183,12 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter<TI
183183
{
184184
using PixelType = TPixelType;
185185
using ValueType = PixelType;
186-
static constexpr SizeValueType NumberOfDimensions = 1;
187-
static constexpr SizeValueType NumberOfColors = 1;
188-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = -1;
189-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = -1;
186+
static constexpr SizeValueType NumberOfDimensions{ 1 };
187+
static constexpr SizeValueType NumberOfColors{ 1 };
188+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ -1 };
189+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ -1 };
190190
static PixelType
191-
pixelInstance(unsigned numberOfDimensions)
191+
pixelInstance(unsigned int numberOfDimensions)
192192
{
193193
return PixelType{};
194194
}
@@ -199,12 +199,12 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter<TI
199199
{
200200
using PixelType = RGBPixel<TScalar>;
201201
using ValueType = typename PixelType::ValueType;
202-
static constexpr SizeValueType NumberOfDimensions = 3;
203-
static constexpr SizeValueType NumberOfColors = 3;
204-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = 0;
205-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = 1;
202+
static constexpr SizeValueType NumberOfDimensions{ 3 };
203+
static constexpr SizeValueType NumberOfColors{ 3 };
204+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ 0 };
205+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ 1 };
206206
static PixelType
207-
pixelInstance(unsigned numberOfDimensions)
207+
pixelInstance(unsigned int numberOfDimensions)
208208
{
209209
return PixelType{};
210210
}
@@ -215,12 +215,12 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter<TI
215215
{
216216
using PixelType = RGBAPixel<TScalar>;
217217
using ValueType = typename PixelType::ValueType;
218-
static constexpr SizeValueType NumberOfDimensions = 4;
219-
static constexpr SizeValueType NumberOfColors = 3;
220-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = 0;
221-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = 1;
218+
static constexpr SizeValueType NumberOfDimensions{ 4 };
219+
static constexpr SizeValueType NumberOfColors{ 3 };
220+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ 0 };
221+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ 1 };
222222
static PixelType
223-
pixelInstance(unsigned numberOfDimensions)
223+
pixelInstance(unsigned int numberOfDimensions)
224224
{
225225
return PixelType{};
226226
}
@@ -229,32 +229,32 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter<TI
229229
// CovariantVector. If NVectorDimension is not at least 3 we
230230
// will refuse to compile this case via a static_assert in the
231231
// constructor of StructurePreservingColorNormalizationFilter.
232-
template <typename TScalar, unsigned int NVectorDimension>
232+
template <typename TScalar, SizeValueType NVectorDimension>
233233
struct PixelHelper<Vector<TScalar, NVectorDimension>, void>
234234
{
235235
using PixelType = Vector<TScalar, NVectorDimension>;
236236
using ValueType = typename PixelType::ValueType;
237-
static constexpr SizeValueType NumberOfDimensions = NVectorDimension;
238-
static constexpr SizeValueType NumberOfColors = NVectorDimension;
239-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = -1;
240-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = -1;
237+
static constexpr SizeValueType NumberOfDimensions{ NVectorDimension };
238+
static constexpr SizeValueType NumberOfColors{ NVectorDimension };
239+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ -1 };
240+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ -1 };
241241
static PixelType
242-
pixelInstance(unsigned numberOfDimensions)
242+
pixelInstance(unsigned int numberOfDimensions)
243243
{
244244
return PixelType{};
245245
}
246246
};
247-
template <typename TScalar, unsigned int NVectorDimension>
247+
template <typename TScalar, SizeValueType NVectorDimension>
248248
struct PixelHelper<CovariantVector<TScalar, NVectorDimension>, void>
249249
{
250250
using PixelType = CovariantVector<TScalar, NVectorDimension>;
251251
using ValueType = typename PixelType::ValueType;
252-
static constexpr SizeValueType NumberOfDimensions = NVectorDimension;
253-
static constexpr SizeValueType NumberOfColors = NVectorDimension;
254-
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin = -1;
255-
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin = -1;
252+
static constexpr SizeValueType NumberOfDimensions{ NVectorDimension };
253+
static constexpr SizeValueType NumberOfColors{ NVectorDimension };
254+
static constexpr typename Eigen::Index ColorIndexSuppressedByHematoxylin{ -1 };
255+
static constexpr typename Eigen::Index ColorIndexSuppressedByEosin{ -1 };
256256
static PixelType
257-
pixelInstance(unsigned numberOfDimensions)
257+
pixelInstance(unsigned int numberOfDimensions)
258258
{
259259
return PixelType{};
260260
}

0 commit comments

Comments
 (0)