Table of Contents
RP → Mixture Model
This module implements raster decomposition using the mixture model strategy. The spatial resolution of remote sensing satellites, in general, allows that a single pixel contains more than a target (for example vegetation + shadow + soil). The mixture model algorithms allow to decompose the raster into fraction images, where the value of the resultant pixels indicate the fraction of each target inside the pixel.
Input:
- One Raster
- A map of pure endmembers, which are pixel values where the user knows the exact proportion of a component.
- Sensor information for each band, if available
The available methods in TerraLib are:
Linear
It is calculated by the following equation: $$r_i = \sum_{j = 1}^n a_{ij} x_j + e_i$$ where
- $r_i$ is the pixel value at band $i$
- $a_{ij}$ is the known value of the component $j$ at band $i$
- $x_j$ is the proportion of component $j$
- $e_i$ is the estimation error for band $i$
PCA
The component matrix is transformed using Principal Component Analysis, and the fraction of each component is obtained by using the proper number of eigenvectors.
From theory to practice
// open input raster std::map<std::string, std::string> rinfo; rinfo["URI"] = "input.tif"; te::rst::Raster* rin = te::rst::RasterFactory::open(rinfo); // create algorithm parameters te::rp::MixtureModel::InputParameters mmInputParameters; te::rp::MixtureModel::OutputParameters mmOutputParameters; // defining input parameters mmInputParameters.m_inputRasterPtr = rin; for (unsigned b = 0; b < rin->getNumberOfBands(); b++) mmInputParameters.m_inputRasterBands.push_back(b); mmInputParameters.m_strategyName = "linear"; // can be "pca" instead to use principal components analysis // link specific parameters with chosen implementation te::rp::MixtureModelLinearStrategy::Parameters lmmParameters; mmInputParameters.setMixtureModelStrategyParams(lmmParameters); // defining endmembers mmInputParameters.m_components["clouds"].push_back(255.0); mmInputParameters.m_components["clouds"].push_back(184.875); mmInputParameters.m_components["clouds"].push_back(255.0); mmInputParameters.m_components["shadow"].push_back(42.075); mmInputParameters.m_components["shadow"].push_back(24.99); mmInputParameters.m_components["shadow"].push_back(49.98); mmInputParameters.m_components["vegetation"].push_back(99.96); mmInputParameters.m_components["vegetation"].push_back(64.005); mmInputParameters.m_components["vegetation"].push_back(154.02); // defining sensor information mmInputParameters.m_inputSensorBands.push_back("CBERS2_CCD_3_RED"); mmInputParameters.m_inputSensorBands.push_back("CBERS2_CCD_4_NIR"); mmInputParameters.m_inputSensorBands.push_back("CBERS2_CCD_2_GREEN"); // defining output parameters std::map<std::string, std::string> orinfo; orinfo["URI"] = "output-linear-mm.tif"; mmOutputParameters.m_rInfo = orinfo; mmOutputParameters.m_rType = "GDAL"; mmOutputParameters.m_normalizeOutput = true; mmOutputParameters.m_createErrorRaster = true; // execute the algorithm te::rp::MixtureModel mmInstance; bool initok = mmInstance.initialize(mmInputParameters); if (initok) mmInstance.execute(mmOutputParameters); // clean up delete rin;
Dependencies: Raster