Commit b8b0d491 authored by Cédric Traizet's avatar Cédric Traizet

ENH : removed unused header and updated doc

parent 0cbf51bd
......@@ -19,29 +19,14 @@
*/
#include "otbMultiChannelExtractROI.h"
#include "otbExtractROI.h"
//#include "otbStreamingStatisticsImageFilter.h"
#include "otbSystem.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkChangeLabelImageFilter.h"
#include "otbTileImageFilter.h"
#include <time.h>
#include <algorithm>
#include <climits>
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "otbStandardWriterWatcher.h"
// New includes
#include "otbStreamingStatisticsMapFromLabelImageFilter.h"
#include "otbLabelImageSmallRegionMergingFilter.h"
#include "itkChangeLabelImageFilter.h"
namespace otb
{
......@@ -60,9 +45,6 @@ public:
typedef UInt32ImageType LabelImageType;
typedef LabelImageType::InternalPixelType LabelImagePixelType;
typedef otb::MultiChannelExtractROI <ImagePixelType,ImagePixelType > MultiChannelExtractROIFilterType;
typedef otb::ExtractROI<LabelImagePixelType,LabelImagePixelType> ExtractROIFilterType;
//typedef otb::StreamingStatisticsImageFilter<LabelImageType> StatisticsImageFilterType;
typedef otb::StreamingStatisticsMapFromLabelImageFilter<ImageType, LabelImageType> StatisticsMapFromLabelImageFilterType;
......@@ -79,7 +61,7 @@ private:
void DoInit() override
{
SetName("SmallRegionsMerging");
SetDescription("This application performs the third (optional) step of the exact Large-Scale Mean-Shift segmentation workflow [1].");
SetDescription("This application merges small regions of a segmentation result to connected region.");
SetDocName("Small Region Merging");
SetDocLongDescription("Given a segmentation result and the original image, it will"
......@@ -89,21 +71,20 @@ private:
"Small segments will be processed by increasing size: first all segments"
" for which area is equal to 1 pixel will be merged with adjacent"
" segments, then all segments of area equal to 2 pixels will be processed,"
" until segments of area minsize. For large images one can use the"
" tilesizex and tilesizey parameters for tile-wise processing, with the"
" guarantees of identical results.\n\n");
" until segments of area minsize."
" \n\n");
SetDocLimitations("This application is more efficient if the labels are contiguous, starting from 0.");
SetDocAuthors("OTB-Team");
SetDocSeeAlso( "Segmentation");
AddDocTag(Tags::Segmentation);
AddParameter(ParameterType_InputImage, "in", "Input image");
AddParameter(ParameterType_InputImage, "in", "Input image");
SetParameterDescription( "in", "The input image, containing initial spectral signatures corresponding to the segmented image (inseg)." );
AddParameter(ParameterType_InputImage, "inseg", "Segmented image");
AddParameter(ParameterType_InputImage, "inseg", "Segmented image");
SetParameterDescription( "inseg", "Segmented image where each pixel value is the unique integer label of the segment it belongs to." );
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription( "out", "The output image. The output image is the segmented image where the minimal segments have been merged. An ecoding of uint32 is advised." );
SetParameterDescription( "out", "The output image. The output image is the segmented image where the minimal segments have been merged." );
SetDefaultOutputPixelType("out",ImagePixelType_uint32);
AddParameter(ParameterType_Int, "minsize", "Minimum Segment Size");
......@@ -118,7 +99,7 @@ private:
SetDocExampleParameterValue("in","smooth.tif");
SetDocExampleParameterValue("inseg","segmentation.tif");
SetDocExampleParameterValue("out","merged.tif");
SetDocExampleParameterValue("minsize","20");
SetDocExampleParameterValue("minsize","50");
SetOfficialDocLink();
}
......@@ -159,6 +140,7 @@ private:
meanValues.push_back(meanValueMap[i]);
}
// Compute the LUT from the original label image to the merged output label image.
auto regionMergingFilter = LabelImageSmallRegionMergingFilterType::New();
regionMergingFilter->SetInput( labelIn );
regionMergingFilter->SetLabelPopulation( labelPopulation );
......@@ -169,7 +151,7 @@ private:
AddProcess(regionMergingFilter, "Computing LUT ...");
regionMergingFilter->Update();
//Relabelling
// Relabelling using the LUT
auto changeLabelFilter = ChangeLabelImageFilterType::New();
changeLabelFilter->SetInput(labelIn);
auto LUT = regionMergingFilter->GetLUT();
......@@ -184,7 +166,6 @@ private:
SetParameterOutputImage("out", changeLabelFilter->GetOutput());
RegisterPipeline();
clock_t toc = clock();
otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds");
}
......
......@@ -139,7 +139,7 @@ protected:
PersistentLabelImageSmallRegionMergingFilter();
/** Destructor */
~PersistentLabelImageSmallRegionMergingFilter() override;
~PersistentLabelImageSmallRegionMergingFilter() override = default;
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
......@@ -240,7 +240,7 @@ protected:
/** Constructor */
LabelImageSmallRegionMergingFilter();
/** Destructor */
~LabelImageSmallRegionMergingFilter() override {}
~LabelImageSmallRegionMergingFilter() override = default;
/** Generate Data method (Update LabelImageSmallRegionMergingFilterType recursively) */
void GenerateData();
......
......@@ -36,13 +36,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
{
}
template <class TInputLabelImage >
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
::~PersistentLabelImageSmallRegionMergingFilter()
{
}
template <class TInputLabelImage >
void
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
......@@ -52,7 +45,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
m_NeighboursMapsTmp.resize( this->GetNumberOfThreads() );
}
template <class TInputLabelImage >
void
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
......@@ -106,6 +98,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
}
}
// Update the LUT
for(InputLabelType label = 0; label < m_LUT.size(); ++label)
{
InputLabelType can = label;
......@@ -116,7 +109,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
m_LUT[label] = can;
}
// Update Statistics
for(InputLabelType label = 0; label < m_LUT.size(); ++label)
{
InputLabelType correspondingLabel = m_LUT[label];
......@@ -261,7 +254,8 @@ LabelImageSmallRegionMergingFilter< TInputLabelImage >
this->SetProgress(0.0);
auto labelImage = this->GetInput();
m_SmallRegionMergingFilter->GetFilter()->SetInput( labelImage );
m_SmallRegionMergingFilter->GetStreamer()->SetAutomaticTiledStreaming();
// Update the filter for all sizes.
for (unsigned int size = 1; size < m_MinSize; size++)
{
m_SmallRegionMergingFilter->GetFilter()->SetSize( size) ;
......
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