{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The basic steps of this algorithm work as follows:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Find the indices for of all given objects and separate them depending on    if they point to an object's border or not."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sort indices by their label value, ensuring that indices which point to    the same object are next to each other. This optimization allows finding    all parts of an object, simply by stepping to the neighboring indices."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sort boundary indices by "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "priority"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Use a stable-sort to preserve the    ordering from the previous sorting step. If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "priority"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is not given,    use "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.bincount",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "?",
                        "kind": "module",
                        "path": "numpy:bincount"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " as a fallback."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Construct a "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.spatial.cKDTree",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "?",
                        "kind": "module",
                        "path": "scipy.spatial._ckdtree:cKDTree"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " from the boundary indices."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Iterate across boundary indices in priority-sorted order, and query the    kd-tree for objects that are too close. Remove ones that are and don't    take them into account when evaluating other objects later on."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The performance of this algorithm depends on the number of samples in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "label_image"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " that belong to an object's border."
            }
          ]
        }
      ],
      "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": "out",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of the same shape as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "label_image"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", for which objects that violate the "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "min_distance"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " condition were removed."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Remove objects, in specified order, until remaining are a minimum distance apart."
            }
          ]
        }
      ],
      "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_image",
              "annotation": "ndarray of integers",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An n-dimensional array containing object labels, e.g. as returned by "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "skimage2.measure.label",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "_skimage2",
                        "version": "?",
                        "kind": "module",
                        "path": "_skimage2.measure._label:label"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". A value of zero is considered background, all other object IDs must be positive integers."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "min_distance",
              "annotation": "int or float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Remove objects whose distance to other objects is not greater than this positive value. Objects with a lower "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "priority"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are removed first."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "priority",
              "annotation": "ndarray, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defines the priority with which objects are removed. Expects a 1-dimensional array of length "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "np.amax(label_image) + 1 <numpy.amax>",
                      "domain": null,
                      "role": "func",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " that contains the priority for each object's label at the respective index. Objects with a lower value are removed first until all remaining objects fulfill the distance requirement. If not given, priority is given to objects with a higher number of samples and their label value second."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "p_norm",
              "annotation": "int or float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The Minkowski distance of order p, used to calculate the distance between objects. The default "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " corresponds to the Euclidean distance, "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to the \"Manhattan\" distance, and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.inf"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to the Chebyshev distance."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "spacing",
              "annotation": "sequence of float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The pixel spacing along each axis of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "label_image"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If not specified, a grid spacing of unity (1) is implied."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "out",
              "annotation": "ndarray, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of the same shape and dtype as "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "image",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", into which the output is placed. By default, a new array is created."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Remove labeled objects from an image until the remaining ones are spaced more than a given distance from one another. By default, smaller objects are removed first."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/_skimage2/morphology/misc.py",
  "item_line": 271,
  "item_type": "function",
  "aliases": [
    "skimage.morphology.remove_objects_by_distance"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import skimage as ski\nski.morphology.remove_objects_by_distance(np.array([2, 0, 1, 1]), 2)\nski.morphology.remove_objects_by_distance(\n    np.array([2, 0, 1, 1]), 2, priority=np.array([0, 1, 9])\n)\nlabel_image = np.array(\n    [[8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9],\n     [8, 8, 8, 0, 0, 0, 0, 0, 0, 9, 9],\n     [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0],\n     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n     [0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0],\n     [2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n     [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n     [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7]]\n)\nski.morphology.remove_objects_by_distance(\n    label_image, min_distance=3\n)\n",
        "execution_status": "success",
        "out": "array([[8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9],\n       [8, 8, 8, 0, 0, 0, 0, 0, 0, 9, 9],\n       [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0],\n       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n       [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n       [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7]])\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "skimage.morphology.remove_small_holes",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "skimage.morphology.misc:remove_small_holes"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Remove holes smaller than the specified size."
            }
          ]
        }
      ],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "skimage.morphology.remove_small_objects",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "skimage.morphology.misc:remove_small_objects"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Remove objects smaller than the specified size."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "label_image",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "min_distance",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "priority",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "p_norm",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "2"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "spacing",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "out",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "remove_objects_by_distance"
  },
  "references": null,
  "qa": "skimage.morphology.misc:remove_objects_by_distance",
  "arbitrary": [],
  "local_refs": [
    "label_image",
    "min_distance",
    "out",
    "p_norm",
    "priority",
    "spacing"
  ]
}