Request for Changes-67: ClassificationMapRegularization option for isolated pixels only
[Request for Changes - 67] ClassificationMapRegularization option for isolated pixels only
- Author: Jordi Inglada
- Additional Contributors (if different than authors)
- Submitted on 29.09.2016
- Proposed target release : 5.8
- Adopted (+3 from Julien, Victor, Guillaume)
- Merged : 1a8588c23f45d269d754cafcc60d17d3fe3d46e3
This RFC proposes a new option for the ClassificationMapRegularization to process isolated pixels only.
The current implementation of the majority voting in a neighbourhood used by the ClassificationMapRegularization application filters all pixels of the image. In many cases, this ends up with rounded corners or even spurious additional pixels depending on the distribution of the labels in the local window. Most of the times, a simple regularization which only processes isolated pixels (the center pixel has a label different from all other pixels in the window) is what is needed. This RFC addresses this issue. The concept of "isolated pixel" is defined as a pixel which has a label for which there is fewer pixels than a given threshold with the same label. The most usual case is when this threshold is equal to 1 and therefore the label of the center pixel is unique in the window.
Two parameters have been added to the application:
- "ip.olyisolatedpixels", "Only pixels whose label is unique in the neighbordhood will be processed. By default, 'false'."
- "ip.isolatedthreshold", "Maximum number of neighbours with the same label as the center pixel to consider that it is an isolated pixel. By default, '1'."
They are forwarded to the otb::NeighborhoodMajorityVotingImageFilter.
The default behaviour is the same as before the addition of the parameters.
Classes and files
M Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h M Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx
Before adding the new option, some refactoring has been performed on the Evaluate() method of the filter, which mainly consist of moving the code for filling the label histogram to a dedicated method and using STL algorithms to find the majority label. Also a new struct (protected to the class) is provided for sorting the histogram in decreasing values of the frequencies of the label, which makes finding the maximum frequency, but also checking for a tie trivial.
For the new option, to class member variables have been added:
- bool m_OnlyIsolatedPixels;
- unsigned int m_IsolatedThreshold //The center pixel is isolated if there are fewer neighbours than this threshold with the same label
M Modules/Fusion/MajorityVoting/test/CMakeLists.txt M Modules/Fusion/MajorityVoting/test/otbMajorityVotingTestDriver.cxx M Modules/Fusion/MajorityVoting/test/otbNeighborhoodMajorityVotingImageFilterTest.cxx
A test without the need of a baseline has been added to verify the correctness of the new option.