21 #ifndef __otbWaveletFilterBank_txx
22 #define __otbWaveletFilterBank_txx
43 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
47 this->SetNumberOfRequiredInputs(1);
48 this->SetNumberOfInputs(1);
50 unsigned int numOfOutputs = 1 << InputImageDimension;
52 this->SetNumberOfOutputs(numOfOutputs);
53 for (
unsigned int i = 0; i < numOfOutputs; ++i)
55 this->SetNthOutput(i, OutputImageType::New());
58 m_UpSampleFilterFactor = 0;
59 m_SubsampleImageFactor = 1;
64 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
69 Superclass::GenerateOutputInformation();
71 if (GetSubsampleImageFactor() == 1)
return;
76 <<
"," << this->GetInput()->GetLargestPossibleRegion().GetSize()[1]);
80 this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput()->GetLargestPossibleRegion());
82 for (
unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i)
84 this->GetOutput(i)->SetRegions(newRegion);
92 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
96 throw (itk::InvalidRequestedRegionError)
98 Superclass::GenerateInputRequestedRegion();
102 lowPassOperator.SetDirection(0);
103 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
104 lowPassOperator.CreateDirectional();
106 unsigned int radius = lowPassOperator.GetRadius()[0];
109 highPassOperator.SetDirection(0);
110 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
111 highPassOperator.CreateDirectional();
113 if (radius < highPassOperator.GetRadius()[0]) radius = highPassOperator.GetRadius()[0];
118 inputRegion.PadByRadius(radius);
120 if (inputRegion.Crop(input->GetLargestPossibleRegion()))
122 input->SetRequestedRegion(inputRegion);
126 input->SetRequestedRegion(inputRegion);
129 err.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
135 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
140 if (m_SubsampleImageFactor > 1)
143 for (
unsigned int i = 0; i < InputImageDimension; ++i)
145 if ((m_SubsampleImageFactor
146 * (this->GetInput()->GetRequestedRegion().GetSize()[i] / m_SubsampleImageFactor))
147 != this->GetInput()->GetRequestedRegion().GetSize()[i])
151 err.
SetDescription(
"Requested region dimension cannot be used in multiresolution analysis (crop it).");
152 err.
SetDataObject(const_cast<InputImageType*>(this->GetInput()));
157 if (InputImageDimension > 1)
160 m_InternalImages.resize(InputImageDimension - 1);
161 for (
unsigned int i = 0; i < m_InternalImages.size(); ++i)
164 m_InternalImages[InputImageDimension - 2 - i].resize(1 << (i + 1));
168 this->Superclass::CallCopyInputRegionToOutputRegion(intermediateRegion,
169 this->GetInput()->GetLargestPossibleRegion());
171 AllocateInternalData(intermediateRegion);
176 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
185 for (
unsigned int direction = 0; direction < InputImageDimension - 1; direction++)
187 this->CallCopyInputRegionToOutputRegion(InputImageDimension - 1 - direction,
188 smallerRegion, largerRegion);
190 for (
unsigned int i = 0; i < m_InternalImages[direction].size(); ++i)
192 m_InternalImages[InputImageDimension - 2 - direction][i] = OutputImageType::New();
193 m_InternalImages[InputImageDimension - 2 - direction][i]->SetRegions(smallerRegion);
194 m_InternalImages[InputImageDimension - 2 - direction][i]->Allocate();
195 m_InternalImages[InputImageDimension - 2 - direction][i]->FillBuffer(0);
198 largerRegion = smallerRegion;
202 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
207 if (m_SubsampleImageFactor > 1 && InputImageDimension > 1)
209 m_InternalImages.clear();
213 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
219 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
221 if (GetSubsampleImageFactor() > 1)
229 for (
unsigned int i = 0; i < InputImageDimension; ++i)
231 destIndex[i] = srcIndex[i] * GetSubsampleImageFactor();
232 destSize[i] = srcSize[i] * GetSubsampleImageFactor();
235 destRegion.SetIndex(destIndex);
236 destRegion.SetSize(destSize);
243 lowPassOperator.SetDirection(0);
244 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
245 lowPassOperator.CreateDirectional();
247 unsigned long radius[InputImageDimension];
248 radius[0] = lowPassOperator.GetRadius()[0];
251 highPassOperator.SetDirection(0);
252 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
253 highPassOperator.CreateDirectional();
255 if (radius[0] < highPassOperator.GetRadius()[0]) radius[0] = highPassOperator.GetRadius()[0];
257 for (
unsigned int i = 1; i < InputImageDimension; ++i)
261 paddedRegion.PadByRadius(radius);
263 if (paddedRegion.Crop(this->GetInput()->GetLargestPossibleRegion()))
265 destRegion = paddedRegion;
272 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
276 (
unsigned int direction,
279 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
281 if (GetSubsampleImageFactor() > 1)
289 for (
unsigned int i = 0; i < InputImageDimension; ++i)
293 destIndex[i] = srcIndex[i] * GetSubsampleImageFactor();
294 destSize[i] = srcSize[i] * GetSubsampleImageFactor();
298 destIndex[i] = srcIndex[i];
299 destSize[i] = srcSize[i];
303 destRegion.SetIndex(destIndex);
304 destRegion.SetSize(destSize);
308 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
314 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
316 if (GetSubsampleImageFactor() > 1)
318 typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
319 typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
321 typename OutputImageRegionType::IndexType destIndex;
322 typename OutputImageRegionType::SizeType destSize;
324 for (
unsigned int i = 0; i < InputImageDimension; ++i)
327 destIndex[i] = srcIndex[i] / GetSubsampleImageFactor();
328 destSize[i] = srcSize[i] / GetSubsampleImageFactor();
331 destRegion.SetIndex(destIndex);
332 destRegion.SetSize(destSize);
336 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
340 (
unsigned int direction,
343 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
345 if (GetSubsampleImageFactor() > 1)
347 typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
348 typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
350 typename OutputImageRegionType::IndexType destIndex;
351 typename OutputImageRegionType::SizeType destSize;
353 for (
unsigned int i = 0; i < InputImageDimension; ++i)
358 destIndex[i] = srcIndex[i] / GetSubsampleImageFactor();
359 destSize[i] = srcSize[i] / GetSubsampleImageFactor();
363 destIndex[i] = srcIndex[i];
364 destSize[i] = srcSize[i];
368 destRegion.SetIndex(destIndex);
369 destRegion.SetSize(destSize);
373 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
379 unsigned int dir = InputImageDimension - 1;
381 if ((1 << dir) >= static_cast<int>(this->GetNumberOfOutputs()))
383 std::ostringstream msg;
384 msg <<
"Output number 1<<" << dir <<
" = " << (1 << dir) <<
" not allocated\n";
385 msg <<
"Number of excpected outputs " << this->GetNumberOfOutputs() <<
"\n";
390 outputRegionForThread.GetNumberOfPixels() * this->GetNumberOfOutputs() * 2);
394 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
400 if (dir != 0 && m_SubsampleImageFactor > 1)
402 outputLowPass = m_InternalImages[dir - 1][0];
403 outputHighPass = m_InternalImages[dir - 1][1];
413 typename SubsampleIteratorType::IndexType subsampling;
415 subsampling[dir] = GetSubsampleImageFactor();
418 InnerProductType innerProduct;
422 highPassOperator.SetDirection(dir);
423 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
424 highPassOperator.CreateDirectional();
426 SubsampleIteratorType subItHighPass(input, inputRegionForThread);
427 subItHighPass.SetSubsampleFactor(subsampling);
428 subItHighPass.GoToBegin();
430 NeighborhoodIteratorType itHighPass(highPassOperator.GetRadius(), input, inputRegionForThread);
432 itHighPass.OverrideBoundaryCondition(&boundaryCondition);
434 IteratorType outHighPass(outputHighPass, subItHighPass.GenerateOutputInformation());
435 outHighPass.GoToBegin();
437 while (!subItHighPass.IsAtEnd() && !outHighPass.IsAtEnd())
439 itHighPass.SetLocation(subItHighPass.GetIndex());
440 outHighPass.Set(innerProduct(itHighPass, highPassOperator));
445 reporter.CompletedPixel();
450 lowPassOperator.SetDirection(dir);
451 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
452 lowPassOperator.CreateDirectional();
454 SubsampleIteratorType subItLowPass(input, inputRegionForThread);
455 subItLowPass.SetSubsampleFactor(subsampling);
456 subItLowPass.GoToBegin();
458 NeighborhoodIteratorType itLowPass(lowPassOperator.GetRadius(), input, inputRegionForThread);
459 itLowPass.OverrideBoundaryCondition(&boundaryCondition);
461 IteratorType outLowPass(outputLowPass, subItLowPass.GenerateOutputInformation());
462 outLowPass.GoToBegin();
464 while (!subItLowPass.IsAtEnd() && !outLowPass.IsAtEnd())
466 itLowPass.SetLocation(subItLowPass.GetIndex());
467 outLowPass.Set(innerProduct(itLowPass, lowPassOperator));
472 reporter.CompletedPixel();
479 this->CallCopyInputRegionToOutputRegion(dir, outputImageRegion, inputRegionForThread);
481 ThreadedGenerateDataAtDimensionN(0, dir - 1, reporter, outputImageRegion, threadId);
482 ThreadedGenerateDataAtDimensionN(1 << dir, dir - 1, reporter, outputImageRegion, threadId);
486 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
499 this->CallCopyInputRegionToOutputRegion(direction, outputImageRegion, outputRegionForThread);
501 if (m_SubsampleImageFactor > 1)
503 input = m_InternalImages[direction][idx / (1 << (direction + 1))];
507 outputLowPass = m_InternalImages[direction - 1][idx / (1 << direction)];
508 outputHighPass = m_InternalImages[direction - 1][idx / (1 << direction) + 1];
516 outputLowPass->SetRegions(outputImageRegion);
517 outputLowPass->Allocate();
518 outputLowPass->FillBuffer(0);
528 typename SubsampleIteratorType::IndexType subsampling;
530 subsampling[direction] = GetSubsampleImageFactor();
533 InnerProductType innerProduct;
537 highPassOperator.SetDirection(direction);
538 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
539 highPassOperator.CreateDirectional();
541 SubsampleIteratorType subItHighPass(input, outputRegionForThread);
542 subItHighPass.SetSubsampleFactor(subsampling);
543 subItHighPass.GoToBegin();
545 NeighborhoodIteratorType itHighPass(highPassOperator.GetRadius(), input, outputRegionForThread);
547 itHighPass.OverrideBoundaryCondition(&boundaryCondition);
549 IteratorType outHighPass(outputHighPass, subItHighPass.GenerateOutputInformation());
550 outHighPass.GoToBegin();
552 while (!subItHighPass.IsAtEnd() && !outHighPass.IsAtEnd())
554 itHighPass.SetLocation(subItHighPass.GetIndex());
555 outHighPass.Set(innerProduct(itHighPass, highPassOperator));
565 lowPassOperator.SetDirection(direction);
566 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
567 lowPassOperator.CreateDirectional();
569 SubsampleIteratorType subItLowPass(input, outputRegionForThread);
570 subItLowPass.SetSubsampleFactor(subsampling);
571 subItLowPass.GoToBegin();
573 NeighborhoodIteratorType itLowPass(lowPassOperator.GetRadius(), input, outputRegionForThread);
574 itLowPass.OverrideBoundaryCondition(&boundaryCondition);
576 IteratorType outLowPass(outputLowPass, subItLowPass.GenerateOutputInformation());
577 outLowPass.GoToBegin();
579 while (!subItLowPass.IsAtEnd() && !outLowPass.IsAtEnd())
581 itLowPass.SetLocation(subItLowPass.GetIndex());
582 outLowPass.Set(innerProduct(itLowPass, lowPassOperator));
592 IteratorType outIt((direction != 0 && m_SubsampleImageFactor > 1) ?
593 static_cast<OutputImageType*>(m_InternalImages[direction - 2][idx / (1 << (direction - 1))])
594 : this->GetOutput(idx),
599 outIt.Set(inIt.
Get());
604 ThreadedGenerateDataAtDimensionN(idx, direction - 1, reporter, outputImageRegion, threadId);
605 ThreadedGenerateDataAtDimensionN(idx + (1 << direction), direction - 1, reporter, outputImageRegion, threadId);
613 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
617 this->SetNumberOfRequiredInputs(1 << InputImageDimension);
618 this->SetNumberOfInputs(1 << InputImageDimension);
619 this->SetNumberOfOutputs(1);
621 m_UpSampleFilterFactor = 0;
622 m_SubsampleImageFactor = 1;
626 this->SetNumberOfThreads(1);
629 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
634 Superclass::GenerateOutputInformation();
636 for (
unsigned int i = 1; i < this->GetNumberOfInputs(); ++i)
638 for (
unsigned int dim = 0; dim < InputImageDimension; dim++)
640 if (this->GetInput(0)->GetLargestPossibleRegion().GetSize()[dim]
641 != this->GetInput(i)->GetLargestPossibleRegion().GetSize()[dim])
644 "Input images are not of the same dimension", ITK_LOCATION);
653 << this->GetInput(0)->GetLargestPossibleRegion().GetSize()[0]
654 <<
"," << this->GetInput(0)->GetLargestPossibleRegion().GetSize()[1]);
658 this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput(0)->GetLargestPossibleRegion());
659 this->GetOutput()->SetRegions(newRegion);
666 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
670 throw (itk::InvalidRequestedRegionError)
672 Superclass::GenerateInputRequestedRegion();
676 lowPassOperator.SetDirection(0);
677 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
678 lowPassOperator.CreateDirectional();
680 unsigned int radius = lowPassOperator.GetRadius()[0];
683 highPassOperator.SetDirection(0);
684 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
685 highPassOperator.CreateDirectional();
687 if (radius < highPassOperator.GetRadius()[0]) radius = highPassOperator.GetRadius()[0];
690 for (
unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx)
694 inputRegion.PadByRadius(radius);
696 if (inputRegion.Crop(input->GetLargestPossibleRegion()))
698 input->SetRequestedRegion(inputRegion);
702 input->SetRequestedRegion(inputRegion);
705 err.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
712 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
717 if (InputImageDimension > 1)
720 m_InternalImages.resize(InputImageDimension - 1);
721 for (
unsigned int i = 0; i < m_InternalImages.size(); ++i)
724 m_InternalImages[i].resize(1 << (i + 1));
728 Superclass::CallCopyInputRegionToOutputRegion(intermediateRegion,
729 this->GetInput(0)->GetLargestPossibleRegion());
731 AllocateInternalData(intermediateRegion);
735 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
744 for (
unsigned int direction = 0; direction < InputImageDimension - 1; direction++)
746 this->CallCopyInputRegionToOutputRegion(direction,
747 largerRegion, smallerRegion);
749 for (
unsigned int i = 0; i < m_InternalImages[direction].size(); ++i)
751 m_InternalImages[direction][i] = OutputImageType::New();
752 m_InternalImages[direction][i]->SetRegions(largerRegion);
753 m_InternalImages[direction][i]->Allocate();
754 m_InternalImages[direction][i]->FillBuffer(0);
757 smallerRegion = largerRegion;
761 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
766 if (m_SubsampleImageFactor > 1 && InputImageDimension > 1)
768 m_InternalImages.clear();
772 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
778 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
780 if (GetSubsampleImageFactor() > 1)
788 for (
unsigned int i = 0; i < InputImageDimension; ++i)
791 destIndex[i] = srcIndex[i] / GetSubsampleImageFactor();
792 destSize[i] = srcSize[i] / GetSubsampleImageFactor();
795 destRegion.SetIndex(destIndex);
796 destRegion.SetSize(destSize);
801 lowPassOperator.SetDirection(0);
802 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
803 lowPassOperator.CreateDirectional();
805 typename InputImageRegionType::SizeType radius;
806 radius[0] = lowPassOperator.GetRadius()[0];
809 highPassOperator.SetDirection(0);
810 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
811 highPassOperator.CreateDirectional();
813 if (radius[0] < highPassOperator.GetRadius()[0]) radius[0] = highPassOperator.GetRadius()[0];
815 for (
unsigned int i = 1; i < InputImageDimension; ++i)
826 paddedRegion.PadByRadius(radius);
828 if (paddedRegion.Crop(this->GetInput(0)->GetLargestPossibleRegion()))
830 destRegion = paddedRegion;
836 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
842 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
844 if (GetSubsampleImageFactor() > 1)
852 for (
unsigned int i = 0; i < InputImageDimension; ++i)
854 destIndex[i] = srcIndex[i] * GetSubsampleImageFactor();
855 destSize[i] = srcSize[i] * GetSubsampleImageFactor();
858 destRegion.SetIndex(destIndex);
859 destRegion.SetSize(destSize);
863 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
867 (
unsigned int direction,
870 Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
872 if (GetSubsampleImageFactor() > 1)
880 for (
unsigned int i = 0; i < InputImageDimension; ++i)
885 destIndex[i] = srcIndex[i] / GetSubsampleImageFactor();
886 destSize[i] = srcSize[i] / GetSubsampleImageFactor();
890 destIndex[i] = srcIndex[i];
891 destSize[i] = srcSize[i];
895 destRegion.SetIndex(destIndex);
896 destRegion.SetSize(destSize);
900 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
904 (
unsigned int direction,
907 Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
909 if (GetSubsampleImageFactor() > 1)
911 typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
912 typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
914 typename OutputImageRegionType::IndexType destIndex;
915 typename OutputImageRegionType::SizeType destSize;
917 for (
unsigned int i = 0; i < InputImageDimension; ++i)
921 destIndex[i] = srcIndex[i] * GetSubsampleImageFactor();
922 destSize[i] = srcSize[i] * GetSubsampleImageFactor();
926 destIndex[i] = srcIndex[i];
927 destSize[i] = srcSize[i];
931 destRegion.SetIndex(destIndex);
932 destRegion.SetSize(destSize);
936 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
943 outputRegionForThread.GetNumberOfPixels() * this->GetNumberOfInputs());
946 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
948 unsigned int dir = 0;
952 lowPassOperator.SetDirection(dir);
953 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
954 lowPassOperator.CreateDirectional();
958 highPassOperator.SetDirection(dir);
959 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
960 highPassOperator.CreateDirectional();
968 typename NeighborhoodIteratorType::RadiusType radiusMax;
969 for (
unsigned int idx = 0; idx < OutputImageDimension; ++idx)
971 radiusMax[idx] = lowPassOperator.GetRadius(idx);
972 if (radiusMax[idx] < highPassOperator.GetRadius(idx)) radiusMax[idx] = highPassOperator.GetRadius(idx);
976 if (m_SubsampleImageFactor > 1)
978 for (
unsigned int i = 0; i < this->GetNumberOfInputs(); i += 2)
984 if (dir != InputImageDimension - 1)
986 outputImage = m_InternalImages[0][i / 2];
990 typename FilterType::InputImageIndexType delta;
992 delta[dir] = this->GetSubsampleImageFactor();
995 cropedLowPass->SetRegions(inputRegionForThread);
996 cropedLowPass->Allocate();
997 cropedLowPass->FillBuffer(0.);
1002 ++cropedLowPassIt, ++imgLowPassIt)
1004 cropedLowPassIt.
Set(imgLowPassIt.
Get());
1008 overSampledLowPass->SetInput(cropedLowPass);
1009 overSampledLowPass->SetSubsampleFactor(delta);
1010 overSampledLowPass->Update();
1013 cropedHighPass->SetRegions(inputRegionForThread);
1014 cropedHighPass->Allocate();
1015 cropedHighPass->FillBuffer(0.);
1020 ++cropedHighPassIt, ++imgHighPassIt)
1022 cropedHighPassIt.
Set(imgHighPassIt.
Get());
1026 overSampledHighPass->SetInput(cropedHighPass);
1027 overSampledHighPass->SetSubsampleFactor(delta);
1028 overSampledHighPass->Update();
1030 InnerProductType innerProduct;
1033 (outputImage, overSampledLowPass->GetOutput()->GetRequestedRegion());
1035 NeighborhoodIteratorType lowIter(lowPassOperator.GetRadius(),
1036 overSampledLowPass->GetOutput(),
1037 overSampledLowPass->GetOutput()->GetRequestedRegion());
1039 lowIter.OverrideBoundaryCondition(&boundaryCondition);
1041 NeighborhoodIteratorType highIter(highPassOperator.GetRadius(),
1042 overSampledHighPass->GetOutput(),
1043 overSampledHighPass->GetOutput()->GetRequestedRegion());
1044 highIter.OverrideBoundaryCondition(&boundaryCondition);
1046 lowIter.GoToBegin();
1047 highIter.GoToBegin();
1050 while (!out.IsAtEnd())
1052 out.Set(innerProduct(lowIter, lowPassOperator)
1053 + innerProduct(highIter, highPassOperator));
1065 for (
unsigned int i = 0; i < this->GetNumberOfInputs(); i += 2)
1071 if (dir != InputImageDimension - 1)
1073 outputImage = m_InternalImages[0][i / 2];
1076 InnerProductType innerProduct;
1080 NeighborhoodIteratorType lowIter(lowPassOperator.GetRadius(), imgLowPass, imgLowPass->GetRequestedRegion());
1082 lowIter.OverrideBoundaryCondition(&boundaryCondition);
1084 NeighborhoodIteratorType highIter(highPassOperator.GetRadius(), imgHighPass, imgLowPass->GetRequestedRegion());
1085 highIter.OverrideBoundaryCondition(&boundaryCondition);
1087 lowIter.GoToBegin();
1088 highIter.GoToBegin();
1091 while (!out.IsAtEnd())
1093 out.Set((innerProduct(lowIter, lowPassOperator)
1094 + innerProduct(highIter, highPassOperator)) / 2.);
1105 if (dir != InputImageDimension - 1)
1109 this->CallCopyInputRegionToOutputRegion(dir, outputImageRegion, inputRegionForThread);
1111 ThreadedGenerateDataAtDimensionN(dir + 1, reporter, outputImageRegion, threadId);
1116 template <
class TInputImage,
class TOutputImage,
class TWaveletOperator>
1120 (
unsigned int direction,
1125 this->CallCopyInputRegionToOutputRegion(direction, outputImageRegion, outputRegionForThread);
1129 lowPassOperator.SetDirection(direction);
1130 lowPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
1131 lowPassOperator.CreateDirectional();
1135 highPassOperator.SetDirection(direction);
1136 highPassOperator.SetUpSampleFactor(this->GetUpSampleFilterFactor());
1137 highPassOperator.CreateDirectional();
1145 typename NeighborhoodIteratorType::RadiusType radiusMax;
1146 for (
unsigned int i = 0; i < InputImageDimension; ++i)
1148 radiusMax[i] = lowPassOperator.GetRadius(i);
1149 if (radiusMax[i] < highPassOperator.GetRadius(i)) radiusMax[i] = highPassOperator.GetRadius(i);
1153 if (m_SubsampleImageFactor > 1)
1155 for (
unsigned int i = 0; i < m_InternalImages[direction - 1].size(); i += 2)
1161 if (direction < InputImageDimension - 1)
1163 outputImage = m_InternalImages[direction][i / 2];
1167 typename FilterType::InputImageIndexType delta;
1169 delta[direction] = this->GetSubsampleImageFactor();
1172 cropedLowPass->SetRegions(outputRegionForThread);
1173 cropedLowPass->Allocate();
1174 cropedLowPass->FillBuffer(0.);
1179 ++cropedLowPassIt, ++imgLowPassIt)
1181 cropedLowPassIt.
Set(imgLowPassIt.
Get());
1185 overSampledLowPass->SetInput(cropedLowPass);
1186 overSampledLowPass->SetSubsampleFactor(delta);
1187 overSampledLowPass->Update();
1190 cropedHighPass->SetRegions(outputRegionForThread);
1191 cropedHighPass->Allocate();
1192 cropedHighPass->FillBuffer(0.);
1197 ++cropedHighPassIt, ++imgHighPassIt)
1199 cropedHighPassIt.
Set(imgHighPassIt.
Get());
1203 overSampledHighPass->SetInput(cropedHighPass);
1204 overSampledHighPass->SetSubsampleFactor(delta);
1205 overSampledHighPass->Update();
1207 InnerProductType innerProduct;
1210 overSampledLowPass->GetOutput()->GetRequestedRegion());
1214 NeighborhoodIteratorType lowIter(lowPassOperator.GetRadius(),
1215 overSampledLowPass->GetOutput(),
1216 overSampledLowPass->GetOutput()->GetRequestedRegion());
1218 lowIter.OverrideBoundaryCondition(&boundaryCondition);
1220 NeighborhoodIteratorType highIter(highPassOperator.GetRadius(),
1221 overSampledHighPass->GetOutput(),
1222 overSampledHighPass->GetOutput()->GetRequestedRegion());
1223 highIter.OverrideBoundaryCondition(&boundaryCondition);
1225 lowIter.GoToBegin();
1226 highIter.GoToBegin();
1229 while (!out.IsAtEnd())
1231 out.Set(innerProduct(lowIter, lowPassOperator)
1232 + innerProduct(highIter, highPassOperator));
1244 for (
unsigned int i = 0; i < m_InternalImages[direction - 1].size(); i += 2)
1250 if (direction < InputImageDimension - 1)
1252 outputImage = m_InternalImages[direction][i / 2];
1255 InnerProductType innerProduct;
1259 NeighborhoodIteratorType lowIter(lowPassOperator.GetRadius(), imgLowPass, imgLowPass->GetRequestedRegion());
1261 lowIter.OverrideBoundaryCondition(&boundaryCondition);
1263 NeighborhoodIteratorType highIter(highPassOperator.GetRadius(), imgHighPass, imgLowPass->GetRequestedRegion());
1264 highIter.OverrideBoundaryCondition(&boundaryCondition);
1266 lowIter.GoToBegin();
1267 highIter.GoToBegin();
1270 while (!out.IsAtEnd())
1272 out.Set((innerProduct(lowIter, lowPassOperator)
1273 + innerProduct(highIter, highPassOperator)) / 2.);
1284 if (direction < InputImageDimension - 1)
1286 ThreadedGenerateDataAtDimensionN(direction + 1, reporter, outputImageRegion, threadId);