diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 69cc812..898838d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -62,9 +62,6 @@ endif() #change it to ON to visualize images, for dev purposes. option(ITK_VISUALIZE_TESTS "Visualize images in tests for development purposes. Require Module_ITKVtkGlue." OFF) mark_as_advanced(ITK_VISUALIZE_TESTS) -if(ITK_VISUALIZE_TESTS) - list(APPEND IsotropicWaveletsTests runViewImage.cxx) -endif() CreateTestDriver(IsotropicWavelets "${Libraries}" "${IsotropicWaveletsTests}") diff --git a/test/itkExpandWithZerosImageFilterTest.cxx b/test/itkExpandWithZerosImageFilterTest.cxx index 3de8819..51e30fd 100644 --- a/test/itkExpandWithZerosImageFilterTest.cxx +++ b/test/itkExpandWithZerosImageFilterTest.cxx @@ -110,7 +110,7 @@ runExpandWithZerosImageFilterTest( unsigned int expandFactor ) } #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( expander->GetOutput(), "ExpandWithZeros Output" ); + itk::ViewImage::View( expander->GetOutput(), "ExpandWithZeros Output" ); #endif // Test than expand with zeros + shrinkage (decimate) results on input image. diff --git a/test/itkFrequencyBandImageFilterTest.cxx b/test/itkFrequencyBandImageFilterTest.cxx index 9efb060..5162144 100644 --- a/test/itkFrequencyBandImageFilterTest.cxx +++ b/test/itkFrequencyBandImageFilterTest.cxx @@ -126,7 +126,7 @@ itkFrequencyBandImageFilterTest( int argc, char* argv[] ) TRY_EXPECT_NO_EXCEPTION( passBandFilter->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( passBandFilter->GetOutput(), "PassBand - default" ); + itk::ViewImage::View( passBandFilter->GetOutput(), "PassBand - default" ); #endif // Stop-band @@ -146,7 +146,7 @@ itkFrequencyBandImageFilterTest( int argc, char* argv[] ) TRY_EXPECT_NO_EXCEPTION( stopBandFilter->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage(stopBandFilter->GetOutput(), "StopBand" ); + itk::ViewImage::View(stopBandFilter->GetOutput(), "StopBand" ); #endif // Regression test @@ -202,7 +202,7 @@ itkFrequencyBandImageFilterTest( int argc, char* argv[] ) TRY_EXPECT_NO_EXCEPTION( passBandFilter->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( passBandFilter->GetOutput(), "PassBand - radians" ); + itk::ViewImage::View( passBandFilter->GetOutput(), "PassBand - radians" ); #endif // Test the non-radial cut-off. @@ -217,7 +217,7 @@ itkFrequencyBandImageFilterTest( int argc, char* argv[] ) passBandFilter->Update(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( passBandFilter->GetOutput(), "PassBand - RadialBandOff" ); + itk::ViewImage::View( passBandFilter->GetOutput(), "PassBand - RadialBandOff" ); #endif // Test with ShiftedIterator. @@ -234,7 +234,7 @@ itkFrequencyBandImageFilterTest( int argc, char* argv[] ) passBandShiftedFilter->SetPassBand( passLowFreqThreshold, passHighFreqThreshold ); TRY_EXPECT_NO_EXCEPTION( passBandShiftedFilter->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( passBandShiftedFilter->GetOutput(), "PassBand - FrequencyShiftedIterator" ); + itk::ViewImage::View( passBandShiftedFilter->GetOutput(), "PassBand - FrequencyShiftedIterator" ); #endif // using WriterType = itk::ImageFileWriter< ImageType3D >; diff --git a/test/itkFrequencyExpandAndShrinkTest.cxx b/test/itkFrequencyExpandAndShrinkTest.cxx index 8be606d..a22b222 100644 --- a/test/itkFrequencyExpandAndShrinkTest.cxx +++ b/test/itkFrequencyExpandAndShrinkTest.cxx @@ -106,8 +106,8 @@ runFrequencyExpandAndShrinkTest( const std::string & inputImage, const std::stri // auto inverseFFTExpand2 = InverseFFTFilterType::New(); // inverseFFTExpand2->SetInput(expandViaInverseFFTFilter->GetOutput()); // inverseFFTExpand2->Update(); -// itk::Testing::ViewImage(inverseFFTExpand1->GetOutput(), "Expand via frequency manipulation"); -// itk::Testing::ViewImage(inverseFFTExpand2->GetOutput(), "Expand ViaInverseFFT"); +// itk::ViewImage::View(inverseFFTExpand1->GetOutput(), "Expand via frequency manipulation"); +// itk::ViewImage::View(inverseFFTExpand2->GetOutput(), "Expand ViaInverseFFT"); // #endif /*********** SHRINK ***************/ @@ -171,8 +171,8 @@ runFrequencyExpandAndShrinkTest( const std::string & inputImage, const std::stri inverseFFT2->Update(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( zeroDCFilter->GetOutput(), "Original" ); - itk::Testing::ViewImage( inverseFFT1->GetOutput(), "ExpandAndShrink via frequency manipulation" ); + itk::ViewImage::View( zeroDCFilter->GetOutput(), "Original" ); + itk::ViewImage::View( inverseFFT1->GetOutput(), "ExpandAndShrink via frequency manipulation" ); #endif // Comparison @@ -196,7 +196,7 @@ runFrequencyExpandAndShrinkTest( const std::string & inputImage, const std::stri // Via inverseFFT and spatial domain manipulation. #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( inverseFFT2->GetOutput(), "ExpandAndShrink ViaInverseFFT" ); + itk::ViewImage::View( inverseFFT2->GetOutput(), "ExpandAndShrink ViaInverseFFT" ); #endif differenceFilter->SetTestInput( inverseFFT2->GetOutput() ); differenceFilter->Update(); diff --git a/test/itkFrequencyExpandTest.cxx b/test/itkFrequencyExpandTest.cxx index ea4fa3b..89ff214 100644 --- a/test/itkFrequencyExpandTest.cxx +++ b/test/itkFrequencyExpandTest.cxx @@ -234,26 +234,26 @@ runFrequencyExpandTest(const std::string & inputImage, const std::string & outpu TRY_EXPECT_NO_EXCEPTION( writer->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( zeroDCFilter->GetOutput(), "Original" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "FrequencyExpander" ); + itk::ViewImage::View( zeroDCFilter->GetOutput(), "Original" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "FrequencyExpander" ); // Compare with regular expand filter. using RegularExpandType = itk::ExpandWithZerosImageFilter< ImageType, ImageType >; auto regularExpandFilter = RegularExpandType::New(); regularExpandFilter->SetInput( reader->GetOutput() ); regularExpandFilter->SetExpandFactors( 2 ); regularExpandFilter->Update(); - itk::Testing::ViewImage( regularExpandFilter->GetOutput(), "Regular expander (adding zeros)" ); + itk::ViewImage::View( regularExpandFilter->GetOutput(), "Regular expander (adding zeros)" ); // Complex to real // using ComplexToRealFilter = itk::ComplexToRealImageFilter; // auto complexToRealFilter = ComplexToRealFilter::New(); // complexToRealFilter->SetInput(fftFilter->GetOutput() ); // complexToRealFilter->Update(); - // itk::Testing::ViewImage(complexToRealFilter->GetOutput()); + // itk::ViewImage::View(complexToRealFilter->GetOutput()); // auto complexToRealFilterExpand = ComplexToRealFilter::New(); // complexToRealFilterExpand->SetInput(expandFilter->GetOutput() ); // complexToRealFilterExpand->Update(); - // itk::Testing::ViewImage(complexToRealFilterExpand->GetOutput()); + // itk::ViewImage::View(complexToRealFilterExpand->GetOutput()); #endif if ( testPassed ) diff --git a/test/itkFrequencyShrinkTest.cxx b/test/itkFrequencyShrinkTest.cxx index 866f76d..5c2beab 100644 --- a/test/itkFrequencyShrinkTest.cxx +++ b/test/itkFrequencyShrinkTest.cxx @@ -322,37 +322,37 @@ runFrequencyShrinkTest( const std::string & inputImage, const std::string & outp TRY_EXPECT_NO_EXCEPTION( writer->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( zeroDCFilter->GetOutput(), "Original" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "FrequencyShrinker" ); + itk::ViewImage::View( zeroDCFilter->GetOutput(), "Original" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "FrequencyShrinker" ); // Compare with regular shrink filter. using RegularShrinkType = itk::ShrinkImageFilter< ImageType, ImageType >; auto regularShrinkFilter = RegularShrinkType::New(); regularShrinkFilter->SetInput( zeroDCFilter->GetOutput() ); regularShrinkFilter->SetShrinkFactors( 2 ); regularShrinkFilter->Update(); - itk::Testing::ViewImage( regularShrinkFilter->GetOutput(), "Regular shrinker" ); + itk::ViewImage::View( regularShrinkFilter->GetOutput(), "Regular shrinker" ); // Complex to real using ComplexToRealFilter = itk::ComplexToRealImageFilter< ComplexImageType, ImageType >; auto complexToRealFilter = ComplexToRealFilter::New(); complexToRealFilter->SetInput( fftFilter->GetOutput() ); complexToRealFilter->Update(); - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), "ComplexToReal. Original" ); + itk::ViewImage::View( complexToRealFilter->GetOutput(), "ComplexToReal. Original" ); auto complexToRealFilterShrink = ComplexToRealFilter::New(); complexToRealFilterShrink->SetInput( shrinkFilter->GetOutput() ); complexToRealFilterShrink->Update(); - itk::Testing::ViewImage(complexToRealFilterShrink->GetOutput(), "ComplexToReal. Shrinked" ); + itk::ViewImage::View(complexToRealFilterShrink->GetOutput(), "ComplexToReal. Shrinked" ); // Complex to imaginary // using ComplexToImaginaryFilter = itk::ComplexToImaginaryImageFilter< ComplexImageType, ImageType >; // auto complexToImaginaryFilter = ComplexToImaginaryFilter::New(); // complexToImaginaryFilter->SetInput( fftFilter->GetOutput() ); // complexToImaginaryFilter->Update(); - // itk::Testing::ViewImage( complexToImaginaryFilter->GetOutput(), "ComplexToImaginary. Original" ); + // itk::ViewImage::View( complexToImaginaryFilter->GetOutput(), "ComplexToImaginary. Original" ); // auto complexToImaginaryFilterShrink = ComplexToImaginaryFilter::New(); // complexToImaginaryFilterShrink->SetInput( shrinkFilter->GetOutput() ); // complexToImaginaryFilterShrink->Update(); - // itk::Testing::ViewImage( complexToImaginaryFilterShrink->GetOutput(), "ComplexToImaginary. Shrinked" ); + // itk::ViewImage::View( complexToImaginaryFilterShrink->GetOutput(), "ComplexToImaginary. Shrinked" ); #endif diff --git a/test/itkMonogenicSignalFrequencyImageFilterTest.cxx b/test/itkMonogenicSignalFrequencyImageFilterTest.cxx index 1302028..a3abe45 100644 --- a/test/itkMonogenicSignalFrequencyImageFilterTest.cxx +++ b/test/itkMonogenicSignalFrequencyImageFilterTest.cxx @@ -101,7 +101,7 @@ itkMonogenicSignalFrequencyImageFilterTest( int argc, char* argv[] ) inverseFFT->Update(); #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( inverseFFT->GetOutput(), "MonoFilterOutput (inverseFFT). Component: " + n2s(c) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "MonoFilterOutput (inverseFFT). Component: " + n2s(c) ); #endif } diff --git a/test/itkPhaseAnalysisSoftThresholdImageFilterTest.cxx b/test/itkPhaseAnalysisSoftThresholdImageFilterTest.cxx index 4565626..f1fd971 100644 --- a/test/itkPhaseAnalysisSoftThresholdImageFilterTest.cxx +++ b/test/itkPhaseAnalysisSoftThresholdImageFilterTest.cxx @@ -168,7 +168,7 @@ int itkPhaseAnalysisSoftThresholdImageFilterTest( int argc, char* argv[] ) phaseAnalyzer->GetOutputPhase(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( cosPhase.GetPointer(), "PhaseAnalyzer(Soft) output" ); + itk::ViewImage::View( cosPhase.GetPointer(), "PhaseAnalyzer(Soft) output" ); #endif return testStatus; diff --git a/test/itkRieszFrequencyFilterBankGeneratorTest.cxx b/test/itkRieszFrequencyFilterBankGeneratorTest.cxx index d2a369f..32cd3f3 100644 --- a/test/itkRieszFrequencyFilterBankGeneratorTest.cxx +++ b/test/itkRieszFrequencyFilterBankGeneratorTest.cxx @@ -114,7 +114,7 @@ itkRieszFrequencyFilterBankGeneratorTest( int argc, char* argv[] ) complexToRealFilter->Update(); #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), "RealPart of Complex. Component: " + n2s( + itk::ViewImage::View( complexToRealFilter->GetOutput(), "RealPart of Complex. Component: " + n2s( comp ) + " / " + n2s( filterBank->GetNumberOfOutputs() - 1 ) + ". Indices: " + oss.str() ); #endif } @@ -139,7 +139,7 @@ itkRieszFrequencyFilterBankGeneratorTest( int argc, char* argv[] ) complexToImaginaryFilter->Update(); #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( complexToImaginaryFilter->GetOutput(), "ImaginaryPart of Complex. Component: " + n2s( + itk::ViewImage::View( complexToImaginaryFilter->GetOutput(), "ImaginaryPart of Complex. Component: " + n2s( comp ) + " / " + n2s( filterBank->GetNumberOfOutputs() - 1 ) + ". Indices: " + oss.str() ); #endif } diff --git a/test/itkRieszFrequencyFunctionTest.cxx b/test/itkRieszFrequencyFunctionTest.cxx index 540e652..beb826c 100644 --- a/test/itkRieszFrequencyFunctionTest.cxx +++ b/test/itkRieszFrequencyFunctionTest.cxx @@ -166,7 +166,7 @@ runRieszFrequencyFunctionTest(unsigned int inputOrder) // // #ifdef ITK_VISUALIZE_TESTS // itk::NumberToString< unsigned int > n2s; -// itk::Testing::ViewImage( complexToRealFilter->GetOutput(), "RealPart of Complex. Direction: " + n2s( +// itk::ViewImage::View( complexToRealFilter->GetOutput(), "RealPart of Complex. Direction: " + n2s( // dir + 1) + " / " + n2s( ImageType::ImageDimension ) ); // #endif } diff --git a/test/itkRieszWaveletPhaseAnalysisTest.cxx b/test/itkRieszWaveletPhaseAnalysisTest.cxx index 3816066..a501d53 100644 --- a/test/itkRieszWaveletPhaseAnalysisTest.cxx +++ b/test/itkRieszWaveletPhaseAnalysisTest.cxx @@ -168,10 +168,10 @@ runRieszWaveletPhaseAnalysisTest( const std::string& inputImage, auto inverseFFT = InverseFFTFilterType::New(); inverseFFT->SetInput(analysisWavelets[i]); inverseFFT->Update(); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "WaveletCoef: output #" + n2s(i) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "WaveletCoef: output #" + n2s(i) ); inverseFFT->SetInput(modifiedWavelets[i]); inverseFFT->Update(); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "WaveletCoef. PhaseAnalyzed #" + n2s(i) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "WaveletCoef. PhaseAnalyzed #" + n2s(i) ); } } #endif @@ -191,8 +191,8 @@ runRieszWaveletPhaseAnalysisTest( const std::string& inputImage, inverseFFT->Update(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( reader->GetOutput(), "Input Image" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "Inverse Wavelet" ); + itk::ViewImage::View( reader->GetOutput(), "Input Image" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "Inverse Wavelet" ); #endif // Cast To Float for save as tiff. diff --git a/test/itkShrinkDecimateImageFilterTest.cxx b/test/itkShrinkDecimateImageFilterTest.cxx index 2be0e5e..1f94484 100644 --- a/test/itkShrinkDecimateImageFilterTest.cxx +++ b/test/itkShrinkDecimateImageFilterTest.cxx @@ -111,7 +111,7 @@ runShrinkDecimateImageFilterTest() } #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( decimator->GetOutput(), "ShrinkDecimate Output" ); + itk::ViewImage::View( decimator->GetOutput(), "ShrinkDecimate Output" ); #endif std::cout << "Test passed." << std::endl; diff --git a/test/itkStructureTensorTest.cxx b/test/itkStructureTensorTest.cxx index e809f20..b068cab 100644 --- a/test/itkStructureTensorTest.cxx +++ b/test/itkStructureTensorTest.cxx @@ -99,8 +99,8 @@ runStructureTensorTest() } #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( inputImage1.GetPointer(), "input1" ); - itk::Testing::ViewImage( inputImage2.GetPointer(), "input2" ); + itk::ViewImage::View( inputImage1.GetPointer(), "input1" ); + itk::ViewImage::View( inputImage2.GetPointer(), "input2" ); #endif // Structure Tensor @@ -141,7 +141,7 @@ runStructureTensorTest() << eigenMatrixCols << std::endl; } #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( tensor->GetGaussianSource()->GetOutput(), "Gaussian" ); + itk::ViewImage::View( tensor->GetGaussianSource()->GetOutput(), "Gaussian" ); #endif typename ImageType::Pointer largestEigenValueProjectionImage; @@ -156,12 +156,12 @@ runStructureTensorTest() #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< float > n2s; - itk::Testing::ViewImage( projectImage.GetPointer(), "eigen number: " + n2s( eigenNumber ) ); + itk::ViewImage::View( projectImage.GetPointer(), "eigen number: " + n2s( eigenNumber ) ); #endif } auto coherencyImage = tensor->ComputeCoherencyImage(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( coherencyImage.GetPointer(), "Coherency image" ); + itk::ViewImage::View( coherencyImage.GetPointer(), "Coherency image" ); #endif // Compare to known result diff --git a/test/itkStructureTensorWithGeneralizedRieszTest.cxx b/test/itkStructureTensorWithGeneralizedRieszTest.cxx index 0050013..473089b 100644 --- a/test/itkStructureTensorWithGeneralizedRieszTest.cxx +++ b/test/itkStructureTensorWithGeneralizedRieszTest.cxx @@ -142,7 +142,7 @@ runStructureTensorWithGeneralizedRieszTest( if ( visualizeRieszWavelets ) { itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( inverseFFT->GetOutput(), + itk::ViewImage::View( inverseFFT->GetOutput(), "RieszWaveletCoef: output #" + n2s(i) + " RieszComp: " + n2s(rieszComp) ); } bool visualizeRieszWaveletsInFrequency = false; @@ -155,11 +155,11 @@ runStructureTensorWithGeneralizedRieszTest( auto complexToImaginary = ComplexToImaginaryFilterType::New(); complexToReal->SetInput(rieszWavelets[rieszComp]); complexToReal->Update(); - itk::Testing::ViewImage( complexToReal->GetOutput(), + itk::ViewImage::View( complexToReal->GetOutput(), "REAL:RieszWaveletCoef: output #" + n2s(i) + " RieszComp: " + n2s(rieszComp) ); complexToImaginary->SetInput(rieszWavelets[rieszComp]); complexToImaginary->Update(); - itk::Testing::ViewImage( complexToImaginary->GetOutput(), + itk::ViewImage::View( complexToImaginary->GetOutput(), "IMAGINARY:RieszWaveletCoef: output #" + n2s(i) + " RieszComp: " + n2s(rieszComp) ); } #endif @@ -190,10 +190,10 @@ runStructureTensorWithGeneralizedRieszTest( auto inverseFFT = InverseFFTFilterType::New(); inverseFFT->SetInput(analysisWavelets[i]); inverseFFT->Update(); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "WaveletCoef: output #" + n2s(i) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "WaveletCoef: output #" + n2s(i) ); inverseFFT->SetInput(modifiedWavelets[i]); inverseFFT->Update(); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "WaveletCoef. LargestComponentStructureTensor #" + n2s(i) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "WaveletCoef. LargestComponentStructureTensor #" + n2s(i) ); } } #endif @@ -212,8 +212,8 @@ runStructureTensorWithGeneralizedRieszTest( inverseFFT->Update(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( reader->GetOutput(), "Input Image" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "Inverse Wavelet" ); + itk::ViewImage::View( reader->GetOutput(), "Input Image" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "Inverse Wavelet" ); #endif // using WriterType = itk::ImageFileWriter< typename InverseFFTFilterType::OutputImageType >; diff --git a/test/itkViewImage.h b/test/itkViewImage.h deleted file mode 100644 index 1339281..0000000 --- a/test/itkViewImage.h +++ /dev/null @@ -1,46 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef itkViewImage_h -#define itkViewImage_h -#include -#include -namespace itk -{ -namespace Testing -{ -template -void -ViewImage(const T* img, - const std::string& win_title = "itkView", - size_t win_x = 600, - size_t win_y = 600); - -template -void -ViewImages(const TLeft* leftImg, - const TRight* rightImg, - const std::string& win_title = "itkView", - size_t win_x = 800, - size_t win_y = 800); -}// namespace Testing -}// namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkViewImage.hxx" -#endif -#endif diff --git a/test/itkViewImage.hxx b/test/itkViewImage.hxx deleted file mode 100644 index 4e4d9cd..0000000 --- a/test/itkViewImage.hxx +++ /dev/null @@ -1,248 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef itkViewImage_hxx -#define itkViewImage_hxx -#include -#include -#include -#include -#include -#include -#include -#include -#include "itkImage.h" -#include "itkImageToVTKImageFilter.h" -#include "itkStatisticsImageFilter.h" -#include -namespace itk -{ -namespace Testing -{ -template< typename T > -void -ViewImage( const T* img, - const std::string& win_title, - size_t win_x, - size_t win_y ) -{ - using ConnectorType = itk::ImageToVTKImageFilter< T >; - auto connector = ConnectorType::New(); - connector->SetInput(img); - connector->Update(); - connector->UpdateLargestPossibleRegion(); - - // Setup renderers - vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer >::New(); - - // Setup render window - vtkSmartPointer< vtkRenderWindow > renderWindow = vtkSmartPointer< vtkRenderWindow >::New(); - renderWindow->SetWindowName(win_title.c_str()); - renderWindow->SetSize(win_x, win_y); - renderWindow->AddRenderer(renderer); - - // Setup render window interactor - vtkSmartPointer< vtkRenderWindowInteractor > renderWindowInteractor = - vtkSmartPointer< vtkRenderWindowInteractor >::New(); - vtkSmartPointer< vtkInteractorStyleRubberBand3D > style = - vtkSmartPointer< vtkInteractorStyleRubberBand3D >::New(); - renderWindowInteractor->SetInteractorStyle(style); - - // Render and start interaction - renderWindowInteractor->SetRenderWindow(renderWindow); - - // Prepare for slices. - using FilterType = itk::StatisticsImageFilter< T >; - auto filter = FilterType::New(); - filter->SetInput(img); - filter->Update(); - filter->UpdateLargestPossibleRegion(); - double min_intensity = filter->GetMinimum(); - double max_intensity = filter->GetMaximum(); - double window = max_intensity - min_intensity; - double level = min_intensity + window / 2; - /** SLICES */ - FixedArray< vtkSmartPointer< vtkImagePlaneWidget >, 3 > slice_planes; - for ( unsigned i = 0; i < 3; ++i ) - { - slice_planes[i] = vtkSmartPointer< vtkImagePlaneWidget >::New(); - slice_planes[i]->SetResliceInterpolateToCubic(); - slice_planes[i]->DisplayTextOn(); - slice_planes[i]->SetInteractor(renderWindowInteractor); - slice_planes[i]->PlaceWidget(); - slice_planes[i]->SetSliceIndex(0); - slice_planes[i]->SetMarginSizeX(0); - slice_planes[i]->SetMarginSizeY(0); - slice_planes[i]->SetRightButtonAction( - vtkImagePlaneWidget::VTK_SLICE_MOTION_ACTION); - slice_planes[i]->SetMiddleButtonAction( - vtkImagePlaneWidget::VTK_WINDOW_LEVEL_ACTION); - slice_planes[i]->TextureInterpolateOff(); - - slice_planes[i]->SetInputData(connector->GetOutput()); - slice_planes[i]->SetPlaneOrientation(i); - slice_planes[i]->UpdatePlacement(); - slice_planes[i]->SetWindowLevel(window, level); - slice_planes[i]->On(); - } - // Flip camera because VTK-ITK different corner for origin. - double pos[3]; - double vup[3]; - vtkCamera *cam = renderer->GetActiveCamera(); - cam->GetPosition(pos); - cam->GetViewUp(vup); - for ( unsigned int i = 0; i < 3; ++i ) - { - pos[i] = -pos[i]; - vup[i] = -vup[i]; - } - cam->SetPosition(pos); - cam->SetViewUp(vup); - - renderer->ResetCamera(); - renderWindowInteractor->Initialize(); - renderWindowInteractor->Start(); -} - -template< typename TLeft, typename TRight > -void -ViewImages( const TLeft* leftImg, - const TRight* rightImg, - const std::string& win_title, - size_t win_x, - size_t win_y ) -{ - using LeftConnectorType = itk::ImageToVTKImageFilter< TLeft >; - auto leftConnector = LeftConnectorType::New(); - leftConnector->SetInput(leftImg); - leftConnector->Update(); - leftConnector->UpdateLargestPossibleRegion(); - - using RightConnectorType = itk::ImageToVTKImageFilter< TRight >; - auto rightConnector = RightConnectorType::New(); - rightConnector->SetInput(rightImg); - rightConnector->Update(); - rightConnector->UpdateLargestPossibleRegion(); - - // Setup renderer (UNIQUE) - vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer >::New(); - - // Setup render window (UNIQUE) - vtkSmartPointer< vtkRenderWindow > renderWindow = vtkSmartPointer< vtkRenderWindow >::New(); - renderWindow->SetWindowName(win_title.c_str()); - renderWindow->SetSize(win_x, win_y); - renderWindow->AddRenderer(renderer); - - // Setup render window interactor (UNIQUE) - vtkSmartPointer< vtkRenderWindowInteractor > renderWindowInteractor = - vtkSmartPointer< vtkRenderWindowInteractor >::New(); - vtkSmartPointer< vtkInteractorStyleRubberBand3D > style = - vtkSmartPointer< vtkInteractorStyleRubberBand3D >::New(); - renderWindowInteractor->SetInteractorStyle(style); - - // Render and start interaction - renderWindowInteractor->SetRenderWindow(renderWindow); - - using LeftFilterType = itk::StatisticsImageFilter< TLeft >; - // Prepare for slices (BOTH) - auto leftFilter = LeftFilterType::New(); - leftFilter->SetInput(leftImg); - leftFilter->Update(); - leftFilter->UpdateLargestPossibleRegion(); - double leftMin_intensity = leftFilter->GetMinimum(); - double leftMax_intensity = leftFilter->GetMaximum(); - double leftWindow = leftMax_intensity - leftMin_intensity; - double leftLevel = leftMin_intensity + leftWindow / 2; - - using RightFilterType = itk::StatisticsImageFilter< TRight >; - auto rightFilter = RightFilterType::New(); - rightFilter->SetInput(rightImg); - rightFilter->Update(); - rightFilter->UpdateLargestPossibleRegion(); - double rightMin_intensity = rightFilter->GetMinimum(); - double rightMax_intensity = rightFilter->GetMaximum(); - double rightWindow = rightMax_intensity - rightMin_intensity; - double rightLevel = rightMin_intensity + rightWindow / 2; - /** SLICES (BOTH) */ - FixedArray< vtkSmartPointer< vtkImagePlaneWidget >, 3 > leftSlice_planes; - for ( unsigned i = 0; i < 3; ++i ) - { - leftSlice_planes[i] = vtkSmartPointer< vtkImagePlaneWidget >::New(); - leftSlice_planes[i]->SetResliceInterpolateToCubic(); - leftSlice_planes[i]->DisplayTextOn(); - leftSlice_planes[i]->SetInteractor(renderWindowInteractor); - leftSlice_planes[i]->PlaceWidget(); - leftSlice_planes[i]->SetSliceIndex(0); - leftSlice_planes[i]->SetMarginSizeX(0); - leftSlice_planes[i]->SetMarginSizeY(0); - leftSlice_planes[i]->SetRightButtonAction( - vtkImagePlaneWidget::VTK_SLICE_MOTION_ACTION); - leftSlice_planes[i]->SetMiddleButtonAction( - vtkImagePlaneWidget::VTK_WINDOW_LEVEL_ACTION); - leftSlice_planes[i]->TextureInterpolateOff(); - - leftSlice_planes[i]->SetInputData(leftConnector->GetOutput()); - leftSlice_planes[i]->SetPlaneOrientation(i); - leftSlice_planes[i]->UpdatePlacement(); - leftSlice_planes[i]->SetWindowLevel(leftWindow, leftLevel); - leftSlice_planes[i]->On(); - } - FixedArray< vtkSmartPointer< vtkImagePlaneWidget >, 3 > rightSlice_planes; - for ( unsigned i = 0; i < 3; ++i ) - { - rightSlice_planes[i] = vtkSmartPointer< vtkImagePlaneWidget >::New(); - rightSlice_planes[i]->SetResliceInterpolateToCubic(); - rightSlice_planes[i]->DisplayTextOn(); - rightSlice_planes[i]->SetInteractor(renderWindowInteractor); - rightSlice_planes[i]->PlaceWidget(); - rightSlice_planes[i]->SetSliceIndex(0); - rightSlice_planes[i]->SetMarginSizeX(0); - rightSlice_planes[i]->SetMarginSizeY(0); - rightSlice_planes[i]->SetRightButtonAction( - vtkImagePlaneWidget::VTK_SLICE_MOTION_ACTION); - rightSlice_planes[i]->SetMiddleButtonAction( - vtkImagePlaneWidget::VTK_WINDOW_LEVEL_ACTION); - rightSlice_planes[i]->TextureInterpolateOff(); - - rightSlice_planes[i]->SetInputData(rightConnector->GetOutput()); - rightSlice_planes[i]->SetPlaneOrientation(i); - rightSlice_planes[i]->UpdatePlacement(); - rightSlice_planes[i]->SetWindowLevel(rightWindow, rightLevel); - rightSlice_planes[i]->On(); - } - // Flip camera because VTK-ITK different corner for origin. - double pos[3]; - double vup[3]; - vtkCamera *cam = renderer->GetActiveCamera(); - cam->GetPosition(pos); - cam->GetViewUp(vup); - for ( unsigned int i = 0; i < 3; ++i ) - { - pos[i] = -pos[i]; - vup[i] = -vup[i]; - } - cam->SetPosition(pos); - cam->SetViewUp(vup); - - renderer->ResetCamera(); - - renderWindowInteractor->Initialize(); - renderWindowInteractor->Start(); -} -}// namespace Testing -}// namespace itk -#endif diff --git a/test/itkWaveletFrequencyFilterBankGeneratorDownsampleTest.cxx b/test/itkWaveletFrequencyFilterBankGeneratorDownsampleTest.cxx index 915d8a0..3f46a57 100644 --- a/test/itkWaveletFrequencyFilterBankGeneratorDownsampleTest.cxx +++ b/test/itkWaveletFrequencyFilterBankGeneratorDownsampleTest.cxx @@ -103,12 +103,12 @@ runWaveletFrequencyFilterBankGeneratorDownsampleTest( const std::string& inputIm auto complexToRealFilter = ComplexToRealFilter::New(); complexToRealFilter->SetInput(shrinkFilter->GetOutput()); complexToRealFilter->Update(); - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), + itk::ViewImage::View( complexToRealFilter->GetOutput(), "shrinked (by half) FilterBank"); // complexToRealFilter->SetInput(forwardFilterBankDown->GetOutputHighPass()); complexToRealFilter->SetInput(forwardFilterBankDown->GetOutputLowPass()); complexToRealFilter->Update(); - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), + itk::ViewImage::View( complexToRealFilter->GetOutput(), "FilterBank of halfSizeImage (highPassBand)"); #endif diff --git a/test/itkWaveletFrequencyFilterBankGeneratorTest.cxx b/test/itkWaveletFrequencyFilterBankGeneratorTest.cxx index 9c055b5..2c8d958 100644 --- a/test/itkWaveletFrequencyFilterBankGeneratorTest.cxx +++ b/test/itkWaveletFrequencyFilterBankGeneratorTest.cxx @@ -95,7 +95,7 @@ runWaveletFrequencyFilterBankGeneratorTest( const std::string& inputImage, #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), + itk::ViewImage::View( complexToRealFilter->GetOutput(), "RealPart of Complex. Band: " + n2s(i) + "/" + n2s( highSubBands ) ); #endif } @@ -120,7 +120,7 @@ runWaveletFrequencyFilterBankGeneratorTest( const std::string& inputImage, #ifdef ITK_VISUALIZE_TESTS itk::NumberToString< unsigned int > n2s; - itk::Testing::ViewImage( inverseFFT->GetOutput(), "InverseFFT. Band: " + n2s(i) + "/" + n2s( highSubBands ) ); + itk::ViewImage::View( inverseFFT->GetOutput(), "InverseFFT. Band: " + n2s(i) + "/" + n2s( highSubBands ) ); #endif } diff --git a/test/itkWaveletFrequencyForwardTest.cxx b/test/itkWaveletFrequencyForwardTest.cxx index 19fe702..bf4d772 100644 --- a/test/itkWaveletFrequencyForwardTest.cxx +++ b/test/itkWaveletFrequencyForwardTest.cxx @@ -218,7 +218,7 @@ int runWaveletFrequencyForwardTest( const std::string& inputImage, #ifdef ITK_VISUALIZE_TESTS std::pair< unsigned int, unsigned int > pairLvBand = forwardWavelet->OutputIndexToLevelBand( nOutput ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), + itk::ViewImage::View( inverseFFT->GetOutput(), "Wavelet coef. n_out: " + n2s( nOutput ) + " level: " + n2s( pairLvBand.first ) + " , band: " + n2s( pairLvBand.second ) + "/" + n2s( inputBands ) ); #endif diff --git a/test/itkWaveletFrequencyForwardUndecimatedTest.cxx b/test/itkWaveletFrequencyForwardUndecimatedTest.cxx index 4bef312..18540d2 100644 --- a/test/itkWaveletFrequencyForwardUndecimatedTest.cxx +++ b/test/itkWaveletFrequencyForwardUndecimatedTest.cxx @@ -205,7 +205,7 @@ runWaveletFrequencyForwardUndecimatedTest( const std::string& inputImage, inverseFFT->Update(); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( inverseFFT->GetOutput(), + itk::ViewImage::View( inverseFFT->GetOutput(), "Wavelet coef. n_out: " + n2s( nOutput ) + " level: " + n2s( level ) + " , band: " + n2s( band ) + "/" + n2s( inputBands ) ); #endif diff --git a/test/itkWaveletFrequencyInverseTest.cxx b/test/itkWaveletFrequencyInverseTest.cxx index 7f9d825..3120d5a 100644 --- a/test/itkWaveletFrequencyInverseTest.cxx +++ b/test/itkWaveletFrequencyInverseTest.cxx @@ -162,8 +162,8 @@ runWaveletFrequencyInverseTest( const std::string& inputImage, TRY_EXPECT_NO_EXCEPTION( writer->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( reader->GetOutput(), "Original" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "InverseWavelet" ); + itk::ViewImage::View( reader->GetOutput(), "Original" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "InverseWavelet" ); #endif // TODO move it from here to Forward test. @@ -179,7 +179,7 @@ runWaveletFrequencyInverseTest( const std::string& inputImage, { complexToRealFilter->SetInput( waveletFilterBankPyramid[i]); complexToRealFilter->UpdateLargestPossibleRegion(); - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), "FilterBankPyramid #" + n2s(i) ); + itk::ViewImage::View( complexToRealFilter->GetOutput(), "FilterBankPyramid #" + n2s(i) ); } #endif diff --git a/test/itkWaveletFrequencyInverseUndecimatedTest.cxx b/test/itkWaveletFrequencyInverseUndecimatedTest.cxx index 505aaf6..7c72285 100644 --- a/test/itkWaveletFrequencyInverseUndecimatedTest.cxx +++ b/test/itkWaveletFrequencyInverseUndecimatedTest.cxx @@ -151,8 +151,8 @@ int runWaveletFrequencyInverseUndecimatedTest( const std::string& inputImage, TRY_EXPECT_NO_EXCEPTION( writer->Update() ); #ifdef ITK_VISUALIZE_TESTS - itk::Testing::ViewImage( reader->GetOutput(), "Original" ); - itk::Testing::ViewImage( inverseFFT->GetOutput(), "InverseWavelet" ); + itk::ViewImage::View( reader->GetOutput(), "Original" ); + itk::ViewImage::View( inverseFFT->GetOutput(), "InverseWavelet" ); #endif // TODO move it from here to Forward test. @@ -168,7 +168,7 @@ int runWaveletFrequencyInverseUndecimatedTest( const std::string& inputImage, { complexToRealFilter->SetInput( waveletFilterBankPyramid[i]); complexToRealFilter->UpdateLargestPossibleRegion(); - itk::Testing::ViewImage( complexToRealFilter->GetOutput(), "FilterBankPyramid #" + n2s(i) ); + itk::ViewImage::View( complexToRealFilter->GetOutput(), "FilterBankPyramid #" + n2s(i) ); } #endif diff --git a/test/runViewImage.cxx b/test/runViewImage.cxx deleted file mode 100644 index 471b74b..0000000 --- a/test/runViewImage.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#include -#include "itkImage.h" -#include "itkImageFileReader.h" -#include "itkViewImage.h" - -using namespace std; -using namespace itk; - -int -runViewImage(int argc, char* argv[]) -{ - if ( argc < 2 || argc == 4 || argc > 5 ) - { - std::cerr << "Usage: " << argv[0] << " inputImage [title] [win_size_x win_size_y] " << std::endl; - return EXIT_FAILURE; - } - // Defaults - std::string win_title = "itkViewImage"; - size_t win_x = 600; - size_t win_y = 600; - if ( argc >= 3 ) - { - win_title = argv[2]; - } - if ( argc == 5 ) - { - win_x = atoi(argv[3]); - win_y = atoi(argv[4]); - } - const string inputImage = argv[1]; - - constexpr unsigned int dimension = 3; - using PixelType = float; - using ImageType = itk::Image< PixelType, dimension >; - using ReaderType = itk::ImageFileReader< ImageType >; - auto reader = ReaderType::New(); - reader->SetFileName(inputImage); - reader->Update(); - - itk::Testing::ViewImage(reader->GetOutput(), win_title, win_x, win_y ); - - return EXIT_SUCCESS; -}