{"id":1964,"date":"2022-01-13T17:03:03","date_gmt":"2022-01-13T09:03:03","guid":{"rendered":"http:\/\/139.9.1.231\/?p=1964"},"modified":"2022-01-13T17:19:57","modified_gmt":"2022-01-13T09:19:57","slug":"inpint","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/13\/inpint\/","title":{"rendered":"\u56fe\u50cf\u4fee\u8865"},"content":{"rendered":"\n<p class=\"has-light-pink-background-color has-background\">\u4f60\u4eec\u5927\u591a\u6570\u4eba\u5bb6\u91cc\u90fd\u4f1a\u6709\u4e00\u4e9b\u65e7\u7684\u65e7\u5316\u7167\u7247\uff0c\u4e0a\u9762\u6709\u9ed1\u70b9\uff0c\u4e00\u4e9b\u7b14\u89e6\u7b49\u3002\u4f60\u662f\u5426\u66fe\u7ecf\u60f3\u8fc7\u5c06\u5176\u8fd8\u539f\uff1f\u6211\u4eec\u4e0d\u80fd\u7b80\u5355\u5730\u5728\u7ed8\u753b\u5de5\u5177\u4e2d\u64e6\u9664\u5b83\u4eec\uff0c\u56e0\u4e3a\u5b83\u5c06\u7b80\u5355\u5730\u7528\u767d\u8272\u7ed3\u6784\u4ee3\u66ff\u9ed1\u8272\u7ed3\u6784\uff0c\u8fd9\u662f\u6ca1\u6709\u7528\u7684\u3002\u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5c06\u4f7f\u7528\u4e00\u79cd\u79f0\u4e3a\u56fe\u50cf\u4fee\u590d\u7684\u6280\u672f\u3002<strong>\u57fa\u672c\u601d\u60f3\u5f88\u7b80\u5355\uff1a\u7528\u9644\u8fd1\u7684\u50cf\u7d20\u66ff\u6362\u90a3\u4e9b\u4e0d\u826f\u533a\u57df\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u548c\u90bb\u8fd1\u7684\u534f\u8c03\u3002<\/strong>\u8003\u8651\u4e0b\u9762\u663e\u793a\u7684\u56fe\u50cf\uff08\u6458\u81eaWikipedia\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"http:\/\/qiniu.aihubs.net\/inpaint_basics.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u57fa\u4e8e\u6b64\u76ee\u7684\u8bbe\u8ba1\u4e86\u51e0\u79cd\u7b97\u6cd5\uff0cOpenCV\u63d0\u4f9b\u4e86\u5176\u4e2d\u4e24\u79cd\u3002 \u4e24\u8005\u90fd\u53ef\u4ee5\u901a\u8fc7\u76f8\u540c\u7684\u51fd\u6570\u8fdb\u884c\u8bbf\u95ee\uff0c<strong>cv.inpaint<\/strong>()<\/p>\n\n\n\n<p>\u7b2c\u4e00\u79cd\u7b97\u6cd5\u57fa\u4e8eAlexandru Telea\u57282004\u5e74\u53d1\u8868\u7684\u8bba\u6587\u201c\u57fa\u4e8e\u5feb\u901f\u884c\u8fdb\u65b9\u6cd5\u7684\u56fe\u50cf\u4fee\u8865\u6280\u672f\u201d\u3002\u5b83\u57fa\u4e8e\u5feb\u901f\u884c\u8fdb\u65b9\u6cd5\u3002\u8003\u8651\u56fe\u50cf\u4e2d\u8981\u4fee\u590d\u7684\u533a\u57df\u3002\u7b97\u6cd5\u4ece\u8be5\u533a\u57df\u7684\u8fb9\u754c\u5f00\u59cb\uff0c\u5e76\u8fdb\u5165\u8be5\u533a\u57df\u5185\u90e8\uff0c\u9996\u5148\u9010\u6e10\u586b\u5145\u8fb9\u754c\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u3002\u5728\u8981\u4fee\u590d\u7684\u90bb\u57df\u4e0a\u7684\u50cf\u7d20\u5468\u56f4\u9700\u8981\u4e00\u4e2a\u5c0f\u7684\u90bb\u57df\u3002\u8be5\u50cf\u7d20\u88ab\u9644\u8fd1\u6240\u6709\u5df2\u77e5\u50cf\u7d20\u7684\u5f52\u4e00\u5316\u52a0\u6743\u603b\u548c\u6240\u4ee3\u66ff\u3002\u6743\u91cd\u7684\u9009\u62e9\u5f88\u91cd\u8981\u3002\u90a3\u4e9b\u4f4d\u4e8e\u8be5\u70b9\u9644\u8fd1\uff0c\u8fb9\u754c\u6cd5\u7ebf\u9644\u8fd1\u7684\u50cf\u7d20\u548c\u90a3\u4e9b\u4f4d\u4e8e\u8fb9\u754c\u8f6e\u5ed3\u7ebf\u4e0a\u7684\u50cf\u7d20\u5c06\u83b7\u5f97\u66f4\u5927\u7684\u6743\u91cd\u3002\u4fee\u590d\u50cf\u7d20\u540e\uff0c\u5c06\u4f7f\u7528\u5feb\u901f\u884c\u8fdb\u65b9\u6cd5\u5c06\u5176\u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u6700\u8fd1\u7684\u50cf\u7d20\u3002FMM\u786e\u4fdd\u9996\u5148\u4fee\u590d\u5df2\u77e5\u50cf\u7d20\u9644\u8fd1\u7684\u90a3\u4e9b\u50cf\u7d20\uff0c\u4ee5\u4fbf\u50cf\u624b\u52a8\u542f\u53d1\u5f0f\u64cd\u4f5c\u4e00\u6837\u5de5\u4f5c\u3002\u901a\u8fc7\u4f7f\u7528\u6807\u5fd7**cv.INPAINT_TELEA**\u542f\u7528\u6b64\u7b97\u6cd5\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u79cd\u7b97\u6cd5\u57fa\u4e8eBertalmio\uff0cMarcelo\uff0cAndrea L. Bertozzi\u548cGuillermo Sapiro\u57282001\u5e74\u53d1\u8868\u7684\u8bba\u6587\u201c Navier-Stokes\uff0c\u6d41\u4f53\u52a8\u529b\u5b66\u4ee5\u53ca\u56fe\u50cf\u548c\u89c6\u9891\u4fee\u8865\u201d\u3002\u8be5\u7b97\u6cd5\u57fa\u4e8e\u6d41\u4f53\u52a8\u529b\u5b66\u5e76\u5229\u7528\u4e86 \u504f\u5fae\u5206\u65b9\u7a0b\u3002\u57fa\u672c\u539f\u7406\u662f\u542f\u53d1\u5f0f\u7684\u3002\u5b83\u9996\u5148\u6cbf\u7740\u8fb9\u7f18\u4ece\u5df2\u77e5\u533a\u57df\u79fb\u52a8\u5230\u672a\u77e5\u533a\u57df\uff08\u56e0\u4e3a\u8fb9\u7f18\u662f\u8fde\u7eed\u7684\uff09\u3002\u5b83\u5ef6\u7eed\u4e86\u7b49\u8ddd\u7ebf\uff08\u7ebf\u8fde\u63a5\u5177\u6709\u76f8\u540c\u5f3a\u5ea6\u7684\u70b9\uff0c\u5c31\u50cf\u8f6e\u5ed3\u7ebf\u8fde\u63a5\u5177\u6709\u76f8\u540c\u9ad8\u7a0b\u7684\u70b9\u4e00\u6837\uff09\uff0c\u540c\u65f6\u5728\u4fee\u590d\u533a\u57df\u7684\u8fb9\u754c\u5339\u914d\u68af\u5ea6\u77e2\u91cf\u3002\u4e3a\u6b64\uff0c\u4f7f\u7528\u4e86\u4e00\u4e9b\u6d41\u4f53\u52a8\u529b\u5b66\u65b9\u6cd5\u3002\u83b7\u5f97\u5b83\u4eec\u540e\uff0c\u5c06\u586b\u5145\u989c\u8272\u4ee5\u51cf\u5c11\u8be5\u533a\u57df\u7684\u6700\u5c0f\u5dee\u5f02\u3002\u901a\u8fc7\u4f7f\u7528\u6807\u5fd7**cv.INPAINT_NS**\u542f\u7528\u6b64\u7b97\u6cd5\u3002<\/p>\n\n\n\n<h3 id=\"_3\">\u4ee3\u7801<a href=\"http:\/\/woshicver.com\/Tenth\/9_2_%E5%9B%BE%E5%83%8F%E4%BF%AE%E8%A1%A5\/#_3\"><\/a><\/h3>\n\n\n\n<p>\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4e0e\u8f93\u5165\u56fe\u50cf\u5927\u5c0f\u76f8\u540c\u7684\u63a9\u7801\uff0c\u5176\u4e2d\u975e\u96f6\u50cf\u7d20\u5bf9\u5e94\u4e8e\u8981\u4fee\u590d\u7684\u533a\u57df\u3002\u5176\u4ed6\u4e00\u5207\u90fd\u5f88\u7b80\u5355\u3002\u6211\u7684\u56fe\u50cf\u56e0\u4e00\u4e9b\u9ed1\u8272\u7b14\u753b\u800c\u65e7\u5316\uff08\u6211\u624b\u52a8\u6dfb\u52a0\u4e86\uff09\u3002\u6211\u4f7f\u7528\u201c\u7ed8\u753b\u201d\u5de5\u5177\u521b\u5efa\u4e86\u76f8\u5e94\u7684\u7b14\u89e6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport cv2 as cv\nimg = cv.imread('messi_2.jpg')\nmask = cv.imread('mask2.png',0)\ndst = cv.inpaint(img,mask,3,cv.INPAINT_TELEA)\ncv.imshow('dst',dst)\ncv.waitKey(0)\ncv.destroyAllWindows()<\/code><\/pre>\n\n\n\n<p>\u8bf7\u53c2\u9605\u4e0b\u9762\u7684\u7ed3\u679c\u3002\u7b2c\u4e00\u5f20\u56fe\u7247\u663e\u793a\u4e86\u964d\u7ea7\u7684\u8f93\u5165\u3002\u7b2c\u4e8c\u4e2a\u56fe\u50cf\u662f\u63a9\u7801\u3002\u7b2c\u4e09\u4e2a\u56fe\u50cf\u662f\u7b2c\u4e00\u4e2a\u7b97\u6cd5\u7684\u7ed3\u679c\uff0c\u6700\u540e\u4e00\u4e2a\u56fe\u50cf\u662f\u7b2c\u4e8c\u4e2a\u7b97\u6cd5\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"http:\/\/qiniu.aihubs.net\/inpaint_result.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>### \u9644\u52a0\u8d44\u6e90 1. Bertalmio, Marcelo, Andrea L. Bertozzi, and Guillermo Sapiro. \u201cNavier-stokes, fluid dynamics, and image and video inpainting.\u201d In Computer Vision and Pattern Recognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on, vol. 1, pp. I-355. IEEE, 2001. 2. Telea, Alexandru. \u201cAn image inpainting technique based on the fast marching method.\u201d Journal of graphics tools 9.1 (2004): 23-34.<\/p>\n\n\n\n<h3 id=\"_4\">\u7ec3\u4e60<a href=\"http:\/\/woshicver.com\/Tenth\/9_2_%E5%9B%BE%E5%83%8F%E4%BF%AE%E8%A1%A5\/#_4\"><\/a><\/h3>\n\n\n\n<ol><li>OpenCV\u4e00\u4e2a\u6709\u5173\u4fee\u590d\u7684\u4ea4\u4e92\u5f0f\u793a\u4f8b\uff0csamples\/python\/inpaint.py\uff0c\u8bf7\u5c1d\u8bd5\u4e00\u4e0b\u3002<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env python\n\n'''\nInpainting sample.\nInpainting repairs damage to images by floodfilling\nthe damage with surrounding image areas.\nUsage:\n  inpaint.py &#91;&lt;image&gt;]\nKeys:\n  SPACE - inpaint\n  r     - reset the inpainting mask\n  ESC   - exit\n'''\n\n# Python 2\/3 compatibility\nfrom __future__ import print_function\n\nimport numpy as np\nimport cv2 as cv\n\nfrom common import Sketcher\n\ndef main():\n    import sys\n    try:\n        fn = sys.argv&#91;1]\n    except:\n        fn = 'fruits.jpg'\n\n    img = cv.imread(cv.samples.findFile(fn))\n    if img is None:\n        print('Failed to load image file:', fn)\n        sys.exit(1)\n\n    img_mark = img.copy()\n    mark = np.zeros(img.shape&#91;:2], np.uint8)\n    sketch = Sketcher('img', &#91;img_mark, mark], lambda : ((255, 255, 255), 255))\n\n    while True:\n        ch = cv.waitKey()\n        if ch == 27:\n            break\n        if ch == ord(' '):\n            res = cv.inpaint(img_mark, mark, 3, cv.INPAINT_TELEA)\n            cv.imshow('inpaint', res)\n        if ch == ord('r'):\n            img_mark&#91;:] = img\n            mark&#91;:] = 0\n            sketch.show()\n\n    print('Done')\n\n\nif __name__ == '__main__':\n    print(__doc__)\n    main()\n    cv.destroyAllWindows()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u4eec\u5927\u591a\u6570\u4eba\u5bb6\u91cc\u90fd\u4f1a\u6709\u4e00\u4e9b\u65e7\u7684\u65e7\u5316\u7167\u7247\uff0c\u4e0a\u9762\u6709\u9ed1\u70b9\uff0c\u4e00\u4e9b\u7b14\u89e6\u7b49\u3002\u4f60\u662f\u5426\u66fe\u7ecf\u60f3\u8fc7\u5c06\u5176\u8fd8\u539f\uff1f\u6211\u4eec\u4e0d\u80fd\u7b80\u5355\u5730\u5728\u7ed8\u753b\u5de5 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/13\/inpint\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u56fe\u50cf\u4fee\u8865<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1964"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=1964"}],"version-history":[{"count":4,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1964\/revisions"}],"predecessor-version":[{"id":1974,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1964\/revisions\/1974"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=1964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=1964"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=1964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}