Commit 30778416 authored by Victor Poughon's avatar Victor Poughon
Browse files

DOC: fix multi example

No related merge requests found
Showing with 66 additions and 58 deletions
+66 -58
...@@ -29,8 +29,6 @@ from otbApplication import ParameterType_Bool, ParameterType_Int, ParameterType_ ...@@ -29,8 +29,6 @@ from otbApplication import ParameterType_Bool, ParameterType_Int, ParameterType_
from otb_warnings import application_documentation_warnings from otb_warnings import application_documentation_warnings
linesep = os.linesep 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): def EncloseString(s):
if not s.startswith("\"") : if not s.startswith("\"") :
...@@ -54,6 +52,7 @@ def ExpandPath(filename,path,exp): ...@@ -54,6 +52,7 @@ def ExpandPath(filename,path,exp):
return os.path.join(path,filename) return os.path.join(path,filename)
def GetPixelType(value): 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 # look for type
foundcode = -1 foundcode = -1
foundname = "" foundname = ""
...@@ -64,38 +63,16 @@ def GetPixelType(value): ...@@ -64,38 +63,16 @@ def GetPixelType(value):
break break
return foundcode,foundname 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=""): def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outputpath=""):
appname = "app" appname = "app"
output = "" 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+= "\timport otbApplication" + linesep + linesep
output+= "\t" + appname + " = otbApplication.Registry.CreateApplication(\"" + app.GetName() + "\")" + linesep + linesep output+= "\t" + appname + " = otbApplication.Registry.CreateApplication(\"" + app.GetName() + "\")" + linesep + linesep
for i in range(0, app.GetExampleNumberOfParameters(idx)): for i in range(0, app.GetExampleNumberOfParameters(idx)):
...@@ -172,9 +149,36 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp ...@@ -172,9 +149,36 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp
output += "\t" + appname + ".SetParameterStringList("+EncloseString(param)+ ", " + str(values) + ")" output += "\t" + appname + ".SetParameterStringList("+EncloseString(param)+ ", " + str(values) + ")"
output+=linesep output+=linesep
output += linesep output += linesep
output+= "\t" + appname + ".ExecuteAndWriteOutput()"+ linesep output+= "\t" + appname + ".ExecuteAndWriteOutput()" + linesep + linesep
return output 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): def rst_section(text, delimiter, ref=None):
"Make a rst section title" "Make a rst section title"
...@@ -235,22 +239,22 @@ def detect_abuse(app): ...@@ -235,22 +239,22 @@ def detect_abuse(app):
fake_groups = {} fake_groups = {}
keys = app.GetParametersKeys() keys = app.GetParametersKeys()
choice_keys = [k for k in keys if app.GetParameterType(k) == ParameterType_Choice]
# For each choice parameter # For each choice parameter
for key in keys: for key in choice_keys:
if app.GetParameterType(key) == ParameterType_Choice:
# Consider all its possible values # Consider all its possible values
for choice_key in app.GetChoiceKeys(key): for choice_key in app.GetChoiceKeys(key):
fullkey = key + "." + choice_key fullkey = key + "." + choice_key
# See if that value is also used as a group anywhere in the application # See if that value is also used as a group anywhere in the application
for k in keys: for k in keys:
if k.startswith(fullkey) and k != fullkey: if k.startswith(fullkey) and k != fullkey:
# In that case, mark the first element of that group # In that case, mark the first element of that group
if fullkey not in fake_groups.values(): if fullkey not in fake_groups.values():
fake_groups[k] = fullkey fake_groups[k] = fullkey
return fake_groups return fake_groups
......
...@@ -20,8 +20,8 @@ def parameter_warnings(app_warn, app, key): ...@@ -20,8 +20,8 @@ def parameter_warnings(app_warn, app, key):
#if description == "": #if description == "":
#warn("missing description") #warn("missing description")
#if len(description) > 0 and description[-1] != ".": if len(description) > 0 and description[-1] != ".":
#warn("description does not end with a period") warn("description does not end with a period")
if len(description) > 0 and " :" in description: if len(description) > 0 and " :" in description:
warn("description has a space before a colon") warn("description has a space before a colon")
......
...@@ -32,8 +32,6 @@ From the command-line: ...@@ -32,8 +32,6 @@ From the command-line:
From Python: From Python:
.. code-block:: python
{examples_python} {examples_python}
{limitations} {limitations}
......
...@@ -144,18 +144,24 @@ private: ...@@ -144,18 +144,24 @@ private:
// Documentation // Documentation
SetDocName("Segmentation"); SetDocName("Segmentation");
SetDocLongDescription("This application allows one to perform various segmentation algorithms on a multispectral image." SetDocLongDescription(
"Available segmentation algorithms are two different versions of Mean-Shift segmentation algorithm (one being multi-threaded)," "This application allows one to perform various segmentation algorithms on a multispectral image."
" simple pixel based connected components according to a user-defined criterion, and watershed from the gradient of the intensity" " Available segmentation algorithms are two different versions of Mean-Shift segmentation algorithm (one being multi-threaded),"
" (norm of spectral bands vector). The application has two different modes that affects the nature of its output.\n\nIn raster mode," " simple pixel based connected components according to a user-defined criterion, and watershed from the gradient of the intensity"
" the output of the application is a classical image of unique labels identifying the segmented regions. The labeled output can be passed to the" " (norm of spectral bands vector). The application has two different modes that affects the nature of its output.\n\n"
" 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" "In raster mode, the output of the application is a classical image of unique labels identifying the segmented regions. The labeled output can be "
" 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" "passed to the"
" with the chosen algorithm, vectorized, and written into the output file or database. This piece-wise behavior ensure that memory will never get overloaded," " ColorMapping application to render regions with contrasted colours. Please note that this mode loads the whole input image into memory, and as such"
" 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" " can not handle large images.\n\n"
" (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. "); "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." 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 " " \nMeanShift filter results depends on the number of threads used. \nWatershed and multiscale geodesic morphology segmentation will be performed on the amplitude "
......
Supports Markdown
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