Image segmentation covers techniques for splitting one image into its components as homogeneous regions.
Input:
Output:
The available method in TerraLib is:
The following methods will be implemented in TerraLib:
Creates regions by merging similar neighboring pixels. To reduce processing time, the raster is divided into pieces, and such pieces are segmented individually.
Algorithm parameters:
References:
To make a segmentation using Region Growing algorithm, the following parameters are necessary:
// ... (set input data) // link specific parameters with chosen implementation te::rp::SegmenterRegionGrowingStrategy::Parameters segparameters; segparameters.m_minSegmentSize = 50; segparameters.m_segmentsSimilarityThreshold = 30; algoInputParameters.m_strategyName = "regiongrowing"; algoInputParameters.setSegStrategyParams(segparameters); // ... (set output data and start algorithm)
Creates regions by merging similar neighboring pixels. The resultant regions must fit a predefined scale and compactness, provided by the user.
Algorithm parameters:
References:
To make a segmentation using Baatz and Shape algorithm, the following parameters are necessary:
// ... (set input data) // link specific parameters with chosen implementation te::rp::SegmenterRegionGrowingStrategy::Parameters segparameters; segparameters.m_compactness = 0.5; segparameters.m_color = 0.3; segparameters.m_scale = 60; algoInputParameters.m_strategyName = "baatz"; algoInputParameters.setSegStrategyParams(segparameters); // ... (set output data and start algorithm)
<color red>Code under development!!!</color>
This algorithm performs pixel-based classification using a geographic approach of the Self-Organizing Maps algorithm. Then neighboring pixels of the same class define the regions.
References:
To make a segmentation using Self Organizing Maps algorithm, the following parameters are necessary:
// ... (set input data) // link specific parameters with chosen implementation te::rp::SegmenterRegionGrowingStrategy::Parameters segparameters; segparameters.m_mapHeight = 3; segparameters.m_mapWidth = 4; segparameters.m_radius = 20; segparameters.m_alpha = 50; segparameters.m_K = 30; algoInputParameters.m_strategyName = "som"; algoInputParameters.setSegStrategyParams(segparameters); // ... (set output data and start algorithm)
<color red>Code under development!!!</color>
The following code shows how to perform a segmentation using Region Growing method.
// open input raster std::map<std::string, std::string> rinfo; rinfo["URI"] = "input.tif"; te::rst::Raster* rin = te::rst::RasterFactory::open(rinfo); // define segmentation parameters // input parameters te::rp::Segmenter::InputParameters algoInputParameters; algoInputParameters.m_inputRasterPtr = rin; algoInputParameters.m_inputRasterBands.push_back(0); algoInputParameters.m_inputRasterBands.push_back(1); algoInputParameters.m_inputRasterBands.push_back(2); // link specific parameters with chosen implementation te::rp::SegmenterRegionGrowingStrategy::Parameters segparameters; segparameters.m_minSegmentSize = 50; segparameters.m_segmentsSimilarityThreshold = 30; algoInputParameters.m_strategyName = "regiongrowing"; algoInputParameters.setSegStrategyParams(segparameters); // output parameters te::rp::Segmenter::OutputParameters algoOutputParameters; std::map<std::string, std::string> orinfo; orinfo["URI"] = "output-segmentation.tif"; algoOutputParameters.m_rInfo = orinfo; algoOutputParameters.m_rType = "GDAL"; // execute the algorithm te::rp::Segmenter seginstance; bool initok = seginstance.initialize(algoInputParameters); if(initok) seginstance.execute(algoOutputParameters); // clean up delete rin;