{"id":2777,"date":"2013-02-24T22:55:27","date_gmt":"2013-02-24T14:55:27","guid":{"rendered":"http:\/\/vanabel.sinaapp.com\/?p=2777"},"modified":"2013-02-24T22:55:27","modified_gmt":"2013-02-24T14:55:27","slug":"%e5%88%a9%e7%94%a8mathematica%e5%88%a0%e9%99%a4%e5%a4%8d%e5%8d%b0%e4%ba%a7%e7%94%9f%e7%9a%84%e9%bb%91%e8%be%b9","status":"publish","type":"post","link":"https:\/\/lttt.vanabel.cn\/?p=2777","title":{"rendered":"\u5229\u7528Mathematica\u5220\u9664\u590d\u5370\u4ea7\u751f\u7684\u9ed1\u8fb9"},"content":{"rendered":"<h3>\u5047\u8bbe\u590d\u5370\u7684\u56fe\u50cf\u4e3a<\/h3>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">img=\u56fe\u50cf\u6216\u5176\u5730\u5740<\/pre>\n<h3>\u624b\u52a8\u6307\u5b9a\u6b32\u5220\u9664\u533a\u57df\u7684\u70b9<\/h3>\n<p>\u7b2c\u4e00\u79cd\u662f\u624b\u52a8\u6307\u5b9a\u6b32\u5220\u9664\u533a\u57df\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u70b9, \u5e76\u5229\u7528<strong>RegionBinarize<\/strong>\u6765\u4e8c\u503c\u5316\u56fe\u50cf<\/p>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">imgdel = RegionBinarize[img, {{1220, 1341}}, .25]\n<\/pre>\n<p><!--more--><br \/>\n\u8fd9\u91cc, {1220,1341}\u662f\u9ed1\u8fb9\u4e2d\u7684\u4e00\u70b9, Mathematica\u53ef\u4ee5\u901a\u8fc7\u5728\u56fe\u50cf\u4e0a\u53f3\u952e\u83b7\u5f97\u5bf9\u5e94\u70b9\u5750\u6807.<\/p>\n<h3>\u6700\u540e\u5229\u7528<strong>Inpaint<\/strong>\u53bb\u6c34\u5370\u4ece\u539f\u56fe\u4e2d\u5220\u9664\u9ed1\u8fb9.<\/h3>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">Inpaint[img, imgdel]<\/pre>\n<h3>\u81ea\u52a8\u751f\u6210\u6b32\u5220\u9664\u533a\u57df<\/h3>\n<p>\u5229\u7528<strong>FillingTransform<\/strong>\u51fd\u6570\u6211\u4eec\u53ef\u4ee5\u81ea\u52a8\u5b9a\u4f4d\u9ed1\u8fb9\u533a\u57df, \u4ece\u800c\u518d\u5229\u7528\u53bb\u6c34\u5370<strong>Inpaint<\/strong>\u51fd\u6570\u5220\u9664\u9ed1\u8fb9.<\/p>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">Inpaint[#, ColorNegate@FillingTransform[#]] &amp;@img<\/pre>\n<h3>\u4e00\u4e2a\u5b8c\u6574\u7684\u5904\u7406<\/h3>\n<p>\u63a5\u4e0b\u6765, \u6211\u5c06\u6f14\u793a\u5982\u4f55\u5b9e\u9645\u5730\u6279\u91cf\u5904\u7406\u4e00\u4e2a\u6587\u6863.<\/p>\n<h4>\u5b9a\u4e49\u5904\u7406\u51fd\u6570<\/h4>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">DelBlack[img_] := Inpaint[img, ColorNegate@FillingTransform[img]]<\/pre>\n<h4>\u5b9a\u4e49\u5de5\u4f5c\u76ee\u5f55<\/h4>\n<p>\u4e3a\u4e86\u65b9\u4fbf, \u6211\u4eec\u5c06\u6240\u6709\u5f85\u5904\u7406\u7684\u56fe\u50cf\u653e\u5230\u4e00\u4e2a\u76ee\u5f55\u4e2d, \u8bf7\u901a\u8fc7<strong>\u63d2\u5165<\/strong>-&gt;&#8221;\u6587\u4ef6\u8def\u5f84&#8221;(\u5e76\u5220\u9664\u6700\u540e\u7684\u6587\u4ef6\u8def\u5f84, \u56e0\u4e3a\u6211\u4eec\u8981\u7684\u662f\u8be5\u6587\u4ef6\u6240\u5728\u76ee\u5f55), \u8fd9\u91cc\u6211\u5047\u8bbe\u662f\u5728<br \/>\nC:\\Users\\van\\Desktop\\new\u4e0b, \u5219<\/p>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">SetDirectory[\"C:\\\\Users\\\\van\\\\Desktop\\\\new\"];<\/pre>\n<h4>\u67e5\u627e\u5de5\u4f5c\u76ee\u5f55\u4e0b\u6240\u6709\u56fe\u50cf\u6587\u4ef6, \u8bf7\u81ea\u884c\u6dfb\u52a0\u6ca1\u6709\u7684\u6269\u5c55\u540d<\/h4>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">FileList = FileNames[{\"*.jpg\", \"*.png\", \"*.gif\"}];<\/pre>\n<h4>\u7531\u4e8e\u6570\u636e\u5de8\u5927, \u5c1d\u8bd5\u91c7\u7528\u5e76\u884c\u8fd0\u7b97(\u591a\u6838)<\/h4>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">DistributeDefinitions[DelBlack]<\/pre>\n<h4>\u904d\u5386\u6574\u4e2a\u6587\u4ef6\u5217\u8868, \u5e76\u5c06\u5904\u7406\u540e\u7684\u56fe\u7247\u653e\u5165\u5f53\u524d\u76ee\u5f55\u7684\\new\\\u76ee\u5f55\u4e0b<\/h4>\n<pre lang=\"mathematica\" line=\"\" file=\"\" colla=\"+\">\nParallelize[Do[Export[\"new\\\\\"<>i, DelBlack[Import[FindFile[i]]]], {i, FileList}]]\n<\/pre>\n<h3>\u6548\u679c\u5982\u56fe<\/h3>\n<p><a href=\"http:\/\/i.imgur.com\/GAvYC8g.jpg\"><img decoding=\"async\" title=\"\u5904\u7406\u524d\" src=\"http:\/\/i.imgur.com\/GAvYC8g.jpg\" alt=\"\u5904\u7406\u524d\" width=\"45%\"  \/><\/a><a href=\"http:\/\/i.imgur.com\/7dMpcI3.jpg\"><img decoding=\"async\" class=\"alignright\" title=\"\u5904\u7406\u540e\" src=\"http:\/\/i.imgur.com\/7dMpcI3.jpg\" alt=\"\u5904\u7406\u540e\" width=\"45%\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5047\u8bbe\u590d\u5370\u7684\u56fe\u50cf\u4e3a img=\u56fe\u50cf\u6216\u5176\u5730\u5740 \u624b\u52a8\u6307\u5b9a\u6b32\u5220\u9664\u533a\u57df\u7684\u70b9 \u7b2c\u4e00\u79cd\u662f\u624b\u52a8\u6307\u5b9a &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/lttt.vanabel.cn\/?p=2777\"> <span class=\"screen-reader-text\">\u5229\u7528Mathematica\u5220\u9664\u590d\u5370\u4ea7\u751f\u7684\u9ed1\u8fb9<\/span> \u9605\u8bfb\u66f4\u591a &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[548,193,73,429],"class_list":["post-2777","post","type-post","status-publish","format-standard","hentry","category-net","tag-mathematica","tag-193","tag-73","tag-429"],"_links":{"self":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/2777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2777"}],"version-history":[{"count":0,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/2777\/revisions"}],"wp:attachment":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}