Commit 720fcdee authored by Julien Michel's avatar Julien Michel
Browse files

LSMS integration (moving from nbtiles parameters to tilsize parameters)

parent a704e6fc
......@@ -221,17 +221,15 @@ private:
SetMinimumParameterIntValue("minsize", 0);
MandatoryOff("minsize");
AddParameter(ParameterType_Int, "nbtilesx", "Number of Tiles (X-axis)");
SetParameterDescription("nbtilesx", "Number of Tiles along the X-axis.");
SetDefaultParameterInt("nbtilesx", 10);
SetMinimumParameterIntValue("nbtilesx", 1);
MandatoryOff("nbtilesx");
AddParameter(ParameterType_Int, "nbtilesy", "Number of Tiles (Y-axis)");
SetParameterDescription("nbtilesy", "Number of Tiles along the Y-axis.");
SetDefaultParameterInt("nbtilesy", 10);
SetMinimumParameterIntValue("nbtilesy", 1);
MandatoryOff("nbtilesy");
AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
SetDefaultParameterInt("tilesizex", 500);
SetMinimumParameterIntValue("tilesizex", 1);
AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
SetDefaultParameterInt("tilesizey", 500);
SetMinimumParameterIntValue("tilesizey", 1);
AddParameter(ParameterType_Directory,"tmpdir","Directory where to write temporary files");
SetParameterDescription("tmpdir","This applications need to write some temporary files for each tile. This parameters allows to choose the path where to write those files. If disabled, the current path will be used.");
......@@ -250,8 +248,8 @@ private:
SetDocExampleParameterValue("ranger","15");
SetDocExampleParameterValue("spatialr","5");
SetDocExampleParameterValue("minsize","0");
SetDocExampleParameterValue("nbtilesx","4");
SetDocExampleParameterValue("nbtilesy","4");
SetDocExampleParameterValue("tilesizex","256");
SetDocExampleParameterValue("tilesizey","256");
}
......@@ -265,13 +263,13 @@ private:
clock_t tic = clock();
const float ranger = GetParameterFloat("ranger");
const float spatialr = GetParameterFloat("spatialr");
const float ranger = GetParameterFloat("ranger");
const float spatialr = GetParameterFloat("spatialr");
unsigned int minRegionSize = GetParameterInt("minsize");
unsigned int minRegionSize = GetParameterInt("minsize");
unsigned int nbTilesX = GetParameterInt("nbtilesx");
unsigned int nbTilesY = GetParameterInt("nbtilesy");
unsigned long sizeTilesX = GetParameterInt("tilesizex");
unsigned long sizeTilesY = GetParameterInt("tilesizey");
// Ensure that temporary directory exists if activated:
......@@ -305,7 +303,11 @@ private:
unsigned long sizeImageY = imageIn->GetLargestPossibleRegion().GetSize()[1];
unsigned int nbComp = imageIn->GetNumberOfComponentsPerPixel();
unsigned long sizeTilesX = (sizeImageX+nbTilesX-1)/nbTilesX, sizeTilesY = (sizeImageY+nbTilesY-1)/nbTilesY;
unsigned int nbTilesX = sizeImageX/sizeTilesX + (sizeImageX%sizeTilesX > 0 ? 1 : 0);
unsigned int nbTilesY = sizeImageY/sizeTilesY + (sizeImageY%sizeTilesY > 0 ? 1 : 0);
otbAppLogINFO(<<"Number of tiles: "<<nbTilesX<<" x "<<nbTilesY);
unsigned long regionCount = 0;
//Segmentation by the connected component per tile and label
......
......@@ -104,27 +104,24 @@ private:
SetDefaultParameterInt("minsize", 50);
SetMinimumParameterIntValue("minsize", 0);
MandatoryOff("minsize");
AddParameter(ParameterType_Int, "nbtilesx", "Number of Tiles (X-axis)");
SetParameterDescription("nbtilesx", "Number of Tiles along the X-axis.");
SetDefaultParameterInt("nbtilesx", 10);
SetMinimumParameterIntValue("nbtilesx", 1);
MandatoryOff("nbtilesx");
AddParameter(ParameterType_Int, "nbtilesy", "Number of Tiles (Y-axis)");
SetParameterDescription("nbtilesy", "Number of Tiles along the Y-axis.");
SetDefaultParameterInt("nbtilesy", 10);
SetMinimumParameterIntValue("nbtilesy", 1);
MandatoryOff("nbtilesy");
AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
SetDefaultParameterInt("tilesizex", 500);
SetMinimumParameterIntValue("tilesizex", 1);
AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
SetDefaultParameterInt("tilesizey", 500);
SetMinimumParameterIntValue("tilesizey", 1);
// Doc example parameter settings
SetDocExampleParameterValue("in","smooth.tif");
SetDocExampleParameterValue("inseg","segmentation.tif");
SetDocExampleParameterValue("out","merged.tif");
SetDocExampleParameterValue("minsize","20");
SetDocExampleParameterValue("nbtilesx","4");
SetDocExampleParameterValue("nbtilesy","4");
SetDocExampleParameterValue("tilesizex","256");
SetDocExampleParameterValue("tilesizey","256");
}
......@@ -136,11 +133,10 @@ private:
{
clock_t tic = clock();
unsigned int minSize = GetParameterInt("minsize");
unsigned int minSize = GetParameterInt("minsize");
unsigned int nbTilesX = GetParameterInt("nbtilesx");
unsigned int nbTilesY = GetParameterInt("nbtilesy");
unsigned long sizeTilesX = GetParameterInt("tilesizex");
unsigned long sizeTilesY = GetParameterInt("tilesizey");
//Acquisition of the input image dimensions
ImageType::Pointer imageIn = GetParameterImage("in");
......@@ -166,13 +162,15 @@ private:
defaultValue.Fill(0);
std::vector<ImageType::PixelType>sum(regionCount+1,defaultValue);
unsigned int nbTilesX = sizeImageX/sizeTilesX + (sizeImageX%sizeTilesX > 0 ? 1 : 0);
unsigned int nbTilesY = sizeImageY/sizeTilesY + (sizeImageY%sizeTilesY > 0 ? 1 : 0);
otbAppLogINFO(<<"Number of tiles: "<<nbTilesX<<" x "<<nbTilesY);
//Sums calculation per label
otbAppLogINFO(<<"Sums calculation ...");
unsigned long sizeTilesX = (sizeImageX+nbTilesX-1)/nbTilesX;
unsigned long sizeTilesY = (sizeImageY+nbTilesY-1)/nbTilesY;
for(unsigned int row = 0; row < nbTilesY ; row++)
for(unsigned int column = 0; column < nbTilesX ; column++)
{
......
......@@ -91,24 +91,22 @@ private:
AddParameter(ParameterType_OutputFilename, "out", "Output GIS vector file");
SetParameterDescription( "out", "The output GIS vector fie, representing the vectorized version of the segmented image where the features of the polygones are the radiometric means and variances." );
AddParameter(ParameterType_Int, "nbtilesx", "Number of Tiles (X-axis)");
SetParameterDescription("nbtilesx", "Number of Tiles along the X-axis.");
SetDefaultParameterInt("nbtilesx", 10);
SetMinimumParameterIntValue("nbtilesx", 1);
MandatoryOff("nbtilesx");
AddParameter(ParameterType_Int, "nbtilesy", "Number of Tiles (Y-axis)");
SetParameterDescription("nbtilesy", "Number of Tiles along the Y-axis.");
SetDefaultParameterInt("nbtilesy", 10);
SetMinimumParameterIntValue("nbtilesy", 1);
MandatoryOff("nbtilesy");
AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
SetDefaultParameterInt("tilesizex", 500);
SetMinimumParameterIntValue("tilesizex", 1);
AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
SetDefaultParameterInt("tilesizey", 500);
SetMinimumParameterIntValue("tilesizey", 1);
// Doc example parameter settings
SetDocExampleParameterValue("in","avions.tif");
SetDocExampleParameterValue("inseg","merged.tif");
SetDocExampleParameterValue("out","vecto.shp");
SetDocExampleParameterValue("nbtilesx","4");
SetDocExampleParameterValue("nbtilesy","4");
SetDocExampleParameterValue("tilesizex","256");
SetDocExampleParameterValue("tilesizey","256");
}
void DoUpdateParameters()
......@@ -119,10 +117,11 @@ private:
{
clock_t tic = clock();
const char * shapefile = GetParameterString("out").c_str();
const char * shapefile = GetParameterString("out").c_str();
unsigned int nbTilesX = GetParameterInt("nbtilesx");
unsigned int nbTilesY = GetParameterInt("nbtilesy");
unsigned long sizeTilesX = GetParameterInt("tilesizex");
unsigned long sizeTilesY = GetParameterInt("tilesizey");
LabelImageType::Pointer labelIn = GetParameterUInt32Image("inseg");
labelIn->UpdateOutputInformation();
......@@ -130,6 +129,11 @@ private:
unsigned long sizeImageX = labelIn->GetLargestPossibleRegion().GetSize()[0];
unsigned long sizeImageY = labelIn->GetLargestPossibleRegion().GetSize()[1];
unsigned int nbTilesX = sizeImageX/sizeTilesX + (sizeImageX%sizeTilesX > 0 ? 1 : 0);
unsigned int nbTilesY = sizeImageY/sizeTilesY + (sizeImageY%sizeTilesY > 0 ? 1 : 0);
otbAppLogINFO(<<"Number of tiles: "<<nbTilesX<<" x "<<nbTilesY);
StatisticsImageFilterType::Pointer stats = StatisticsImageFilterType::New();
stats->SetInput(labelIn);
stats->Update();
......@@ -187,10 +191,6 @@ private:
layer.CreateField(field, true);
}
unsigned long sizeTilesX = (sizeImageX+nbTilesX-1)/nbTilesX;
unsigned long sizeTilesY = (sizeImageY+nbTilesY-1)/nbTilesY;
//Vectorization per tile
otbAppLogINFO(<<"Vectorization ...");
for(unsigned int row = 0; row < nbTilesY ; row++)
......@@ -273,7 +273,7 @@ private:
otb::ogr::Feature firstFeature = layerTmp.ogr().GetNextFeature();
//Geometry fusion
otbAppLogINFO("Fusion of polygons accross tiles ...");
otbAppLogINFO("Merging polygons accross tiles ...");
while(firstFeature.addr())
{
LabelImagePixelType curLabel = firstFeature.ogr().GetFieldAsInteger("label");
......
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