Commit 30778416 authored by Victor Poughon's avatar Victor Poughon

DOC: fix multi example

parent 6c96da86
......@@ -29,8 +29,6 @@ from otbApplication import ParameterType_Bool, ParameterType_Int, ParameterType_
from otb_warnings import application_documentation_warnings
linesep = os.linesep
pixeltypes = {' uchar' : 1, ' int8' : 0, ' uint8' : 1, ' int16' : 2, ' uint16': 3, ' int32' : 4, ' uint32' : 5, ' float' : 6, ' double': 7}
def EncloseString(s):
if not s.startswith("\"") :
......@@ -54,6 +52,7 @@ def ExpandPath(filename,path,exp):
return os.path.join(path,filename)
def GetPixelType(value):
pixeltypes = {' uchar' : 1, ' int8' : 0, ' uint8' : 1, ' int16' : 2, ' uint16': 3, ' int32' : 4, ' uint32' : 5, ' float' : 6, ' double': 7}
# look for type
foundcode = -1
foundname = ""
......@@ -64,38 +63,16 @@ def GetPixelType(value):
break
return foundcode,foundname
def render_choice(app, key):
"Render a choice parameter to rst"
# First render all the choice values
choice_keys = app.GetChoiceKeys(key)
choice_names = app.GetChoiceNames(key)
choice_entries = ""
for (choice_key, choice_name) in zip(choice_keys, choice_names):
# For the description, replace newlines by |br| because we are in a bullet list item
choice_description = app.GetParameterDescription(key + "." + choice_key).replace("\n", " |br| ")
choice_entries += template_parameter_choice_entry.format(
name=choice_name,
#key=choice_key, # if we want to show the key in choice parameter values
description=choice_description
)
# Then render the full choice parameter
return template_parameter_choice.format(
name=app.GetParameterName(key),
key=key,
value="[" + "|".join(choice_keys) + "]",
flags=rst_parameter_flags(app, key),
description=app.GetParameterDescription(key),
choices=choice_entries,
)
def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outputpath=""):
appname = "app"
output = ""
# Render example comment
if len(app.GetExampleComment(idx)) > 0:
output += app.GetExampleComment(idx) + ":\n\n"
output += ".. code-block:: python\n\n"
output+= "\timport otbApplication" + linesep + linesep
output+= "\t" + appname + " = otbApplication.Registry.CreateApplication(\"" + app.GetName() + "\")" + linesep + linesep
for i in range(0, app.GetExampleNumberOfParameters(idx)):
......@@ -172,9 +149,36 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp
output += "\t" + appname + ".SetParameterStringList("+EncloseString(param)+ ", " + str(values) + ")"
output+=linesep
output += linesep
output+= "\t" + appname + ".ExecuteAndWriteOutput()"+ linesep
output+= "\t" + appname + ".ExecuteAndWriteOutput()" + linesep + linesep
return output
def render_choice(app, key):
"Render a choice parameter to rst"
# First render all the choice values
choice_keys = app.GetChoiceKeys(key)
choice_names = app.GetChoiceNames(key)
choice_entries = ""
for (choice_key, choice_name) in zip(choice_keys, choice_names):
# For the description, replace newlines by |br| because we are in a bullet list item
choice_description = app.GetParameterDescription(key + "." + choice_key).replace("\n", " |br| ")
choice_entries += template_parameter_choice_entry.format(
name=choice_name,
#key=choice_key, # if we want to show the key in choice parameter values
description=choice_description
)
# Then render the full choice parameter
return template_parameter_choice.format(
name=app.GetParameterName(key),
key=key,
value="[" + "|".join(choice_keys) + "]",
flags=rst_parameter_flags(app, key),
description=app.GetParameterDescription(key),
choices=choice_entries,
)
def rst_section(text, delimiter, ref=None):
"Make a rst section title"
......@@ -235,22 +239,22 @@ def detect_abuse(app):
fake_groups = {}
keys = app.GetParametersKeys()
choice_keys = [k for k in keys if app.GetParameterType(k) == ParameterType_Choice]
# For each choice parameter
for key in keys:
if app.GetParameterType(key) == ParameterType_Choice:
for key in choice_keys:
# Consider all its possible values
for choice_key in app.GetChoiceKeys(key):
fullkey = key + "." + choice_key
# Consider all its possible values
for choice_key in app.GetChoiceKeys(key):
fullkey = key + "." + choice_key
# See if that value is also used as a group anywhere in the application
for k in keys:
if k.startswith(fullkey) and k != fullkey:
# See if that value is also used as a group anywhere in the application
for k in keys:
if k.startswith(fullkey) and k != fullkey:
# In that case, mark the first element of that group
if fullkey not in fake_groups.values():
fake_groups[k] = fullkey
# In that case, mark the first element of that group
if fullkey not in fake_groups.values():
fake_groups[k] = fullkey
return fake_groups
......
......@@ -20,8 +20,8 @@ def parameter_warnings(app_warn, app, key):
#if description == "":
#warn("missing description")
#if len(description) > 0 and description[-1] != ".":
#warn("description does not end with a period")
if len(description) > 0 and description[-1] != ".":
warn("description does not end with a period")
if len(description) > 0 and " :" in description:
warn("description has a space before a colon")
......
......@@ -32,8 +32,6 @@ From the command-line:
From Python:
.. code-block:: python
{examples_python}
{limitations}
......
......@@ -144,18 +144,24 @@ private:
// Documentation
SetDocName("Segmentation");
SetDocLongDescription("This application allows one to perform various segmentation algorithms on a multispectral image."
"Available segmentation algorithms are two different versions of Mean-Shift segmentation algorithm (one being multi-threaded),"
" simple pixel based connected components according to a user-defined criterion, and watershed from the gradient of the intensity"
" (norm of spectral bands vector). The application has two different modes that affects the nature of its output.\n\nIn raster mode,"
" the output of the application is a classical image of unique labels identifying the segmented regions. The labeled output can be passed to the"
" ColorMapping application to render regions with contrasted colours. Please note that this mode loads the whole input image into memory, and as such"
" can not handle large images. \n\n To segment large data, one can use the vector mode. In this case, the output of the application is a"
" vector file or database. The input image is split into tiles (whose size can be set using the tilesize parameter), and each tile is loaded, segmented"
" with the chosen algorithm, vectorized, and written into the output file or database. This piece-wise behavior ensure that memory will never get overloaded,"
" and that images of any size can be processed. There are few more options in the vector mode. The simplify option allows simplifying the geometry"
" (i.e. remove nodes in polygons) according to a user-defined tolerance. The stitch option tries to stitch together the polygons corresponding"
" to segmented region that may have been split by the tiling scheme. ");
SetDocLongDescription(
"This application allows one to perform various segmentation algorithms on a multispectral image."
" Available segmentation algorithms are two different versions of Mean-Shift segmentation algorithm (one being multi-threaded),"
" simple pixel based connected components according to a user-defined criterion, and watershed from the gradient of the intensity"
" (norm of spectral bands vector). The application has two different modes that affects the nature of its output.\n\n"
"In raster mode, the output of the application is a classical image of unique labels identifying the segmented regions. The labeled output can be "
"passed to the"
" ColorMapping application to render regions with contrasted colours. Please note that this mode loads the whole input image into memory, and as such"
" can not handle large images.\n\n"
"To segment large data, one can use the vector mode. In this case, the output of the application is a"
" vector file or database. The input image is split into tiles (whose size can be set using the tilesize parameter), and each tile is loaded, segmented"
" with the chosen algorithm, vectorized, and written into the output file or database. This piece-wise behavior ensure that memory will never get"
" overloaded, and that images of any size can be processed. There are few more options in the vector mode. The simplify option allows simplifying the "
"geometry"
" (i.e. remove nodes in polygons) according to a user-defined tolerance. The stitch option tries to stitch together the polygons corresponding"
" to segmented region that may have been split by the tiling scheme. ");
SetDocLimitations("In raster mode, the application can not handle large input images. Stitching step of vector mode might become slow with very large input images."
" \nMeanShift filter results depends on the number of threads used. \nWatershed and multiscale geodesic morphology segmentation will be performed on the amplitude "
......
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