Commit 537ba04e authored by Manuel Grizonnet's avatar Manuel Grizonnet

DOC:obia

parent f06d29f0
......@@ -168,7 +168,7 @@ void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage>
::GenerateParameters()
{
if(m_IsSetAtmosphericRadiativeTerms==false)
if(!m_IsSetAtmosphericRadiativeTerms)
{
this->UpdateAtmosphericRadiativeTerms();
}
......
......@@ -65,13 +65,14 @@ int main(int argc, char * argv[])
const int dim = 2;
typedef unsigned short PixelType;
typedef otb::Image< PixelType, dim > ImageType;
// Software Guide : EndCodeSnippet
typedef itk::LabelObject< PixelType, dim > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The reader is instantiated and
// As usual, the reader is instantiated and
// the input image is set.
//
// Software Guide : EndLatex
......@@ -91,7 +92,7 @@ int main(int argc, char * argv[])
// \item \code{FullyConnected}: Set whether the connected
// components are defined strictly by face connectivity or by
// face+edge+vertex connectivity. Default is FullyConnectedOff.
// \item InputForegroundValue/OutputBackgroundValue specify the
// \item \code{InputForegroundValue/OutputBackgroundValue}: specify the
// pixel value of input/output of the foreground/background.
// the input image is set.
// \end{itemize}
......@@ -109,7 +110,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// Then the inverse process is .
// Then the inverse process is uses to recreate a image of labels.
// The \doxygen{itk}{LabelMapToLabelImageFilter} converts a
// LabelMap to a labeled image.
//
......
......@@ -39,9 +39,7 @@
int main(int argc, char * argv[])
{
const int dim = 2;
typedef unsigned long PixelType;
typedef itk::Image< PixelType, dim > ImageType;
if( argc != 3)
{
......@@ -49,42 +47,95 @@ int main(int argc, char * argv[])
return EXIT_FAILURE;
}
// read the input image
// Software Guide : BeginLatex
//
// The image types are defined using pixel types and
// dimension. The input image is defined as an \doxygen{otb}{Image}.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
const int dim = 2;
typedef unsigned long PixelType;
typedef itk::Image< PixelType, dim > ImageType;
typedef unsigned long LabelType;
typedef itk::ShapeLabelObject< LabelType, dim > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
typedef itk::LabelImageToLabelMapFilter< ImageType, LabelMapType > ConverterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Firstly, the image reader is instantiated.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
// Software Guide : EndCodeSnippet
// define the object type. Here the ShapeLabelObject type
// Software Guide : BeginLatex
//
// Here the ShapeLabelObject type
// is chosen in order to read some attribute related to the shape
// of the objects (by opposition to the content of the object, with
// the StatisticsLabelObejct).
typedef unsigned long LabelType;
typedef itk::ShapeLabelObject< LabelType, dim > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
// the \doxygen{itk}{StatisticsLabelObject).
//
// Software Guide : EndLatex
// convert the image in a collection of objects
typedef itk::LabelImageToLabelMapFilter< ImageType, LabelMapType > ConverterType;
// Software Guide : BeginCodeSnippet
typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The input image is converted in a collection of objects
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
ConverterType::Pointer converter = ConverterType::New();
converter->SetInput( reader->GetOutput() );
converter->SetBackgroundValue( itk::NumericTraits<LabelType>::min() );
typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType;
ShapeFilterType::Pointer shape = ShapeFilterType::New();
shape->SetInput( converter->GetOutput() );
// update the shape filter, so its output will be up to date
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Update the shape filter, so its output will be up to date.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
shape->Update();
// Software Guide : EndCodeSnippet
std::cout << "Nb. objects conv. " << converter->GetOutput()->GetNumberOfLabelObjects() << std::endl;
std::cout << "Nb. objects shape " << shape->GetOutput()->GetNumberOfLabelObjects() << std::endl;
// then we can read the attribute values we're interested in. The BinaryImageToShapeLabelMapFilter
std::cout << "Nb. objects shape " << shape->GetOutput()->GetNumberOfLabelObjects() << std::endl;
// Software Guide : BeginLatex
//
// Then, we can read the attribute values we're interested in. The \doxygen{itk}{BinaryImageToShapeLabelMapFilter
// produce consecutive labels, so we can use a for loop and GetLabelObject() method to retrieve
// the label objects. If the labels are not consecutive, the GetNthLabelObject() method must be
// use instead of GetLabelObject(), or an iterator on the label
// object container of the label map.
std::ofstream outfile( argv[2] );
// In this example, we print 2 shape attributes of each object to a text file (the size and the centroid coordinates).
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
std::ofstream outfile( argv[2] );
LabelMapType::Pointer labelMap = shape->GetOutput();
for( unsigned long label=1; label<=labelMap->GetNumberOfLabelObjects(); label++ )
......@@ -96,5 +147,7 @@ int main(int argc, char * argv[])
}
outfile.close();
// Software Guide : EndCodeSnippet
return EXIT_SUCCESS;
}
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