{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The steps of the algorithm are as follows:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Smooth the image using a Gaussian with "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "sigma"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " width."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Apply the horizontal and vertical Sobel operators to get the gradients   within the image. The edge strength is the norm of the gradient."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Thin potential edges to 1-pixel wide curves. First, find the normal   to the edge at each point. This is done by looking at the   signs and the relative magnitude of the X-Sobel and Y-Sobel   to sort the points into 4 categories: horizontal, vertical,   diagonal and antidiagonal. Then look in the normal and reverse   directions to see if the values in either of those directions are   greater than the point in question. Use interpolation to get a mix of   points instead of picking the one that's the closest to the normal."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Perform a hysteresis thresholding: first label all points above the   high threshold as edges. Then recursively label any point above the   low threshold that is 8-connected to a labeled point as an edge."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "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": "output",
              "annotation": "ndarray of shape (M, N)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The binary edge map."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Edge filter an image using the Canny algorithm."
            }
          ]
        }
      ],
      "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": "image",
              "annotation": "ndarray of shape (M, N)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Grayscale input image to detect edges on; can be of any dtype."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "sigma",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Standard deviation of the Gaussian filter."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "low_threshold",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype's max."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "high_threshold",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype's max."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mask",
              "annotation": "ndarray of dtype bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Mask to limit the application of Canny to a certain area."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "use_quantiles",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " then the thresholds must be in the range [0, 1]."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mode",
              "annotation": "{'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "mode"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " parameter determines how the array borders are handled during Gaussian filtering, where "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "cval"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the value when "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "mode"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is equal to 'constant'."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "cval",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Value to fill past edges of input if "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "mode"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is 'constant'."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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/feature/_canny.py",
  "item_line": 12,
  "item_type": "function",
  "aliases": [
    "skimage.feature.canny"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nimport skimage as ski\nrng = np.random.default_rng()\nim = np.zeros((256, 256))\nim[64:-64, 64:-64] = 1\nim += 0.2 * rng.random(im.shape)\nedges1 = ski.feature.canny(im)\nedges2 = ski.feature.canny(im, sigma=3)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "skimage.filters.sobel",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "skimage.filters.edges:sobel"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "image",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "sigma",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1.0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "low_threshold",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "high_threshold",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "mask",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "use_quantiles",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "mode",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "constant"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "cval",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "0.0"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "canny"
  },
  "references": [
    ".. [1] Canny, J., A Computational Approach To Edge Detection, IEEE Trans.",
    "       Pattern Analysis and Machine Intelligence, 8:679-714, 1986",
    "       :DOI:`10.1109/TPAMI.1986.4767851`",
    ".. [2] William Green's Canny tutorial",
    "       https://en.wikipedia.org/wiki/Canny_edge_detector"
  ],
  "qa": "skimage.feature._canny:canny",
  "arbitrary": [],
  "local_refs": [
    "cval",
    "high_threshold",
    "image",
    "low_threshold",
    "mask",
    "mode",
    "output",
    "sigma",
    "use_quantiles"
  ]
}