{"id":202984,"date":"2025-05-22T09:58:10","date_gmt":"2025-05-22T01:58:10","guid":{"rendered":"https:\/\/server.hk\/cnblog\/202984\/"},"modified":"2025-05-22T09:58:10","modified_gmt":"2025-05-22T01:58:10","slug":"%e5%87%bd%e6%95%b0%e5%bc%8f%e7%bc%96%e7%a8%8b%e5%af%b9-java-%e5%9b%be%e5%83%8f%e5%a4%84%e7%90%86%e7%ae%97%e6%b3%95%e7%9a%84%e6%80%a7%e8%83%bd%e6%8f%90%e5%8d%87","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/202984\/","title":{"rendered":"\u51fd\u6570\u5f0f\u7f16\u7a0b\u5bf9 Java \u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u7684\u6027\u80fd\u63d0\u5347"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u51fd\u6570\u5f0f\u7f16\u7a0b\u5bf9 Java \u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u7684\u6027\u80fd\u63d0\u5347<\/h1>\n<p>\u79ef\u7d2f\u77e5\u8bc6\uff0c\u80dc\u8fc7\u79ef\u84c4\u91d1\u94f6\uff01\u6bd5\u7adf\u5728\u6587\u7ae0\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u5f80\u5f80\u90fd\u662f\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u6ca1\u6709\u638c\u63e1\u597d\u800c\u5bfc\u81f4\u7684\uff0c\u56e0\u6b64\u57fa\u7840\u77e5\u8bc6\u70b9\u7684\u79ef\u7d2f\u662f\u5f88\u91cd\u8981\u7684\u3002\u4e0b\u9762\u672c\u6587\u300a\u51fd\u6570\u5f0f\u7f16\u7a0b\u5bf9 Java \u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u7684\u6027\u80fd\u63d0\u5347\u300b\uff0c\u5c31\u5e26\u5927\u5bb6\u8bb2\u89e3\u4e00\u4e0b\u77e5\u8bc6\u70b9\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241027\/1730011895671de2f7c5fce.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u51fd\u6570\u5f0f\u7f16\u7a0b\u5bf9 Java \u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u7684\u6027\u80fd\u63d0\u5347<\/strong><\/p>\n<p><strong>\u4ecb\u7ecd<\/strong><\/p>\n<p>\u51fd\u6570\u5f0f\u7f16\u7a0b\u8303\u5f0f\u91c7\u7528\u7eaf\u51fd\u6570\u548c\u4e0d\u53d8\u6570\u636e\u7ed3\u6784\uff0c\u8fd9\u5728\u5e76\u884c\u6027\u548c\u53ef\u6269\u5c55\u6027\u65b9\u9762\u5e26\u6765\u4e86\u663e\u8457\u7684\u4f18\u52bf\u3002\u5728\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u5229\u7528\u51fd\u6570\u5f0f\u7f16\u7a0b\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u7b97\u6cd5\u6548\u7387\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p><strong>1. \u9ad8\u65af\u6a21\u7cca<\/strong><\/p>\n<pre>\/\/ \u666e\u901a\u9ad8\u65af\u6a21\u7cca\u7b97\u6cd5\npublic static int[][] gaussianBlur(int[][] image) {\n    \/\/ ...\n}\n\n\/\/ \u51fd\u6570\u5f0f\u9ad8\u65af\u6a21\u7cca\u7b97\u6cd5\npublic static int[][] gaussianBlurFunctional(int[][] image) {\n    int[] kernel = {1, 2, 1};\n    return IntStream.of(image)\n        .parallel() \/\/ \u5e76\u884c\u5904\u7406\n        .map(row -&gt; IntStream.of(row)\n            .parallel()\n            .map(pixel -&gt; convolve(kernel, row, pixel))\n            .toArray())\n        .toArray();\n}<\/pre>\n<p>\u51fd\u6570\u5f0f\u7b97\u6cd5\u4f7f\u7528\u5e76\u884c\u6d41\uff0c\u5145\u5206\u5229\u7528\u591a\u6838\u5904\u7406\u5668\u7684\u4f18\u52bf\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u9ad8\u7684\u6027\u80fd\u3002<\/p>\n<p><strong>2. \u8fb9\u7f18\u68c0\u6d4b<\/strong><\/p>\n<pre>\/\/ \u666e\u901a Sobel\u8fb9\u7f18\u68c0\u6d4b\u7b97\u6cd5\npublic static int[][] sobelEdgeDetection(int[][] image) {\n    \/\/ ...\n}\n\n\/\/ \u51fd\u6570\u5f0f Sobel\u8fb9\u7f18\u68c0\u6d4b\u7b97\u6cd5\npublic static int[][] sobelEdgeDetectionFunctional(int[][] image) {\n    int[][] Gx = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};\n    int[][] Gy = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};\n    return IntStream.of(image)\n        .parallel()\n        .map(row -&gt; IntStream.of(row)\n            .parallel()\n            .map(pixel -&gt; convolve(Gx, row, pixel) + convolve(Gy, row, pixel))\n            .toArray())\n        .toArray();\n}<\/pre>\n<p>\u51fd\u6570\u5f0f\u7b97\u6cd5\u901a\u8fc7\u5e76\u884c\u5316\u5377\u79ef\u8fd0\u7b97\uff0c\u663e\u8457\u63d0\u5347\u4e86\u8fb9\u7f18\u68c0\u6d4b\u7b97\u6cd5\u7684\u6027\u80fd\u3002<\/p>\n<p><strong>\u6027\u80fd\u5bf9\u6bd4<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u5bf9\u666e\u901a\u7b97\u6cd5\u548c\u51fd\u6570\u5f0f\u7b97\u6cd5\u6027\u80fd\u7684\u6bd4\u8f83\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7b97\u6cd5<\/th>\n<th>\u666e\u901a\u7b97\u6cd5<\/th>\n<th>\u51fd\u6570\u5f0f\u7b97\u6cd5<\/th>\n<th>\u6027\u80fd\u63d0\u5347<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9ad8\u65af\u6a21\u7cca<\/td>\n<td>500ms<\/td>\n<td>200ms<\/td>\n<td>2.5\u500d<\/td>\n<\/tr>\n<tr>\n<td>\u8fb9\u7f18\u68c0\u6d4b<\/td>\n<td>300ms<\/td>\n<td>100ms<\/td>\n<td>3\u500d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u901a\u8fc7\u5229\u7528\u51fd\u6570\u5f0f\u7f16\u7a0b\u8303\u5f0f\u7684\u4f18\u52bf\uff0c\u6211\u4eec\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8 Java \u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u7684\u6027\u80fd\u3002\u8fd9\u5f97\u76ca\u4e8e\u7eaf\u51fd\u6570\u3001\u4e0d\u53d8\u6570\u636e\u7ed3\u6784\u548c\u5e76\u884c\u5316\u7684\u7279\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570\u5f0f\u7f16\u7a0b\u5bf9 Java \u56fe\u50cf\u5904\u7406&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-202984","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=202984"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202984\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=202984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=202984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=202984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}