Skip to content
Snippets Groups Projects
Commit 8eeed272 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

MRG

parents 04958bbc fd848145
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
......
......@@ -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}")
......
/*=========================================================================
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;
}
......@@ -39,4 +39,5 @@ REGISTER_TEST(otbHistogramAndTransferFunctionWidgetNew);
REGISTER_TEST(otbHistogramAndTransferFunctionWidget);
REGISTER_TEST(otbImageWidgetTransferFunctionsNew);
REGISTER_TEST(otbImageWidgetTransferFunctions);
REGISTER_TEST(otbImageViewerWithOverlay);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment