{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The algorithm "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is an improved version of Chernyaev's Marching Cubes 33 algorithm. It is an efficient algorithm that relies on heavy use of lookup tables to handle the many different cases, keeping the algorithm relatively easy. This implementation is written in Cython, ported from Lewiner's C++ implementation."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To quantify the area of an isosurface generated by this algorithm, pass verts and faces to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "skimage.measure.mesh_surface_area",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "skimage",
                "version": "*",
                "kind": "api",
                "path": "skimage.measure._marching_cubes_lewiner:mesh_surface_area"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Regarding visualization of algorithm output, to contour a volume named "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "myvolume",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " about the level 0.0, using the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mayavi"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " package    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>>\n>> from mayavi import mlab\n>> verts, faces, _, _ = marching_cubes(myvolume, 0.0)\n>> mlab.triangular_mesh([vert[0] for vert in verts],\n                        [vert[1] for vert in verts],\n                        [vert[2] for vert in verts],\n                        faces)\n>> mlab.show()",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similarly using the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "visvis"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " package    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>>\n>> import visvis as vv\n>> verts, faces, normals, values = marching_cubes(myvolume, 0.0)\n>> vv.mesh(np.fliplr(verts), faces, normals, values)\n>> vv.use().Run()",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To reduce the number of triangles in the mesh for better performance, see this "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "example"
                }
              ],
              "url": "https://docs.enthought.com/mayavi/mayavi/auto/example_julia_set_decimation.html#example-julia-set-decimation",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " using the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mayavi"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " package."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "verts",
              "annotation": "(V, 3) array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Spatial coordinates for V unique mesh vertices. Coordinate order matches input "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "volume"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (M, N, P). If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "allow_degenerate"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is set to True, then the presence of degenerate triangles in the mesh can make this array have duplicate vertices."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "faces",
              "annotation": "(F, 3) array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Define triangular faces via referencing vertex indices from "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "verts"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". This algorithm specifically outputs triangles, so each face has exactly three indices."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "normals",
              "annotation": "(V, 3) array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The normal direction at each vertex, as calculated from the data."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "values",
              "annotation": "(V,) array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Gives a measure for the maximum value of the data in the local region near each vertex. This can be used by visualization tools to apply a colormap to the mesh."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Marching cubes algorithm to find surfaces in 3d volumetric data."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "volume",
              "annotation": "(M, N, P) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Input data volume to find isosurfaces. Will internally be converted to float32 if necessary."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "level",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Contour value to search for isosurfaces in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "volume"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If not given or None, the average of the min and max of vol is used."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "spacing",
              "annotation": "length-3 tuple of floats, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Voxel spacing in spatial dimensions corresponding to numpy array indexing dimensions (M, N, P) as in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "volume"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "gradient_direction",
              "annotation": "{'descent', 'ascent'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Controls if the mesh was generated from an isosurface with gradient descent toward objects of interest (the default), or the opposite, considering the "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "left-hand"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " rule. The two options are: * descent : Object was greater than exterior * ascent : Exterior was greater than object"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "step_size",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Step size in voxels. Default 1. Larger steps yield faster but coarser results. The result will always be topologically correct though."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "allow_degenerate",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Whether to allow degenerate (i.e. zero-area) triangles in the end-result. Default True. If False, degenerate triangles are removed, at the cost of making the algorithm slower."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "method",
              "annotation": "{'lewiner', 'lorensen'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Whether the method of Lewiner et al. or Lorensen et al. will be used."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mask",
              "annotation": "(M, N, P) array, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Boolean array. The marching cube algorithm will be computed only on True elements. This will save computational time when interfaces are located within certain region of the volume M, N, P-e.g. the top half of the cube-and also allow to compute finite surfaces-i.e. open surfaces that do not end at the border of the cube."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In contrast with Lorensen et al. approach "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", Lewiner et al. algorithm is faster, resolves ambiguities, and guarantees topologically correct results. Therefore, this algorithm is generally a better choice."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Returns",
    "Yields",
    "Receives",
    "Raises",
    "Warns",
    "Other Parameters",
    "Attributes",
    "Methods",
    "Notes",
    "Warnings"
  ],
  "item_file": "/dev/scikit-image/src/skimage/measure/_marching_cubes_lewiner.py",
  "item_line": 9,
  "item_type": "function",
  "aliases": [
    "skimage.measure.marching_cubes"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "skimage.measure.find_contours",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "skimage.measure._find_contours:find_contours"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "skimage.measure.mesh_surface_area",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "skimage.measure._marching_cubes_lewiner:mesh_surface_area"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "volume",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "level",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "spacing",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "(1.0, 1.0, 1.0)"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "gradient_direction",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "descent"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "step_size",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "1"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "allow_degenerate",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "True"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "method",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "lewiner"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "mask",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "marching_cubes"
  },
  "references": [
    ".. [1] Thomas Lewiner, Helio Lopes, Antonio Wilson Vieira and Geovan",
    "       Tavares. Efficient implementation of Marching Cubes' cases with",
    "       topological guarantees. Journal of Graphics Tools 8(2)",
    "       pp. 1-15 (december 2003).",
    "       :DOI:`10.1080/10867651.2003.10487582`",
    ".. [2] Lorensen, William and Harvey E. Cline. Marching Cubes: A High",
    "       Resolution 3D Surface Construction Algorithm. Computer Graphics",
    "       (SIGGRAPH 87 Proceedings) 21(4) July 1987, p. 163-170).",
    "       :DOI:`10.1145/37401.37422`"
  ],
  "qa": "skimage.measure._marching_cubes_lewiner:marching_cubes",
  "arbitrary": [],
  "local_refs": [
    "allow_degenerate",
    "faces",
    "gradient_direction",
    "level",
    "mask",
    "method",
    "normals",
    "spacing",
    "step_size",
    "values",
    "verts",
    "volume"
  ]
}