{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The label 0 is assumed to denote the background and is never remapped."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The forward map can be extremely big for some inputs, since its length is given by the maximum of the label field. However, in most situations, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "label_field.max()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is much smaller than "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "label_field.size"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and in these cases the forward map is guaranteed to be smaller than either the input or output images."
            }
          ]
        }
      ],
      "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": "relabeled",
              "annotation": "numpy array of int, same shape as `label_field`",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The input label field with labels mapped to {offset, ..., number_of_labels + offset - 1}. The data type will be the same as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "label_field"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", except when offset + number_of_labels causes overflow of the current data type."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "forward_map",
              "annotation": "ArrayMap",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The map from the original label space to the returned label space. Can be used to re-apply the same mapping. See examples for usage. The output data type will be the same as "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "relabeled",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": null,
                        "version": null,
                        "kind": "local",
                        "path": "relabeled"
                      },
                      "kind": "local"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "inverse_map",
              "annotation": "ArrayMap",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The map from the new label space to the original space. This can be used to reconstruct the original label field from the relabeled one. The output data type will be the same as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "label_field"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Relabel arbitrary labels to {"
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "offset"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", ... "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "offset"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " + number_of_labels}."
            }
          ]
        }
      ],
      "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": "label_field",
              "annotation": "numpy array of int, arbitrary shape",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array of labels, which must be non-negative integers."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "offset",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The return labels will start at "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "offset"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", which should be strictly positive."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function also returns the forward map (mapping the original labels to the reduced labels) and the inverse map (mapping the reduced labels back to the original ones)."
            }
          ]
        }
      ],
      "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/segmentation/_join.py",
  "item_line": 76,
  "item_type": "function",
  "aliases": [
    "skimage.segmentation.relabel_sequential"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from skimage.segmentation import relabel_sequential\nlabel_field = np.array([1, 1, 5, 5, 8, 99, 42])\nrelab, fw, inv = relabel_sequential(label_field)\nrelab\nprint(fw)\nnp.array(fw)\nnp.array(inv)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "(fw[label_field] == relab).all()\n(inv[relab] == label_field).all()\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "relab, fw, inv = relabel_sequential(label_field, offset=5)\nrelab\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "label_field",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "offset",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "relabel_sequential"
  },
  "references": null,
  "qa": "skimage.segmentation._join:relabel_sequential",
  "arbitrary": [],
  "local_refs": [
    "forward_map",
    "inverse_map",
    "label_field",
    "offset",
    "relabeled"
  ]
}