LSMS is a segmentation workflow which allows to perform tile-wise segmentation of very large image with theoretical guarantees of getting identical results to those without tiling. It has been developed by David Youssefi and Julien Michel during David internship at CNES and is to be published soon.
The workflow consists in chaining 3 or 4 dedicated applications and produces a GIS vector file with artifact-free polygons corresponding to the segmented image, as well as mean and variance of the radiometry of each band for each polygon.
The first step of the workflow is to perform Mean-Shift smoothing with the MeanShiftSmoothing application:
Note that the modesearch option should be disabled, and that the foutpos parameter is optional: it can be activated if you want to perform the segmentation based on both spatial and range modes.
This application will smooth large images by streaming them, and deactivating the modesearch will guarantee that the results will not depend on the streaming scheme. Please also note that the maxiter is used to set the margin to ensure these identical results, and as such increasing the maxiter may have an additional impact on processing time.
The next step is to produce an initial segmentation based on the smoothed images produced by the MeanShiftSmoothing application. To do so, the LSMSSegmentation will process them by tiles whose dimensions are defined by the tilesizex and tilesizey parameters, and by writing intermediate images to disk, thus keeping the memory consumption very low throughout the process. The segmentation will group together adjacent pixels whose range distance is below the ranger parameter and (optionally) spatial distance is below the spatialr parameter.
Note that the final segmentation image may contains a very large number of segments, and the uint32 image type should therefore be used to ensure that there will be enough labels to index those segments. The minsize parameter will filter segments whose size in pixels is below its value, and their labels will be set to 0 (nodata).
Please note that the output segmented image may look patchy, as if there were tiling artifacts: this is because segments are numbered sequentially with respect to the order in which tiles are processed. You will see after the result of the vectorization step that there are no artifacts in the results.
The LSMSSegmentation application will write as many intermediate files as tiles needed during processing. As such, it may require twice as free disk space as the final size of the final image. The cleanup option (active by default) will clear the intermediate files during the processing as soon as they are not needed anymore. By default, files will be written to the current directory. The tmpdir option allows to specify a different directory for these intermediate files.
The LSMSSegmentation application allows to filter out small segments. In the output segmented image, those segments will be removed and replaced by the background label (0). Another solution to deal with the small regions is to merge them with the closest big enough adjacent region in terms of radiometry. This is handled by the LSMSSmallRegionsMerging application, which will output a segmented image where small regions have been merged. Again, the uint32 image type is advised for this output image.
The minsize parameter allows to specify the threshold on the size of the regions to be merged. Like the LSMSSegmentation application, this application will process the input images tile-wise to keep resources usage low, with the guarantee of identical results. You can set the tile size using the tilesizex and tilesizey parameters. However unlike the LSMSSegmentation application, it does not require to write any temporary file to disk.
The last step of the LSMS workflow consists in the vectorization of the segmented image into a GIS vector file. This vector file will contain one polygon per segment, and each of these polygons will hold additional attributes denoting the label of the original segment, the size of the segment in pixels, and the mean and variance of each band over the segment. The projection of the output GIS vector file will be the same as the projection from the input image (if input image has no projection, so does the output GIS file).
This application will process the input images tile-wise to keep resources usage low, with the guarantee of identical results. You can set the tile size using the tilesizex and tilesizey parameters. However unlike the LSMSSegmentation application, it does not require to write any temporary file to disk.