{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/sobel-operator/",
  "atlas": "https://www.pystone.net/?node=sobel-operator#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/sobel-operator.md",
  "context": "https://www.pystone.net/notes/sobel-operator.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:sobel-operator",
  "slug": "sobel-operator",
  "title": "Sobel operator",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Sobel operator",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "376133af7cae1a9e8858f23d93dd2ab9b05271bd4f4d0d77aeb0850c0fbca957",
  "assets": [
    {
      "reference": "assets/1614307655559.png",
      "url": "/media/dc7d836db46a7e2c4761.png",
      "mediaType": "image/png",
      "contentHash": "dc7d836db46a7e2c47611f931df72a4a954b74b6d45c4c2b1fc1b6a7e6b390da",
      "byteLength": 44860,
      "width": 1209,
      "height": 272
    },
    {
      "reference": "assets/1614309214023.png",
      "url": "/media/bfa3967d5c84ed72be30.png",
      "mediaType": "image/png",
      "contentHash": "bfa3967d5c84ed72be30a98deff3f72b06ae64ff578cb2dd2b8ffc2fab6eeb76",
      "byteLength": 110186,
      "width": 941,
      "height": 770
    },
    {
      "reference": "assets/1614325004782.png",
      "url": "/media/c2d13b603268d834b7e6.png",
      "mediaType": "image/png",
      "contentHash": "c2d13b603268d834b7e6bbb8b4c92a5e76c4a0ae93db2b2c3a4af1d6f6ab1662",
      "byteLength": 21309,
      "width": 422,
      "height": 280
    },
    {
      "reference": "assets/1614325088192.png",
      "url": "/media/abb8d03709abfd168f5b.png",
      "mediaType": "image/png",
      "contentHash": "abb8d03709abfd168f5b630412c6de13c8cc3914988eda10e91602ce2e0ec460",
      "byteLength": 164007,
      "width": 720,
      "height": 326
    },
    {
      "reference": "assets/1614325113469.png",
      "url": "/media/09e4b946c151ff7d3008.png",
      "mediaType": "image/png",
      "contentHash": "09e4b946c151ff7d3008afaeaa944a662325af0d2b4db856b06fb05950201320",
      "byteLength": 5932,
      "width": 300,
      "height": 109
    },
    {
      "reference": "assets/1614325174627.png",
      "url": "/media/e20169a00a4ad6c2e2cd.png",
      "mediaType": "image/png",
      "contentHash": "e20169a00a4ad6c2e2cd7b0fcf105938b23110e8e64438a151efb05c98310d8a",
      "byteLength": 7828,
      "width": 616,
      "height": 63
    },
    {
      "reference": "assets/1614325147490.png",
      "url": "/media/d2352361e72077d73c67.png",
      "mediaType": "image/png",
      "contentHash": "d2352361e72077d73c67ea2457ba2b1d858869acef016e3dc91d0675faef38be",
      "byteLength": 5205,
      "width": 290,
      "height": 97
    },
    {
      "reference": "assets/1614325218437.png",
      "url": "/media/3dda0535799491690f09.png",
      "mediaType": "image/png",
      "contentHash": "3dda0535799491690f09faf7ea2e2b5868c5d92622b100c7c99cd2e4ce7713ce",
      "byteLength": 14591,
      "width": 597,
      "height": 130
    },
    {
      "reference": "assets/1614325564506.png",
      "url": "/media/75b56b9e717744564c8a.png",
      "mediaType": "image/png",
      "contentHash": "75b56b9e717744564c8ae5b5cc79a5e76c7570f725738d146fe4df74b9caa67e",
      "byteLength": 5502,
      "width": 532,
      "height": 262
    },
    {
      "reference": "assets/1614326498086.png",
      "url": "/media/258688e0753703558f98.png",
      "mediaType": "image/png",
      "contentHash": "258688e0753703558f9846247a19329567861d0f2c33580b909476590bff22ba",
      "byteLength": 835,
      "width": 162,
      "height": 31
    },
    {
      "reference": "assets/1614326508239.png",
      "url": "/media/c0eecfd4bf6b6a844264.png",
      "mediaType": "image/png",
      "contentHash": "c0eecfd4bf6b6a844264f1ee000654bff6f41bd695a0d6f4637b1a3030e5fbc3",
      "byteLength": 646,
      "width": 153,
      "height": 26
    },
    {
      "reference": "assets/1614326609475.png",
      "url": "/media/353bca4e0ba95a9200ae.png",
      "mediaType": "image/png",
      "contentHash": "353bca4e0ba95a9200ae8c75c246cd719305b7b0ba4f5b26a83434783d93ec5d",
      "byteLength": 904,
      "width": 167,
      "height": 26
    },
    {
      "reference": "assets/1614326653052.png",
      "url": "/media/d42577c6cbc52c85e03e.png",
      "mediaType": "image/png",
      "contentHash": "d42577c6cbc52c85e03e5e5659f93f03a3066dd371a7013bcd511571800a1fa4",
      "byteLength": 2630,
      "width": 474,
      "height": 43
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "Sobel operator",
      "anchor": "sobel-operator",
      "citation": "https://www.pystone.net/notes/sobel-operator/#sobel-operator"
    },
    {
      "depth": 2,
      "text": "背景知识",
      "anchor": "背景知识",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E8%83%8C%E6%99%AF%E7%9F%A5%E8%AF%86"
    },
    {
      "depth": 3,
      "text": "术语",
      "anchor": "术语",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E6%9C%AF%E8%AF%AD"
    },
    {
      "depth": 3,
      "text": "算子(operator)",
      "anchor": "算子operator",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E7%AE%97%E5%AD%90operator"
    },
    {
      "depth": 3,
      "text": "差分算子",
      "anchor": "差分算子",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E5%B7%AE%E5%88%86%E7%AE%97%E5%AD%90"
    },
    {
      "depth": 3,
      "text": "图像处理中的卷积",
      "anchor": "图像处理中的卷积",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E5%8D%B7%E7%A7%AF"
    },
    {
      "depth": 2,
      "text": "Sobel边缘检测",
      "anchor": "sobel边缘检测",
      "citation": "https://www.pystone.net/notes/sobel-operator/#sobel%E8%BE%B9%E7%BC%98%E6%A3%80%E6%B5%8B"
    },
    {
      "depth": 2,
      "text": "代码",
      "anchor": "代码",
      "citation": "https://www.pystone.net/notes/sobel-operator/#%E4%BB%A3%E7%A0%81"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/sobel-operator/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "渲染基础中的“Sobel operator”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#%E6%B8%B2%E6%9F%93%E5%9F%BA%E7%A1%80"
    }
  ],
  "contentMarkdown": "# Sobel operator\n\n> 创建时间：2021/2/25 21:01\n\n  * Sobel operator\n    * 背景知识\n      * 术语\n      * 算子(operator)\n      * 差分算子\n      * 图像处理中的卷积\n    * Sobel边缘检测\n    * 代码\n    * Ref\n\n## 背景知识\n\n索贝尔算子（Sobel operator）主要用作边缘检测，在技术上，它是一离散性差分算子，用来运算图像亮度函数的灰度之近似值。在图像的任何一点使用此算子，将会产生对应的灰度矢量或是其法矢量。\n\n### 术语\n\n  * 边缘：灰度或结构等信息的突变处，边缘是一个区域的结束，也是另一个区域的开始，利用该特征可以分割图像。\n\n  * 边缘点：图像中具有坐标[x，y]，且处在强度显著变化的位置上的点。\n\n  * 边缘段：对应于边缘点坐标[x，y]及其方位 ，边缘的方位可能是梯度角。\n\n### 算子(operator)\n\n算子（英语：Operator）是将一个元素在向量空间（或模）中转换为另一个元素的映射。\n\n![Alt text](assets/1614307655559.png)\n\n摘录知乎的回答（<https://www.zhihu.com/question/24989360/answer/29702293>）：\n算子含义为操作、运算等等。算子可以理解为，把一个函数变成另一个函数的东西。\n函数是从数到数的映射。\n泛函是从函数到数的映射。\n算子是从函数到函数的映射。\n当然，有的时候这几个词可以混用，比如可以可以把数当作常函数，那么普通的函数也可以看作泛函或算子；再比如考虑从算子到算子的映射，你仍然可以叫它算子。\n\n![Alt text](assets/1614309214023.png)\n\n### 差分算子\n\n百度百科：\n差分算子是一种算子，对任一实函数f(x)，若记Δf(x)=f(x+1)-f(x)，则称Δ为向前差分算子，简称差分算子。差分是计算数学的基本概念之一，指离散函数在离散节点上的改变量。\n\n维基百科：\n差分，又名差分函数或差分运算，是数学中的一个概念。它将原函数\n映射到\n。差分运算，相应于微分运算，是微积分中重要的一个概念。\n\n### 图像处理中的卷积\n\n![Alt text](assets/1614325004782.png)\n\n所谓两个函数的卷积，本质上就是先将一个函数翻转，然后进行滑动叠加。\n在图像处理的中，卷积处理的结果，其实就是把每个像素周边的像素都考虑进来，进行加权求和。\n\n![Alt text](assets/1614325088192.png)\n\n![Alt text](assets/1614325113469.png)\n\n![Alt text](assets/1614325174627.png)\n\n![Alt text](assets/1614325147490.png)\n\n计算卷积时，就可以用 f 和 g’ 的内积：\n\n![Alt text](assets/1614325218437.png)\n\n使用卷积，实质上是使用一个矩阵，表示像素点周围各个像素点的权值，对范围内的像素值做加权求平均。\n\n## Sobel边缘检测\n\n使用Sobel算子对传进来的图像像素做卷积。\n卷积的实质是在求梯度值。\n卷积核( convolution kernels)\n\n![Alt text](assets/1614325564506.png)\n\n> 可以直观地看到，用这两个矩阵与像素及其周围的像素点求卷积之后，像素亮度在x或y轴方向上变化越大，得到的值的绝对值越大。\n\nThe kernels can be applied separately to the input image, to produce separate measurements of the gradient component in each orientation.\n\n> A very common operator for doing this is a Sobel Operator, which is an approximation to a derivative of an image.\n\nThese can then be combined together to find the absolute magnitude of the gradient at each point and the orientation of that gradient.\n\n![Alt text](assets/1614326498086.png)\n\nTypically, an approximate magnitude is computed using:\n\n![Alt text](assets/1614326508239.png)\n\nThe angle of orientation of the edge (relative to the pixel grid) giving rise to the spatial gradient is given by:\n\n![Alt text](assets/1614326609475.png)\n\n![Alt text](assets/1614326653052.png)\n\n## 代码\n\n```cpp\nstring s = String.Empty;\n\n```\n\n## Ref\n\n<https://zh.wikipedia.org/zh-cn/%E7%AE%97%E5%AD%90>\n<https://www.zhihu.com/question/24989360/answer/29702293>\n<https://baike.baidu.com/item/%E5%B7%AE%E5%88%86%E7%AE%97%E5%AD%90>\n<https://medium.datadriveninvestor.com/understanding-edge-detection-sobel-operator-2aada303b900>\n<http://homepages.inf.ed.ac.uk/rbf/HIPR2/sobel.htm>\n<http://recreationstudios.blogspot.com/search/label/Compute%20Shader>\n"
}
