Skip to content
Snippets Groups Projects
Commit 537ba04e authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

DOC:obia

parent f06d29f0
Branches
Tags
No related merge requests found
...@@ -168,7 +168,7 @@ void ...@@ -168,7 +168,7 @@ void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage>
::GenerateParameters() ::GenerateParameters()
{ {
if(m_IsSetAtmosphericRadiativeTerms==false) if(!m_IsSetAtmosphericRadiativeTerms)
{ {
this->UpdateAtmosphericRadiativeTerms(); this->UpdateAtmosphericRadiativeTerms();
} }
......
...@@ -65,13 +65,14 @@ int main(int argc, char * argv[]) ...@@ -65,13 +65,14 @@ int main(int argc, char * argv[])
const int dim = 2; const int dim = 2;
typedef unsigned short PixelType; typedef unsigned short PixelType;
typedef otb::Image< PixelType, dim > ImageType; typedef otb::Image< PixelType, dim > ImageType;
// Software Guide : EndCodeSnippet
typedef itk::LabelObject< PixelType, dim > LabelObjectType; typedef itk::LabelObject< PixelType, dim > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType; typedef itk::LabelMap< LabelObjectType > LabelMapType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex // Software Guide : BeginLatex
// //
// The reader is instantiated and // As usual, the reader is instantiated and
// the input image is set. // the input image is set.
// //
// Software Guide : EndLatex // Software Guide : EndLatex
...@@ -91,7 +92,7 @@ int main(int argc, char * argv[]) ...@@ -91,7 +92,7 @@ int main(int argc, char * argv[])
// \item \code{FullyConnected}: Set whether the connected // \item \code{FullyConnected}: Set whether the connected
// components are defined strictly by face connectivity or by // components are defined strictly by face connectivity or by
// face+edge+vertex connectivity. Default is FullyConnectedOff. // 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. // pixel value of input/output of the foreground/background.
// the input image is set. // the input image is set.
// \end{itemize} // \end{itemize}
...@@ -109,7 +110,7 @@ int main(int argc, char * argv[]) ...@@ -109,7 +110,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex // 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 // The \doxygen{itk}{LabelMapToLabelImageFilter} converts a
// LabelMap to a labeled image. // LabelMap to a labeled image.
// //
......
...@@ -39,9 +39,7 @@ ...@@ -39,9 +39,7 @@
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
const int dim = 2;
typedef unsigned long PixelType;
typedef itk::Image< PixelType, dim > ImageType;
if( argc != 3) if( argc != 3)
{ {
...@@ -49,42 +47,95 @@ int main(int argc, char * argv[]) ...@@ -49,42 +47,95 @@ int main(int argc, char * argv[])
return EXIT_FAILURE; 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; typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New(); ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] ); 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 // is chosen in order to read some attribute related to the shape
// of the objects (by opposition to the content of the object, with // of the objects (by opposition to the content of the object, with
// the StatisticsLabelObejct). // the \doxygen{itk}{StatisticsLabelObject).
typedef unsigned long LabelType; //
typedef itk::ShapeLabelObject< LabelType, dim > LabelObjectType; // Software Guide : EndLatex
typedef itk::LabelMap< LabelObjectType > LabelMapType;
// convert the image in a collection of objects // Software Guide : BeginCodeSnippet
typedef itk::LabelImageToLabelMapFilter< ImageType, LabelMapType > ConverterType; 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(); ConverterType::Pointer converter = ConverterType::New();
converter->SetInput( reader->GetOutput() ); converter->SetInput( reader->GetOutput() );
converter->SetBackgroundValue( itk::NumericTraits<LabelType>::min() ); converter->SetBackgroundValue( itk::NumericTraits<LabelType>::min() );
typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType;
ShapeFilterType::Pointer shape = ShapeFilterType::New(); ShapeFilterType::Pointer shape = ShapeFilterType::New();
shape->SetInput( converter->GetOutput() ); 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(); shape->Update();
// Software Guide : EndCodeSnippet
std::cout << "Nb. objects conv. " << converter->GetOutput()->GetNumberOfLabelObjects() << std::endl; std::cout << "Nb. objects conv. " << converter->GetOutput()->GetNumberOfLabelObjects() << std::endl;
std::cout << "Nb. objects shape " << shape->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
// 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 // 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 // the label objects. If the labels are not consecutive, the GetNthLabelObject() method must be
// use instead of GetLabelObject(), or an iterator on the label // use instead of GetLabelObject(), or an iterator on the label
// object container of the label map. // 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(); LabelMapType::Pointer labelMap = shape->GetOutput();
for( unsigned long label=1; label<=labelMap->GetNumberOfLabelObjects(); label++ ) for( unsigned long label=1; label<=labelMap->GetNumberOfLabelObjects(); label++ )
...@@ -96,5 +147,7 @@ int main(int argc, char * argv[]) ...@@ -96,5 +147,7 @@ int main(int argc, char * argv[])
} }
outfile.close(); outfile.close();
// Software Guide : EndCodeSnippet
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment