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

ENH : removed unused header and updated doc

No related merge requests found
Showing with 16 additions and 41 deletions
+16 -41
...@@ -19,29 +19,14 @@ ...@@ -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 <time.h>
#include <algorithm>
#include <climits>
#include "otbWrapperApplication.h" #include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h" #include "otbWrapperApplicationFactory.h"
#include "otbStandardWriterWatcher.h"
// New includes
#include "otbStreamingStatisticsMapFromLabelImageFilter.h" #include "otbStreamingStatisticsMapFromLabelImageFilter.h"
#include "otbLabelImageSmallRegionMergingFilter.h" #include "otbLabelImageSmallRegionMergingFilter.h"
#include "itkChangeLabelImageFilter.h"
namespace otb namespace otb
{ {
...@@ -60,9 +45,6 @@ public: ...@@ -60,9 +45,6 @@ public:
typedef UInt32ImageType LabelImageType; typedef UInt32ImageType LabelImageType;
typedef LabelImageType::InternalPixelType LabelImagePixelType; typedef LabelImageType::InternalPixelType LabelImagePixelType;
typedef otb::MultiChannelExtractROI <ImagePixelType,ImagePixelType > MultiChannelExtractROIFilterType;
typedef otb::ExtractROI<LabelImagePixelType,LabelImagePixelType> ExtractROIFilterType;
//typedef otb::StreamingStatisticsImageFilter<LabelImageType> StatisticsImageFilterType; //typedef otb::StreamingStatisticsImageFilter<LabelImageType> StatisticsImageFilterType;
typedef otb::StreamingStatisticsMapFromLabelImageFilter<ImageType, LabelImageType> StatisticsMapFromLabelImageFilterType; typedef otb::StreamingStatisticsMapFromLabelImageFilter<ImageType, LabelImageType> StatisticsMapFromLabelImageFilterType;
...@@ -79,7 +61,7 @@ private: ...@@ -79,7 +61,7 @@ private:
void DoInit() override void DoInit() override
{ {
SetName("SmallRegionsMerging"); 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"); SetDocName("Small Region Merging");
SetDocLongDescription("Given a segmentation result and the original image, it will" SetDocLongDescription("Given a segmentation result and the original image, it will"
...@@ -89,21 +71,20 @@ private: ...@@ -89,21 +71,20 @@ private:
"Small segments will be processed by increasing size: first all segments" "Small segments will be processed by increasing size: first all segments"
" for which area is equal to 1 pixel will be merged with adjacent" " 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," " 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" " until segments of area minsize."
" tilesizex and tilesizey parameters for tile-wise processing, with the" " \n\n");
" guarantees of identical results.\n\n");
SetDocLimitations("This application is more efficient if the labels are contiguous, starting from 0."); SetDocLimitations("This application is more efficient if the labels are contiguous, starting from 0.");
SetDocAuthors("OTB-Team"); SetDocAuthors("OTB-Team");
SetDocSeeAlso( "Segmentation"); SetDocSeeAlso( "Segmentation");
AddDocTag(Tags::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)." ); 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." ); 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"); 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); SetDefaultOutputPixelType("out",ImagePixelType_uint32);
AddParameter(ParameterType_Int, "minsize", "Minimum Segment Size"); AddParameter(ParameterType_Int, "minsize", "Minimum Segment Size");
...@@ -118,7 +99,7 @@ private: ...@@ -118,7 +99,7 @@ private:
SetDocExampleParameterValue("in","smooth.tif"); SetDocExampleParameterValue("in","smooth.tif");
SetDocExampleParameterValue("inseg","segmentation.tif"); SetDocExampleParameterValue("inseg","segmentation.tif");
SetDocExampleParameterValue("out","merged.tif"); SetDocExampleParameterValue("out","merged.tif");
SetDocExampleParameterValue("minsize","20"); SetDocExampleParameterValue("minsize","50");
SetOfficialDocLink(); SetOfficialDocLink();
} }
...@@ -159,6 +140,7 @@ private: ...@@ -159,6 +140,7 @@ private:
meanValues.push_back(meanValueMap[i]); meanValues.push_back(meanValueMap[i]);
} }
// Compute the LUT from the original label image to the merged output label image.
auto regionMergingFilter = LabelImageSmallRegionMergingFilterType::New(); auto regionMergingFilter = LabelImageSmallRegionMergingFilterType::New();
regionMergingFilter->SetInput( labelIn ); regionMergingFilter->SetInput( labelIn );
regionMergingFilter->SetLabelPopulation( labelPopulation ); regionMergingFilter->SetLabelPopulation( labelPopulation );
...@@ -169,7 +151,7 @@ private: ...@@ -169,7 +151,7 @@ private:
AddProcess(regionMergingFilter, "Computing LUT ..."); AddProcess(regionMergingFilter, "Computing LUT ...");
regionMergingFilter->Update(); regionMergingFilter->Update();
//Relabelling // Relabelling using the LUT
auto changeLabelFilter = ChangeLabelImageFilterType::New(); auto changeLabelFilter = ChangeLabelImageFilterType::New();
changeLabelFilter->SetInput(labelIn); changeLabelFilter->SetInput(labelIn);
auto LUT = regionMergingFilter->GetLUT(); auto LUT = regionMergingFilter->GetLUT();
...@@ -184,7 +166,6 @@ private: ...@@ -184,7 +166,6 @@ private:
SetParameterOutputImage("out", changeLabelFilter->GetOutput()); SetParameterOutputImage("out", changeLabelFilter->GetOutput());
RegisterPipeline(); RegisterPipeline();
clock_t toc = clock(); clock_t toc = clock();
otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds"); otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds");
} }
......
...@@ -139,7 +139,7 @@ protected: ...@@ -139,7 +139,7 @@ protected:
PersistentLabelImageSmallRegionMergingFilter(); PersistentLabelImageSmallRegionMergingFilter();
/** Destructor */ /** Destructor */
~PersistentLabelImageSmallRegionMergingFilter() override; ~PersistentLabelImageSmallRegionMergingFilter() override = default;
/** PrintSelf method */ /** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const override; void PrintSelf(std::ostream& os, itk::Indent indent) const override;
...@@ -240,7 +240,7 @@ protected: ...@@ -240,7 +240,7 @@ protected:
/** Constructor */ /** Constructor */
LabelImageSmallRegionMergingFilter(); LabelImageSmallRegionMergingFilter();
/** Destructor */ /** Destructor */
~LabelImageSmallRegionMergingFilter() override {} ~LabelImageSmallRegionMergingFilter() override = default;
/** Generate Data method (Update LabelImageSmallRegionMergingFilterType recursively) */ /** Generate Data method (Update LabelImageSmallRegionMergingFilterType recursively) */
void GenerateData(); void GenerateData();
......
...@@ -36,13 +36,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > ...@@ -36,13 +36,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
{ {
} }
template <class TInputLabelImage >
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
::~PersistentLabelImageSmallRegionMergingFilter()
{
}
template <class TInputLabelImage > template <class TInputLabelImage >
void void
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
...@@ -52,7 +45,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > ...@@ -52,7 +45,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
m_NeighboursMapsTmp.resize( this->GetNumberOfThreads() ); m_NeighboursMapsTmp.resize( this->GetNumberOfThreads() );
} }
template <class TInputLabelImage > template <class TInputLabelImage >
void void
PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
...@@ -106,6 +98,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > ...@@ -106,6 +98,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
} }
} }
// Update the LUT
for(InputLabelType label = 0; label < m_LUT.size(); ++label) for(InputLabelType label = 0; label < m_LUT.size(); ++label)
{ {
InputLabelType can = label; InputLabelType can = label;
...@@ -116,7 +109,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > ...@@ -116,7 +109,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
m_LUT[label] = can; m_LUT[label] = can;
} }
// Update Statistics
for(InputLabelType label = 0; label < m_LUT.size(); ++label) for(InputLabelType label = 0; label < m_LUT.size(); ++label)
{ {
InputLabelType correspondingLabel = m_LUT[label]; InputLabelType correspondingLabel = m_LUT[label];
...@@ -261,7 +254,8 @@ LabelImageSmallRegionMergingFilter< TInputLabelImage > ...@@ -261,7 +254,8 @@ LabelImageSmallRegionMergingFilter< TInputLabelImage >
this->SetProgress(0.0); this->SetProgress(0.0);
auto labelImage = this->GetInput(); auto labelImage = this->GetInput();
m_SmallRegionMergingFilter->GetFilter()->SetInput( labelImage ); m_SmallRegionMergingFilter->GetFilter()->SetInput( labelImage );
m_SmallRegionMergingFilter->GetStreamer()->SetAutomaticTiledStreaming();
// Update the filter for all sizes.
for (unsigned int size = 1; size < m_MinSize; size++) for (unsigned int size = 1; size < m_MinSize; size++)
{ {
m_SmallRegionMergingFilter->GetFilter()->SetSize( size) ; m_SmallRegionMergingFilter->GetFilter()->SetSize( size) ;
......
Supports Markdown
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