Commit 8091de84 authored by Jordi Inglada's avatar Jordi Inglada

DOC: pretty image production for example

parent 1d2e5058
......@@ -27,6 +27,8 @@ ADD_TEST( trTeOBIAImageToLabelToImageTest ${EXE_TESTS}
OBIAImageToLabelToImageTest
${INPUTDATA}/MSLabeledOutput.tif
${TEMP}/OBIAI2L2IOutput.tif
${TEMP}/OBIAI2L2IInPretty.tif
${TEMP}/OBIAI2L2IOutPretty.tif
1 1108 0
)
......
......@@ -19,7 +19,7 @@
// Software Guide : BeginCommandLineArgs
// INPUTS: {MSLabeledOutput.tif}
// OUTPUTS: {OBIAI2L2IOutput.tif}
// OUTPUTS: {OBIAI2L2IOutput.tif}, {OBIAI2L2IInputPretty.tif}, {OBIAI2L2IOutputPretty.tif}
// 1 1108 0
// Software Guide : EndCommandLineArgs
......@@ -39,17 +39,18 @@
#include "itkLabelMapToLabelImageFilter.h"
// Software Guide : EndCodeSnippet
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
int main(int argc, char * argv[])
{
if( argc != 6 )
if( argc != 8 )
{
std::cerr << "usage: " << argv[0] << " input output conn fg bg" << std::endl;
std::cerr << "usage: " << argv[0] << " input output inPretty outPretty conn fg bg" << std::endl;
exit(1);
}
......@@ -57,7 +58,7 @@ int main(int argc, char * argv[])
typedef unsigned short PixelType;
typedef itk::Image< PixelType, dim > ImageType;
typedef otb::Image< PixelType, dim > ImageType;
typedef itk::LabelObject< PixelType, dim > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
......@@ -69,9 +70,9 @@ int main(int argc, char * argv[])
typedef itk::BinaryImageToLabelMapFilter< ImageType, LabelMapType> I2LType;
I2LType::Pointer i2l = I2LType::New();
i2l->SetInput( reader->GetOutput() );
i2l->SetFullyConnected( atoi(argv[3]) );
i2l->SetForegroundValue( atoi(argv[4]) );
i2l->SetBackgroundValue( atoi(argv[5]) );
i2l->SetFullyConnected( atoi(argv[5]) );
i2l->SetForegroundValue( atoi(argv[6]) );
i2l->SetBackgroundValue( atoi(argv[7]) );
typedef itk::LabelMapToLabelImageFilter< LabelMapType, ImageType> L2IType;
L2IType::Pointer l2i = L2IType::New();
......@@ -83,6 +84,26 @@ int main(int argc, char * argv[])
writer->SetFileName( argv[2] );
writer->Update();
// Pretty image creation for the printing
typedef otb::Image<unsigned char, dim> OutputPrettyImageType;
typedef otb::ImageFileWriter<OutputPrettyImageType> WriterPrettyType;
typedef itk::RescaleIntensityImageFilter< ImageType, OutputPrettyImageType> RescalerType;
RescalerType::Pointer rescaler = RescalerType::New();
WriterPrettyType::Pointer prettyWriter = WriterPrettyType::New();
rescaler->SetInput( reader->GetOutput() );
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
prettyWriter->SetFileName( argv[3] );
prettyWriter->SetInput( rescaler->GetOutput() );
prettyWriter->Update();
rescaler->SetInput( l2i->GetOutput() );
prettyWriter->SetFileName( argv[4] );
prettyWriter->SetInput( rescaler->GetOutput() );
prettyWriter->Update();
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment