{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Example\n\nLet $\\Omega \\subseteq \\R^n$ be a bounded open set, let $f \\in L^2(\\Omega)$ be a noisy image, and let $\\lambda \u003e 0$.\nFor $u \\in L^2(\\Omega)$ let\n$$TV(u) = \\sup \\Big\\{ \\int_\\Omega u \\operatorname{div} \\varphi \\, dx : \\varphi \\in C^1_c(\\Omega; \\R^n), \\ \\abs{\\varphi(x)} \\le 1 \\text{ for all } x \\Big\\},$$\nthe [[total variation|8QA5DEWNYD]] of $u$, which equals $\\int_\\Omega \\abs{\\nabla u} \\, dx$ for smooth $u$.\n*Total variation denoising*, in the model of Rudin, Osher and Fatemi, replaces $f$ by the minimizer of\n$$E(u) = TV(u) + \\frac{\\lambda}{2} \\int_\\Omega (u - f)^2 \\, dx, \\qquad u \\in L^2(\\Omega).$$\nThe functional $E$ is lower semicontinuous, coercive and strictly [[convex|07Q7CNM5WF]] on the [[Lp space|SASP14MA1Z]] $L^2(\\Omega)$, so it has exactly one minimizer.\n\nA worked case on $\\Omega = (0, 1)$: let $h \u003e 0$ and $f = h$ on $(0, \\tfrac12)$, $f = 0$ on $(\\tfrac12, 1)$, a single edge of height $h$.\nAssume $\\lambda \\ge 4/h$ and set $\\delta = 2/\\lambda$.\nThe minimizer is $u = h - \\delta$ on $(0, \\tfrac12)$ and $u = \\delta$ on $(\\tfrac12, 1)$.\n\nCheck: let $w(x) = 2x$ on $[0, \\tfrac12]$ and $w(x) = 2 - 2x$ on $[\\tfrac12, 1]$.\nThen $\\abs{w} \\le 1$, $w(0) = w(1) = 0$, $w' = \\lambda (f - u)$, and $\\int_0^1 u w' \\, dx = h - 2\\delta = TV(u)$.\nFor every $v$ one has $TV(v) \\ge \\int_0^1 v w' \\, dx$, and expanding the squares gives $E(v) - E(u) \\ge \\frac{\\lambda}{2} \\int_0^1 (v - u)^2 \\, dx \\ge 0$.\n\n## Remarks\n\nThe edge survives at the same place, and its height drops from $h$ to $h - 4/\\lambda$.\nA quadratic penalty $\\int \\abs{\\nabla u}^2$ instead of $TV(u)$ would smear the jump into a smooth ramp.\nIf $\\lambda \u003c 4/h$, the minimizer is the constant $h/2$, so a weak fidelity term erases small edges.\n\n## Explanations\n\n### L1 human\n\nA noisy photo has many small random oscillations.\nTotal variation denoising looks for an image close to the photo whose total amount of up-and-down change is small.\nNoise has a lot of such change and is removed.\nA sharp edge costs only its height, not its steepness, so edges are kept, though with a little less contrast.\nIn the example, a step of height $h$ comes out as a step of height $h - 4/\\lambda$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "illustrates": [
      "8QA5DEWNYD"
    ],
    "kind": "example",
    "msc": [
      "94A08",
      "68U10",
      "49J45"
    ],
    "name": "Total variation denoising",
    "same_as": {
      "wikidata": "Q7828156",
      "wikipedia": "Total variation denoising"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Total_variation_denoising"
      }
    ],
    "tag": "M4RJHZ3KNA",
    "uses": [
      "8QA5DEWNYD",
      "SASP14MA1Z",
      "07Q7CNM5WF"
    ]
  },
  "kind": "example",
  "link": "https://tamnd.github.io/math2/node/M4RJHZ3KNA/",
  "links": [
    {
      "field": "illustrates",
      "target": "8QA5DEWNYD"
    },
    {
      "field": "uses",
      "target": "8QA5DEWNYD"
    },
    {
      "field": "uses",
      "target": "SASP14MA1Z"
    },
    {
      "field": "uses",
      "target": "07Q7CNM5WF"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/M4RJHZ3KNA.md",
  "msc": [
    "94A08",
    "68U10",
    "49J45"
  ],
  "name": "Total variation denoising",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/M4R/M4RJHZ3KNA.md",
  "status": null,
  "tag": "M4RJHZ3KNA",
  "uri": "m2://M4RJHZ3KNA",
  "url": "https://tamnd.github.io/math2/wiki/total-variation-denoising/",
  "writing": {
    "tag": "M4RJHZ3KNA",
    "kind": "example",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
