{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function applies the Wiener filter to a noisy (degraded) image by an impulse response (or PSF). If the data model is"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "y = Hx + n"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is noise, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "H"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the PSF, and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the unknown original image, the Wiener filter is"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\hat x = F^\\dagger \\left( |\\Lambda_H|^2 + \\lambda |\\Lambda_D|^2 \\right)^{-1}\n\\Lambda_H^\\dagger F y"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F^\\dagger"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are the Fourier and inverse Fourier transforms respectively, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\Lambda_H"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the transfer function (or the Fourier transform of the PSF, see "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\Lambda_D"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the regularization operator, which is a filter penalizing the restored image frequencies (Laplacian by default, that is, penalization of high frequencies). The parameter "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\lambda"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " tunes the balance between data (which tends to increase high frequencies, even those coming from noise) and regularization/prior (which tends to avoid noise artifacts)."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "These methods are then specific to a prior model. Consequently, the application or the true image nature must correspond to the prior model. By default, the prior model (Laplacian) introduces image smoothness or pixel correlation. It can also be interpreted as high-frequency penalization to compensate for the instability of the solution with respect to the data (sometimes called noise amplification or \"explosive\" solution)."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Finally, the use of Fourier space implies a circulant property of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "H"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", see "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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": "im_deconv",
              "annotation": "(N1, N2, ..., ND) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The deconvolved image."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Restore image using Wiener–Hunt deconvolution."
            }
          ]
        }
      ],
      "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": "(N1, N2, ..., ND) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Degraded image."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "psf",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Point spread function (PSF). Assumed to be the impulse response (input image space) if the data type is real, or the transfer function (Fourier or frequency space) if the data type is complex. There is no constraint on the shape of the impulse response. The transfer function though must be of shape "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "(N1, N2, ..., ND)",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "is_real is True",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "(N1, N2, ..., ND // 2 + 1)",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " otherwise (see "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.fft.rfftn",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy.fft:rfftn"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ")."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "balance",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Regularization parameter. Denoted by "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "\\lambda"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ": in the Notes section below, its value lets you balance data adequacy (improving frequency restoration) with respect to prior adequacy (reducing frequency restoration and avoiding noise artifacts). A larger value for this parameter favors the regularization/prior."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "reg",
              "annotation": "ndarray, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Regularization operator. Laplacian by default. It can be an impulse response or a transfer function, as for the PSF. Shape constraints are the same as for "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "psf"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "is_real",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "True by default. Specify if "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "psf"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "reg"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are provided over just half the frequency space (thanks to the redundancy of the Fourier transform for real signals). Applies only if "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "psf"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and/or "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "reg"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are provided as transfer functions. See "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "uft"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " module and "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "np.fft.rfftn",
                      "domain": null,
                      "role": "func",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "clip",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "True by default. If True, pixel values of the deconvolved image (which is the return value) above 1 (resp. below -1) are clipped to 1 (resp. to -1). Be careful to set "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "clip=False",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if you do not want this clipping and/or if your data range is not [0, 1] or [-1,1]."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Wiener–Hunt deconvolution is a restoration method which follows a Bayesian approach "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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/restoration/deconvolution.py",
  "item_line": 10,
  "item_type": "function",
  "aliases": [
    "skimage.restoration.wiener"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import skimage as ski\nimport scipy as sp\nimg = ski.color.rgb2gray(ski.data.astronaut())\npsf = np.ones((5, 5)) / 25\nimg = sp.signal.convolve2d(img, psf, 'same')\nrng = np.random.default_rng()\nimg += 0.1 * img.std() * rng.standard_normal(img.shape)\ndeconvolved_img = ski.restoration.wiener(img, psf, 0.1)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "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": "psf",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "balance",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "reg",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "is_real",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "clip",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "wiener"
  },
  "references": [
    ".. [1] François Orieux, Jean-François Giovannelli, and Thomas",
    "       Rodet, \"Bayesian estimation of regularization and point",
    "       spread function parameters for Wiener–Hunt deconvolution\",",
    "       J. Opt. Soc. Am. A 27, 1593–1607 (2010)",
    "       https://www.osapublishing.org/josaa/abstract.cfm?URI=josaa-27-7-1593",
    "       https://hal.archives-ouvertes.fr/hal-00674508",
    "",
    ".. [2] B. R. Hunt \"A matrix theory proof of the discrete",
    "       convolution theorem\", IEEE Trans. on Audio and",
    "       Electroacoustics, vol. au-19, no. 4, pp. 285–288, dec. 1971"
  ],
  "qa": "skimage.restoration.deconvolution:wiener",
  "arbitrary": [],
  "local_refs": [
    "balance",
    "clip",
    "im_deconv",
    "image",
    "is_real",
    "psf",
    "reg"
  ]
}