diff --git a/Code/DisparityMap/otbStreamingWarpImageFilter.h b/Code/DisparityMap/otbStreamingWarpImageFilter.h index 566da07046ae6fa07c8f87334533620bb65c00c6..9e5f4c2b7fc1880d23cc706fbbc93dab02c301d9 100644 --- a/Code/DisparityMap/otbStreamingWarpImageFilter.h +++ b/Code/DisparityMap/otbStreamingWarpImageFilter.h @@ -25,9 +25,22 @@ namespace otb { /** \class StreamingWarpImageFilter - * \brief + * \brief This class acts like the itk::WarpImageFilter, but it does not request the largest possible region of the image to warp. * - * \TODO: Document + * Instead, the user should assess the maximum deformation in the deformation field and set it via the SetMaximumDeformation() method. + * + * The filter will then compute an appropriate security margin according to the image spacing, the maximum deformation and the interpolator + * radius in otb::StreamingTraits. + * + * This security margin is used to stream the input image, making this filter an entirely streamable one. + * + * If the maximum deformation is wrong, this filter is likely to request data outside of the input image buffered region. In this case, pixels + * outside the region will be set to Zero according to itk::NumericTraits. + * + * \sa itk::WarpImageFilter + * + * \ingroup Streamed + * \ingroup Threaded */ template <class TInputImage, class TOutputImage, class TDeformationField> @@ -35,7 +48,6 @@ class ITK_EXPORT StreamingWarpImageFilter : public itk::WarpImageFilter< TInputImage, TOutputImage, TDeformationField > { public: - /** Standard class typedefs. */ typedef StreamingWarpImageFilter Self; typedef itk::WarpImageFilter< TInputImage, TOutputImage, TDeformationField> Superclass; diff --git a/Code/DisparityMap/otbStreamingWarpImageFilter.txx b/Code/DisparityMap/otbStreamingWarpImageFilter.txx index 9ce17120e29eaca0c1ae6c9b8ebb2ef2834a8100..8018205eeca0e7cd1a7132ecfb5db8250e987556 100644 --- a/Code/DisparityMap/otbStreamingWarpImageFilter.txx +++ b/Code/DisparityMap/otbStreamingWarpImageFilter.txx @@ -65,7 +65,7 @@ StreamingWarpImageFilter<TInputImage,TOutputImage,TDeformationField> // Compute the margin due to the maximum deformation value and interpolator radius for(unsigned int i = 0; i<InputImageType::ImageDimension;++i) { - radius[i]=interpolatorRadius + static_cast<unsigned int>(vcl_ceil(m_MaximumDeformation[i]/spacing[i])); + radius[i]= interpolatorRadius + static_cast<unsigned int>(vcl_ceil(m_MaximumDeformation[i]/vcl_abs(spacing[i]))); } otbMsgDevMacro(<<"WarpImageFilter: MaximumDeformation: "<<m_MaximumDeformation<<", interpolator radius: "<<interpolatorRadius<<", total radius: "<<radius); diff --git a/Testing/Code/Visu/CMakeLists.txt b/Testing/Code/Visu/CMakeLists.txt index 5b10f9d2f360d7a914a777a14fd938dc9b2742fe..96a89e462c114ff0e8d5134ef8b571f23bcd1143 100644 --- a/Testing/Code/Visu/CMakeLists.txt +++ b/Testing/Code/Visu/CMakeLists.txt @@ -179,6 +179,14 @@ ADD_TEST(viTvImageWidgetTransferFunctions ${VISU_TESTS2} ${TEMP}/viTvImageWidgetTransferFunctionsOutput.txt ) +#---------- otb::ImageViewer (Testing overlay, related to bug 35 ----------- +ADD_TEST(viTvImageViewerWithOverlay ${VISU_TESTS2} + otbImageViewerWithOverlay + ${INPUTDATA}/couleurs.tif + 128 + 128 +) + # ------- Fichiers sources CXX ----------------------------------- SET(BasicVisu_SRCS1 otbImageWidgetBaseNew.cxx @@ -206,6 +214,7 @@ otbHistogramAndTransferFunctionWidgetNew.cxx otbHistogramAndTransferFunctionWidget.cxx otbImageWidgetTransferFunctions.cxx otbImageWidgetTransferFunctionsNew.cxx +otbImageViewerWithOverlay.cxx ) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") diff --git a/Testing/Code/Visu/otbImageViewerWithOverlay.cxx b/Testing/Code/Visu/otbImageViewerWithOverlay.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b79402481fbcaf5b53536f947ac034d31d5e77e0 --- /dev/null +++ b/Testing/Code/Visu/otbImageViewerWithOverlay.cxx @@ -0,0 +1,96 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkExceptionObject.h" +#include "otbImageFileReader.h" +#include "otbImageViewer.h" +#include "otbMacro.h" +#include "itkBinaryThresholdImageFilter.h" +#include "otbChangeLabelImageFilter.h" + +int otbImageViewerWithOverlay( int argc, char * argv[] ) +{ + char * filename = argv[1]; + double upperThresh = atof(argv[2]); + unsigned char opacity = atoi(argv[3]); + + + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + typedef ImageViewerType::SingleImageType ImageType; + typedef ImageViewerType::ViewModelType ViewModelType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef ImageViewerType::OverlayImageType OverlayImageType; + typedef otb::Image<unsigned short,2> LabeledImageType; + typedef itk::BinaryThresholdImageFilter<ImageType,LabeledImageType> ThresholdFilterType; + typedef otb::ChangeLabelImageFilter<LabeledImageType,OverlayImageType> ChangeLabelFilterType; + typedef OverlayImageType::PixelType OverlayPixelType; + + // instantiation + ImageViewerType::Pointer viewer = ImageViewerType::New(); + ThresholdFilterType::Pointer thresh = ThresholdFilterType::New(); + ChangeLabelFilterType::Pointer chLabel = ChangeLabelFilterType::New(); + + // check for input images + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(filename); + reader->GenerateOutputInformation(); + + thresh->SetInput(reader->GetOutput()); + thresh->SetInsideValue(1); + thresh->SetOutsideValue(0); + thresh->SetLowerThreshold(0); + thresh->SetUpperThreshold(upperThresh); + + chLabel->SetInput(thresh->GetOutput()); + + OverlayPixelType insideValue,outsideValue; + + insideValue.SetSize(3); + insideValue.Fill(0); + insideValue[0]=255; + + outsideValue.SetSize(3); + outsideValue.Fill(0); + outsideValue[2]=255; + + chLabel->SetNumberOfComponentsPerPixel(3); + chLabel->SetChange(0,outsideValue); + chLabel->SetChange(1,insideValue); + chLabel->GetOutput()->UpdateOutputInformation(); + + + viewer->SetImage(reader->GetOutput()); + viewer->SetImageOverlay(chLabel->GetOutput()); + viewer->SetUseImageOverlay(true); + + // build the app + viewer->Build(); + viewer->SetImageOverlayOpacity(opacity); + viewer->SetViewModel(static_cast<ViewModelType>(0)); + viewer->Show(); + + Fl::check(); + + // Uncomment to hold display + // Fl::run(); + + return EXIT_SUCCESS; +} + + diff --git a/Testing/Code/Visu/otbVisuTests2.cxx b/Testing/Code/Visu/otbVisuTests2.cxx index 3b2e0005460eae7146f0f5042eec247994674a63..3ca2c6fcf30c7e3895f984d844df7c846d1aff48 100644 --- a/Testing/Code/Visu/otbVisuTests2.cxx +++ b/Testing/Code/Visu/otbVisuTests2.cxx @@ -39,4 +39,5 @@ REGISTER_TEST(otbHistogramAndTransferFunctionWidgetNew); REGISTER_TEST(otbHistogramAndTransferFunctionWidget); REGISTER_TEST(otbImageWidgetTransferFunctionsNew); REGISTER_TEST(otbImageWidgetTransferFunctions); +REGISTER_TEST(otbImageViewerWithOverlay); }