Commit ede8e778 authored by Antoine Regimbeau's avatar Antoine Regimbeau
Browse files

REFAC: rm cast and change some types

parent c42d1436
...@@ -90,11 +90,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -90,11 +90,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunEmphasisOutput() ::GetShortRunEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 1) this->GetOutput(0);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(0));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -103,11 +99,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -103,11 +99,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunEmphasisOutput() ::GetLongRunEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 2) this->GetOutput(1);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(1));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -116,11 +108,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -116,11 +108,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetGreyLevelNonuniformityOutput() ::GetGreyLevelNonuniformityOutput()
{ {
if (this->GetNumberOfOutputs() < 3) this->GetOutput(2);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(2));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -129,11 +117,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -129,11 +117,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetRunLengthNonuniformityOutput() ::GetRunLengthNonuniformityOutput()
{ {
if (this->GetNumberOfOutputs() < 4) this->GetOutput(3);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(3));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -142,11 +126,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -142,11 +126,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLowGreyLevelRunEmphasisOutput() ::GetLowGreyLevelRunEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 5) this->GetOutput(4);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(4));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -155,11 +135,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -155,11 +135,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetHighGreyLevelRunEmphasisOutput() ::GetHighGreyLevelRunEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 6) this->GetOutput(5);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(5));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -168,11 +144,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -168,11 +144,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunLowGreyLevelEmphasisOutput() ::GetShortRunLowGreyLevelEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 7) this->GetOutput(6);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(6));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -181,11 +153,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -181,11 +153,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunHighGreyLevelEmphasisOutput() ::GetShortRunHighGreyLevelEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 8) this->GetOutput(7);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(7));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -194,11 +162,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -194,11 +162,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunLowGreyLevelEmphasisOutput() ::GetLongRunLowGreyLevelEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 9) this->GetOutput(8);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(8));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -207,11 +171,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -207,11 +171,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunHighGreyLevelEmphasisOutput() ::GetLongRunHighGreyLevelEmphasisOutput()
{ {
if (this->GetNumberOfOutputs() < 10) this->GetOutput(9);
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(9));
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -229,27 +189,26 @@ void ...@@ -229,27 +189,26 @@ void
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GenerateOutputInformation() ::GenerateOutputInformation()
{ {
// First, call superclass implementation
Superclass::GenerateOutputInformation();
// Compute output size, origin & spacing // Compute output size, origin & spacing
InputRegionType inputRegion = this->GetInput()->GetLargestPossibleRegion(); const InputImageType * inputPtr = this->GetInput();
InputRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
OutputRegionType outputRegion; OutputRegionType outputRegion;
outputRegion.SetIndex(0,0); outputRegion.SetIndex(0,0);
outputRegion.SetIndex(1,0); outputRegion.SetIndex(1,0);
outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]);
outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]);
typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSignedSpacing(); typename OutputImageType::SpacingType outSpacing = inputPtr->GetSignedSpacing();
outSpacing[0] *= m_SubsampleFactor[0]; outSpacing[0] *= m_SubsampleFactor[0];
outSpacing[1] *= m_SubsampleFactor[1]; outSpacing[1] *= m_SubsampleFactor[1];
typename OutputImageType::PointType outOrigin; typename OutputImageType::PointType outOrigin;
this->GetInput()->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin); inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin);
for (unsigned int i=0 ; i < this->GetNumberOfOutputs() ; i++) for (unsigned int i=0 ; i < this->GetNumberOfOutputs() ; i++)
{ {
OutputImagePointerType outputPtr = this->GetOutput(i); OutputImagePointerType outputPtr = this->GetOutput(i);
outputPtr->CopyInformation(inputPtr);
outputPtr->SetLargestPossibleRegion(outputRegion); outputPtr->SetLargestPossibleRegion(outputRegion);
outputPtr->SetOrigin(outOrigin); outputPtr->SetOrigin(outOrigin);
outputPtr->SetSignedSpacing(outSpacing); outputPtr->SetSignedSpacing(outSpacing);
...@@ -315,7 +274,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -315,7 +274,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId) ::ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId)
{ {
// Retrieve the input and output pointers // Retrieve the input and output pointers
InputImagePointerType inputPtr = const_cast<InputImageType *>(this->GetInput()); const InputImageType * inputPtr = this->GetInput();
typedef typename itk::ImageRegionIterator<OutputImageType> IteratorType; typedef typename itk::ImageRegionIterator<OutputImageType> IteratorType;
std::vector<IteratorType> outputImagesIterators; std::vector<IteratorType> outputImagesIterators;
...@@ -368,7 +327,8 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> ...@@ -368,7 +327,8 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
localInputImage->SetRegions(inputRegion); localInputImage->SetRegions(inputRegion);
localInputImage->Allocate(); localInputImage->Allocate();
typedef itk::ImageRegionIteratorWithIndex<InputImageType> ImageRegionIteratorType; typedef itk::ImageRegionIteratorWithIndex<InputImageType> ImageRegionIteratorType;
ImageRegionIteratorType itInputPtr(inputPtr, inputRegion); typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> ImageRegionConstIteratorType;
ImageRegionConstIteratorType itInputPtr(inputPtr, inputRegion);
ImageRegionIteratorType itLocalInputImage(localInputImage, inputRegion); ImageRegionIteratorType itLocalInputImage(localInputImage, inputRegion);
for (itInputPtr.GoToBegin(), itLocalInputImage.GoToBegin(); for (itInputPtr.GoToBegin(), itLocalInputImage.GoToBegin();
!itInputPtr.IsAtEnd(); !itInputPtr.IsAtEnd();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment