@@ -34,7 +34,7 @@ StructurePreservingColorNormalizationFilter<TImage>::StructurePreservingColorNor
3434 , m_ColorIndexSuppressedByEosin(Self::PixelHelper<PixelType>::ColorIndexSuppressedByEosin)
3535{
3636 // The number of colors had better be at least 3 or be unknown
37- // ( which is indicated with the value -1 ).
37+ // (which is indicated with the value -1).
3838 static_assert (2 / PixelHelper<PixelType>::NumberOfColors < 1 , " Images need at least 3 colors" );
3939}
4040
@@ -67,8 +67,8 @@ StructurePreservingColorNormalizationFilter<TImage>::GenerateInputRequestedRegio
6767 // Call the superclass' implementation of this method
6868 Superclass::GenerateInputRequestedRegion ();
6969
70- // Get pointers to the input image ( to be normalized ) and
71- // reference image.
70+ // Get pointers to the input image (to be normalized) and reference
71+ // image.
7272 ImageType * inputImage = const_cast <ImageType *>(this ->GetInput (0 ));
7373 ImageType * referenceImage = const_cast <ImageType *>(this ->GetInput (1 ));
7474
@@ -143,7 +143,7 @@ StructurePreservingColorNormalizationFilter<TImage>::BeforeThreadedGenerateData(
143143 RegionConstIterator refIt{ m_Reference, m_Reference->GetRequestedRegion () };
144144 refIt.GoToBegin ();
145145 itkAssertOrThrowMacro (m_NumberOfColors == refIt.Get ().Size (),
146- " The ( cached ) reference image needs its number of colors to be exactly the same as the "
146+ " The (cached) reference image needs its number of colors to be exactly the same as the "
147147 " input image to be normalized" );
148148 }
149149 }
@@ -155,7 +155,7 @@ StructurePreservingColorNormalizationFilter<TImage>::BeforeThreadedGenerateData(
155155 // we failed
156156 itkAssertOrThrowMacro (
157157 m_Input != nullptr ,
158- " The image to be normalized could not be processed; does it have white, blue, and pink pixels?" )
158+ " The image to be normalized could not be processed; does it have white, blue, and pink pixels?" );
159159 }
160160 m_Input = inputImage;
161161
@@ -178,7 +178,7 @@ StructurePreservingColorNormalizationFilter<TImage>::BeforeThreadedGenerateData(
178178 // we failed
179179 m_Reference = nullptr ;
180180 itkAssertOrThrowMacro (m_Reference != nullptr ,
181- " The reference image could not be processed; does it have white, blue, and pink pixels?" )
181+ " The reference image could not be processed; does it have white, blue, and pink pixels?" );
182182 }
183183 }
184184 m_Reference = referenceImage;
@@ -194,7 +194,6 @@ StructurePreservingColorNormalizationFilter<TImage>::BeforeThreadedGenerateData(
194194 m_ReferenceH.row (0 ) = referenceHOriginal.row (1 );
195195 m_ReferenceH.row (1 ) = referenceHOriginal.row (0 );
196196 }
197-
198197 itkAssertOrThrowMacro ((m_InputH * m_ReferenceH.transpose ()).determinant () > CalcElementType (0 ),
199198 " Hematoxylin and Eosin are getting mixed up; failed" );
200199}
205204StructurePreservingColorNormalizationFilter<TImage>::DynamicThreadedGenerateData(const RegionType & outputRegion)
206205{
207206 ImageType * const outputImage = this ->GetOutput ();
208- itkAssertOrThrowMacro (outputImage != nullptr , " An output image needs to be supplied" )
209- RegionIterator outIt{ outputImage, outputRegion };
207+ itkAssertOrThrowMacro (outputImage != nullptr , " An output image needs to be supplied" );
208+ RegionIterator outIt{ outputImage, outputRegion };
210209
211210 this ->NMFsToImage (m_InputH, m_InputUnstainedPixel, m_ReferenceH, m_ReferenceUnstainedPixel, outIt);
212211}
@@ -254,7 +253,7 @@ StructurePreservingColorNormalizationFilter<TImage>::ImageToNMF(RegionConstItera
254253 }
255254
256255 // Rescale each row of matrixH so that the
257- // ( 100-VeryDarkPercentileLevel ) value of each column of matrixW is
256+ // (100-VeryDarkPercentileLevel) value of each column of matrixW is
258257 // 1.0.
259258 // { std::ostringstream mesg; mesg << "matrixH before NormalizeMatrixH = " << std::endl << matrixH << std::endl;
260259 // std::cout << mesg.str() << std::flush; }
@@ -370,8 +369,8 @@ StructurePreservingColorNormalizationFilter<TImage>::MatrixToDistinguishers(cons
370369{
371370 const CalcMatrixType normVStart{ matrixV };
372371
373- // We will store the row ( pixel ) index of each distinguishing
374- // pixel in firstPassDistinguisherIndices.
372+ // We will store the row (pixel) index of each distinguishing pixel
373+ // in firstPassDistinguisherIndices.
375374 std::array<int , NumberOfStains + 1 > firstPassDistinguisherIndices{ -1 };
376375 SizeValueType numberOfDistinguishers{ 0 };
377376 Self::FirstPassDistinguishers (normVStart, firstPassDistinguisherIndices, numberOfDistinguishers);
@@ -399,7 +398,7 @@ StructurePreservingColorNormalizationFilter<TImage>::FirstPassDistinguishers(
399398 bool needToRecenterMatrix = true ;
400399 while (numberOfDistinguishers <= NumberOfStains)
401400 {
402- // Find the next distinguishing row ( pixel )
401+ // Find the next distinguishing row (pixel)
403402 firstPassDistinguisherIndices[numberOfDistinguishers] = Self::MatrixToOneDistinguisher (normV);
404403 // If we found a distinguisher and we have not yet found
405404 // NumberOfStains+1 of them, then look for the next distinguisher.
@@ -462,8 +461,8 @@ StructurePreservingColorNormalizationFilter<TImage>::SecondPassDistinguishers(
462461 // We have sent all distinguishers except self to the origin.
463462 // Whatever is far from the origin in the same direction as self
464463 // is a good replacement for self. We will take an average among
465- // those that are at least 80% as far as the best. ( Note that
466- // self could still be best, but not always. )
464+ // those that are at least 80% as far as the best. (Note that
465+ // self could still be best, but not always.)
467466 const CalcColVectorType dotProducts{ normV * normV.row (firstPassDistinguisherIndices[distinguisher]).transpose () };
468467 const CalcElementType threshold{ *std::max_element (Self::cbegin (dotProducts), Self::cend (dotProducts)) *
469468 SecondPassDistinguishersThreshold };
@@ -571,9 +570,9 @@ StructurePreservingColorNormalizationFilter<TImage>::DistinguishersToColors(Calc
571570 SizeValueType & hematoxylinIndex,
572571 SizeValueType & eosinIndex) const
573572{
574- // Figure out which, distinguishers are unstained ( highest
575- // brightness ), hematoxylin ( suppresses red ), and eosin (
576- // suppresses green ).
573+ // Figure out which, distinguishers are unstained (highest
574+ // brightness), hematoxylin (suppresses red), and eosin (suppresses
575+ // green).
577576 const CalcColVectorType lengths2{ distinguishers.rowwise ().squaredNorm () };
578577 const CalcElementType * const unstainedIterator{ std::max_element (Self::cbegin (lengths2), Self::cend (lengths2)) };
579578 unstainedIndex = std::distance (Self::cbegin (lengths2), unstainedIterator);
@@ -601,8 +600,8 @@ StructurePreservingColorNormalizationFilter<TImage>::NormalizeMatrixH(const Calc
601600 const CalcColVectorType firstOnes{ CalcColVectorType::Constant (matrixDarkVIn.rows (), 1 , 1.0 ) };
602601
603602 // Compute the VeryDarkPercentileLevel percentile of a stain's
604- // negative( matrixW ) column. This a dark value due to its being the
605- // ( 100 - VeryDarkPercentileLevel ) among quantities of stain.
603+ // negative(matrixW) column. This a dark value due to its being the
604+ // (100 - VeryDarkPercentileLevel) among quantities of stain.
606605 CalcRowVectorType logUnstainedCalcPixel = unstainedPixel.unaryExpr (CalcUnaryFunctionPointer (std::log));
607606 CalcMatrixType matrixDarkV{ matrixDarkVIn };
608607 matrixDarkV = (firstOnes * logUnstainedCalcPixel) - matrixDarkV.unaryExpr (CalcUnaryFunctionPointer (std::log));
@@ -836,8 +835,8 @@ StructurePreservingColorNormalizationFilter<TImage>::end(
836835{
837836 itkAssertOrThrowMacro (std::distance (matrix.data (), &matrix (matrix.rows () - 1 , matrix.cols () - 1 )) + 1 ==
838837 matrix.size (),
839- " Bad array stepping" ) return matrix. data () +
840- matrix.size ();
838+ " Bad array stepping" );
839+ return matrix. data () + matrix.size ();
841840}
842841
843842template <typename TImage>
@@ -848,8 +847,8 @@ StructurePreservingColorNormalizationFilter<TImage>::cend(
848847{
849848 itkAssertOrThrowMacro (std::distance (matrix.data (), &matrix (matrix.rows () - 1 , matrix.cols () - 1 )) + 1 ==
850849 matrix.size (),
851- " Bad array stepping" ) return matrix. data () +
852- matrix.size ();
850+ " Bad array stepping" );
851+ return matrix. data () + matrix.size ();
853852}
854853
855854#else
@@ -876,8 +875,8 @@ StructurePreservingColorNormalizationFilter<TImage>::end(TMatrix & matrix)
876875{
877876 itkAssertOrThrowMacro (std::distance (matrix.data (), &matrix (matrix.rows () - 1 , matrix.cols () - 1 )) + 1 ==
878877 matrix.size (),
879- " Bad array stepping" ) return matrix. data () +
880- matrix.size ();
878+ " Bad array stepping" );
879+ return matrix. data () + matrix.size ();
881880}
882881
883882template <typename TImage>
@@ -887,8 +886,8 @@ StructurePreservingColorNormalizationFilter<TImage>::cend(const TMatrix & matrix
887886{
888887 itkAssertOrThrowMacro (std::distance (matrix.data (), &matrix (matrix.rows () - 1 , matrix.cols () - 1 )) + 1 ==
889888 matrix.size (),
890- " Bad array stepping" ) return matrix. data () +
891- matrix.size ();
889+ " Bad array stepping" );
890+ return matrix. data () + matrix.size ();
892891}
893892#endif
894893
0 commit comments