Skip to content
Snippets Groups Projects
Commit 6f15ca4e authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

BUG: add test for bug 479 : writing int8 image

parent dd140d13
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
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.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "otbImage.h"
#include "otbImageFileWriter.h"
#include "otbImageFileReader.h"
#include "itkImageRegionIterator.h"
int main(int argc, char* argv[])
{
typedef char PixelType;
const char * out = argv[1];
const PixelType value = static_cast<PixelType>(atof(argv[2] ));
typedef otb::Image<PixelType, 2> ImageType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef itk::ImageRegionIterator<ImageType> IterType;
ImageType::IndexType id;
ImageType::SizeType size;
ImageType::RegionType region;
id.Fill(0);
size.Fill(10);
region.SetSize( size );
region.SetIndex( id );
ImageType::Pointer image = ImageType::New();
ImageType::PixelType pix;
image->SetRegions(region);
image->Allocate();
image->FillBuffer(value);
IterType it1( image, region );
it1.GoToBegin();
it1.GoToBegin();
while( !it1.IsAtEnd() )
{
if( value != it1.Get() )
{
std::cout<<"Allocated image pixel value "<<it1.Get()<<" differs from the asked one "<<(double)value<<"."<<std::endl;
return EXIT_FAILURE;
}
++it1;
}
WriterType::Pointer writer = WriterType::New();
writer->SetInput(image);
writer->SetFileName(out);
writer->Update();
typedef otb::Image<double, 2> ReaderImageType;
typedef otb::ImageFileReader<ReaderImageType> ReaderType;
typedef itk::ImageRegionIterator<ReaderImageType> ReaderIterType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(out);
reader->Update();
ReaderIterType it2( reader->GetOutput(), region );
it2.GoToBegin();
while( !it2.IsAtEnd() )
{
if( value != it2.Get() )
{
std::cout<<"Read image pixel value "<<it2.Get()<<" differs from the asked one "<<(double)value<<"."<<std::endl;
return EXIT_FAILURE;
}
++it2;
}
return EXIT_SUCCESS;
}
SET(TEMP ${OTBTesting_BINARY_DIR}/Temporary)
# Failing tests showing bugs
# ------- Compare region propagation of ExtractROI filters ------------------------------
ADD_TEST(FA-000307-ExtractROIRegion ${CXX_TEST_PATH}/0000307-ExtractROICompareRegion)
ADD_EXECUTABLE(0000307-ExtractROICompareRegion 0000307-ExtractROICompareRegionsImplementations.cxx)
TARGET_LINK_LIBRARIES(0000307-ExtractROICompareRegion OTBIO OTBCommon)
# ------- Write an int8 image ------------------------------
ADD_TEST(FA-0000479-WriteInt8Image ${CXX_TEST_PATH}/0000479-WriteInt8Image
${TEMP}/FA-0000479-WriteInt8Image.tif
-10)
ADD_EXECUTABLE(0000479-WriteInt8Image 0000479-WriteInt8Image.cxx)
TARGET_LINK_LIBRARIES(0000479-WriteInt8Image OTBIO OTBCommon)
ADD_TEST(FA-000209-SVMValidationLinearlySeparableWithProbEstimate_KO ${CXX_TEST_PATH}/0000209-SVMValidationLinearlySeparableProbEstimation
0000209-SVMValidationLinearlySeparableProbEstimation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 1)
ADD_EXECUTABLE(0000307-ExtractROICompareRegion 0000307-ExtractROICompareRegionsImplementations.cxx)
TARGET_LINK_LIBRARIES(0000307-ExtractROICompareRegion OTBIO OTBCommon)
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