Commit ee33a11c authored by Marina Bertolino's avatar Marina Bertolino

ENH: add the internal ComputeImagesStatistics app and connect

parent fd2eb9cb
......@@ -56,7 +56,8 @@ private:
3) SampleSelection : select the samples by constant strategy in the shapefile, \
4) SamplesExtraction : extract the samples descriptors, \
5) TrainVectorClassifier : train the SharkKMeans model, \
6) ImageClassifier : performs the classification of the input image according to a model file."
6) ComputeImagesStatistics : compute images second order statistics, \
7) ImageClassifier : performs the classification of the input image according to a model file."
"If you want keep the temporary files (sample selected, model file, ...), initialize cleanup parameter.");
......@@ -123,6 +124,9 @@ private:
fileNames.sampleExtractOutput,
actualNBSamplesForKMeans);
// Compute Images second order statistics
ComputeImageStatistics(GetParameterString("in"), fileNames.imgStatOutput);
// Compute a train model with TrainVectorClassifier app
TrainKMModel(GetParameterImage("in"), fileNames.sampleExtractOutput,
fileNames.modelFile);
......
......@@ -116,6 +116,14 @@ public:
std::string sampleTrainFileName,
std::string modelFileName);
/**
* Compute image second order statistics
* \param imageFileName input image filename
* \param imagesStatsFileName image statistics
*/
void ComputeImageStatistics(std::string imageFileName,
std::string imagesStatsFileName);
/**
* Performs a classification of the input image according to a model file
*/
......@@ -137,6 +145,7 @@ public:
sampleSelectOutput = outPath + "_sampleSelect.shp";
sampleExtractOutput = outPath + "_sampleExtract.shp";
modelFile = outPath + "_model.txt";
imgStatOutput = outPath + "_imgstats.xml";
}
void clear()
......@@ -146,6 +155,7 @@ public:
RemoveFile(sampleSelectOutput);
RemoveFile(sampleExtractOutput);
RemoveFile(modelFile);
RemoveFile(imgStatOutput);
}
std::string tmpVectorFile;
......@@ -153,6 +163,7 @@ public:
std::string sampleSelectOutput;
std::string sampleExtractOutput;
std::string modelFile;
std::string imgStatOutput;
private:
bool RemoveFile(std::string &filePath)
......
......@@ -77,6 +77,7 @@ void ClassKMeansBase::InitKMSampling()
void ClassKMeansBase::InitKMClassification()
{
AddApplication("TrainVectorClassifier", "training", "Model training");
AddApplication("ComputeImagesStatistics", "imgstats", "Compute Images second order statistics");
AddApplication("ImageClassifier", "classif", "Performs a classification of the input image");
ShareKMClassificationParams();
......@@ -113,10 +114,12 @@ void ClassKMeansBase::ConnectKMSamplingParams()
void ClassKMeansBase::ConnectKMClassificationParams()
{
Connect("training.cfield", "extraction.field");
Connect("training.io.stats","imgstats.out");
Connect("classif.in", "imgenvelop.in");
Connect("classif.model", "training.io.out");
Connect("classif.ram", "polystats.ram");
Connect("classif.imstat", "imgstats.out");
}
void ClassKMeansBase::ConnectKMClassificationMask()
......@@ -239,6 +242,18 @@ void ClassKMeansBase::TrainKMModel(FloatVectorImageType *image,
otbAppLogINFO("output model : " << GetInternalApplication("training")->GetParameterString("io.out"));
}
void ClassKMeansBase::ComputeImageStatistics(std::string imageFileName,
std::string imagesStatsFileName)
{
std::vector<std::string> imageFileNameList = {imageFileName};
GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList, false);
GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName, false);
ExecuteInternal( "imgstats" );
otbAppLogINFO("image statistics file : " << GetInternalApplication("imgstats")->GetParameterString("out"));
}
void ClassKMeansBase::KMeansClassif()
{
ExecuteInternal( "classif" );
......
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