{"id":971456,"date":"2024-12-27T05:35:13","date_gmt":"2024-12-26T21:35:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/971456.html"},"modified":"2024-12-27T05:35:16","modified_gmt":"2024-12-26T21:35:16","slug":"python%e5%9b%be%e5%83%8f%e5%8d%b7%e7%a7%af%e5%a6%82%e4%bd%95%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/971456.html","title":{"rendered":"python\u56fe\u50cf\u5377\u79ef\u5982\u4f55\u7f16\u7a0b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194545\/44c98508-51a8-41a3-b1a3-6a6cb71f4133.webp\" alt=\"python\u56fe\u50cf\u5377\u79ef\u5982\u4f55\u7f16\u7a0b\" \/><\/p>\n<p><p> <strong>Python\u56fe\u50cf\u5377\u79ef\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u5e93\u5b9e\u73b0\uff0c\u5305\u62ecOpenCV\u3001NumPy\u548cScipy\u7b49\u3002\u9996\u5148\uff0c\u4e86\u89e3\u5377\u79ef\u7684\u57fa\u672c\u6982\u5ff5\u662f\u5173\u952e\uff0c\u5377\u79ef\u64cd\u4f5c\u662f\u5bf9\u56fe\u50cf\u77e9\u9635\u548c\u5377\u79ef\u6838\u77e9\u9635\u8fdb\u884c\u9010\u5143\u7d20\u76f8\u4e58\u5e76\u6c42\u548c\uff0c\u5f97\u5230\u65b0\u7684\u50cf\u7d20\u503c\u3002\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef\u7684\u57fa\u672c\u6b65\u9aa4\u5305\u62ec\uff1a\u52a0\u8f7d\u56fe\u50cf\u3001\u5b9a\u4e49\u5377\u79ef\u6838\u3001\u6267\u884c\u5377\u79ef\u64cd\u4f5c\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u56fe\u50cf\u5377\u79ef\u7f16\u7a0b\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5377\u79ef\u57fa\u672c\u6982\u5ff5<\/p>\n<\/p>\n<p><p>\u5377\u79ef\u662f\u4fe1\u53f7\u5904\u7406\u4e2d\u91cd\u8981\u7684\u64cd\u4f5c\uff0c\u901a\u8fc7\u5377\u79ef\u53ef\u4ee5\u8fdb\u884c\u56fe\u50cf\u7684\u5e73\u6ed1\u3001\u9510\u5316\u3001\u8fb9\u7f18\u68c0\u6d4b\u7b49\u64cd\u4f5c\u3002\u5377\u79ef\u64cd\u4f5c\u6d89\u53ca\u4e24\u4e2a\u4e3b\u8981\u7ec4\u4ef6\uff1a\u8f93\u5165\u56fe\u50cf\u548c\u5377\u79ef\u6838\uff08\u6216\u79f0\u6ee4\u6ce2\u5668\uff09\u3002\u5377\u79ef\u6838\u901a\u5e38\u662f\u4e00\u4e2a\u8f83\u5c0f\u7684\u77e9\u9635\uff0c\u5e94\u7528\u4e8e\u56fe\u50cf\u7684\u6bcf\u4e2a\u50cf\u7d20\u53ca\u5176\u5468\u56f4\u50cf\u7d20\uff0c\u4ee5\u751f\u6210\u65b0\u7684\u56fe\u50cf\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5377\u79ef\u6838\u7684\u5b9a\u4e49<\/strong><\/p>\n<\/p>\n<p><p>\u5377\u79ef\u6838\u662f\u4e00\u4e2am\u00d7n\u7684\u77e9\u9635\uff0c\u5176\u4e2dm\u548cn\u4e00\u822c\u4e3a\u5947\u6570\u3002\u5e38\u7528\u7684\u5377\u79ef\u6838\u6709\u6a21\u7cca\u6838\u3001\u9510\u5316\u6838\u3001\u8fb9\u7f18\u68c0\u6d4b\u6838\u7b49\u3002\u6a21\u7cca\u6838\u901a\u5e38\u7528\u4e8e\u56fe\u50cf\u5e73\u6ed1\u5904\u7406\uff0c\u800c\u9510\u5316\u6838\u7528\u4e8e\u589e\u5f3a\u56fe\u50cf\u7684\u8fb9\u7f18\u7ec6\u8282\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5377\u79ef\u64cd\u4f5c\u6b65\u9aa4<\/strong><\/p>\n<\/p>\n<p><p>\u5377\u79ef\u64cd\u4f5c\u7684\u57fa\u672c\u6b65\u9aa4\u5305\u62ec\uff1a\u5c06\u5377\u79ef\u6838\u5b9a\u4f4d\u5230\u8f93\u5165\u56fe\u50cf\u7684\u67d0\u4e2a\u50cf\u7d20\u4e0a\uff0c\u8ba1\u7b97\u5377\u79ef\u6838\u77e9\u9635\u4e0e\u56fe\u50cf\u5bf9\u5e94\u5b50\u77e9\u9635\u7684\u9010\u5143\u7d20\u4e58\u79ef\u548c\uff0c\u5c06\u7ed3\u679c\u4f5c\u4e3a\u5377\u79ef\u7ed3\u679c\u56fe\u50cf\u5bf9\u5e94\u4f4d\u7f6e\u7684\u50cf\u7d20\u503c\u3002\u91cd\u590d\u8fd9\u4e00\u8fc7\u7a0b\uff0c\u76f4\u5230\u5377\u79ef\u6838\u8986\u76d6\u6574\u5e45\u56fe\u50cf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528NumPy\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef<\/p>\n<\/p>\n<p><p>NumPy\u662fPython\u7684\u4e00\u4e2a\u5f3a\u5927\u5e93\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u6267\u884c\u6570\u7ec4\u8fd0\u7b97\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528NumPy\u6765\u624b\u52a8\u5b9e\u73b0\u5377\u79ef\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528PIL\uff08Python Imaging Library\uff09\u6216OpenCV\u52a0\u8f7d\u56fe\u50cf\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3aNumPy\u6570\u7ec4\u3002\u6ce8\u610f\u5982\u679c\u56fe\u50cf\u662f\u5f69\u8272\u7684\uff0c\u9700\u8981\u5c06\u5176\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u4ee5\u7b80\u5316\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf\u5e76\u8f6c\u6362\u4e3a\u7070\u5ea6<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;).convert(&#39;L&#39;)<\/p>\n<p>image_array = np.array(image)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u5377\u79ef\u6838<\/strong><\/p>\n<\/p>\n<p><p>\u5b9a\u4e49\u4e00\u4e2a\u7b80\u5355\u76843&#215;3\u5377\u79ef\u6838\uff0c\u4f8b\u5982\u7528\u4e8e\u8fb9\u7f18\u68c0\u6d4b\u7684Sobel\u7b97\u5b50\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49Sobel\u6c34\u5e73\u8fb9\u7f18\u68c0\u6d4b\u6838<\/p>\n<p>kernel = np.array([[-1, 0, 1],<\/p>\n<p>                   [-2, 0, 2],<\/p>\n<p>                   [-1, 0, 1]])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6267\u884c\u5377\u79ef\u64cd\u4f5c<\/strong><\/p>\n<\/p>\n<p><p>\u624b\u52a8\u5b9e\u73b0\u5377\u79ef\u7684\u5173\u952e\u5728\u4e8e\u904d\u5386\u56fe\u50cf\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\uff0c\u5e76\u8ba1\u7b97\u5377\u79ef\u6838\u4e0e\u5bf9\u5e94\u5b50\u533a\u57df\u7684\u70b9\u79ef\u548c\u3002\u9700\u8981\u6ce8\u610f\u5904\u7406\u56fe\u50cf\u8fb9\u754c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def convolve2d(image, kernel):<\/p>\n<p>    image_height, image_width = image.shape<\/p>\n<p>    kernel_height, kernel_width = kernel.shape<\/p>\n<p>    output = np.zeros((image_height, image_width))<\/p>\n<p>    # \u904d\u5386\u56fe\u50cf<\/p>\n<p>    for i in range(image_height - kernel_height + 1):<\/p>\n<p>        for j in range(image_width - kernel_width + 1):<\/p>\n<p>            # \u63d0\u53d6\u5b50\u533a\u57df<\/p>\n<p>            image_region = image[i:i + kernel_height, j:j + kernel_width]<\/p>\n<p>            # \u8ba1\u7b97\u5377\u79ef\u6838\u4e0e\u5b50\u533a\u57df\u7684\u4e58\u79ef\u548c<\/p>\n<p>            output[i + 1, j + 1] = np.sum(image_region * kernel)<\/p>\n<p>    return output<\/p>\n<h2><strong>\u6267\u884c\u5377\u79ef<\/strong><\/h2>\n<p>convolved_image = convolve2d(image_array, kernel)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684<code>convolve2d<\/code>\u51fd\u6570\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7b80\u5355\u76842D\u5377\u79ef\u64cd\u4f5c\u3002\u6ce8\u610f\u5230\u8f93\u51fa\u56fe\u50cf\u7684\u5c3a\u5bf8\u6bd4\u8f93\u5165\u56fe\u50cf\u5c0f\u4e00\u5708\uff0c\u56e0\u4e3a\u5377\u79ef\u6838\u65e0\u6cd5\u8d85\u51fa\u56fe\u50cf\u8fb9\u754c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528OpenCV\u8fdb\u884c\u56fe\u50cf\u5377\u79ef<\/p>\n<\/p>\n<p><p>OpenCV\u662f\u4e00\u4e2a\u5f00\u6e90\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\u3002\u4f7f\u7528OpenCV\u7684<code>filter2D<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u5377\u79ef\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5OpenCV<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86OpenCV\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7pip\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install opencv-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52a0\u8f7d\u56fe\u50cf\u548c\u5e94\u7528\u5377\u79ef<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528OpenCV\u52a0\u8f7d\u56fe\u50cf\uff0c\u5e76\u5e94\u7528\u5377\u79ef\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>image = cv2.imread(&#39;path_to_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u5b9a\u4e49\u5377\u79ef\u6838<\/strong><\/h2>\n<p>kernel = np.array([[-1, 0, 1],<\/p>\n<p>                   [-2, 0, 2],<\/p>\n<p>                   [-1, 0, 1]])<\/p>\n<h2><strong>\u4f7f\u7528filter2D\u51fd\u6570\u8fdb\u884c\u5377\u79ef<\/strong><\/h2>\n<p>convolved_image = cv2.filter2D(image, -1, kernel)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>OpenCV\u7684<code>filter2D<\/code>\u51fd\u6570\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u5377\u79ef\u8ba1\u7b97\uff0c\u5e76\u81ea\u52a8\u5904\u7406\u8fb9\u754c\u95ee\u9898\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570<code>-1<\/code>\u8868\u793a\u8f93\u51fa\u56fe\u50cf\u4e0e\u8f93\u5165\u56fe\u50cf\u5177\u6709\u76f8\u540c\u7684\u6df1\u5ea6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528Scipy\u8fdb\u884c\u56fe\u50cf\u5377\u79ef<\/p>\n<\/p>\n<p><p>Scipy\u662f\u53e6\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u5176<code>ndimage<\/code>\u6a21\u5757\u4e2d\u63d0\u4f9b\u4e86\u5377\u79ef\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Scipy<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u8fd8\u6ca1\u6709\u5b89\u88c5Scipy\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install scipy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Scipy\u8fdb\u884c\u5377\u79ef<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Scipy\u7684<code>convolve<\/code>\u51fd\u6570\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.ndimage import convolve<\/p>\n<h2><strong>\u4f7f\u7528Scipy\u8fdb\u884c\u5377\u79ef<\/strong><\/h2>\n<p>convolved_image = convolve(image_array, kernel)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Scipy\u7684<code>convolve<\/code>\u51fd\u6570\u4e0eNumPy\u548cOpenCV\u7c7b\u4f3c\uff0c\u81ea\u52a8\u5904\u7406\u56fe\u50cf\u8fb9\u754c\u5e76\u652f\u6301\u591a\u79cd\u5377\u79ef\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5377\u79ef\u5e94\u7528\u5b9e\u4f8b<\/p>\n<\/p>\n<p><p>\u5377\u79ef\u5728\u56fe\u50cf\u5904\u7406\u4e2d\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5e38\u89c1\u7684\u5e94\u7528\u5b9e\u4f8b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u56fe\u50cf\u6a21\u7cca<\/strong><\/p>\n<\/p>\n<p><p>\u6a21\u7cca\u5904\u7406\u53ef\u4ee5\u4f7f\u7528\u5747\u503c\u6ee4\u6ce2\u5668\uff08\u59823&#215;3\u7684\u5747\u503c\u6838\uff09\uff0c\u8fd9\u5bf9\u4e8e\u53bb\u9664\u566a\u58f0\u548c\u5e73\u6ed1\u56fe\u50cf\u975e\u5e38\u6709\u6548\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u5747\u503c\u6ee4\u6ce2\u5668<\/p>\n<p>blur_kernel = np.ones((3, 3)) \/ 9.0<\/p>\n<h2><strong>\u5e94\u7528\u6a21\u7cca\u5377\u79ef<\/strong><\/h2>\n<p>blurred_image = convolve(image_array, blur_kernel)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u56fe\u50cf\u9510\u5316<\/strong><\/p>\n<\/p>\n<p><p>\u9510\u5316\u5904\u7406\u53ef\u4ee5\u589e\u5f3a\u56fe\u50cf\u7684\u8fb9\u7f18\u7ec6\u8282\uff0c\u5e38\u7528\u7684\u9510\u5316\u6838\u5982\u62c9\u666e\u62c9\u65af\u7b97\u5b50\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u62c9\u666e\u62c9\u65af\u9510\u5316\u6838<\/p>\n<p>sharpen_kernel = np.array([[0, -1, 0],<\/p>\n<p>                           [-1, 5, -1],<\/p>\n<p>                           [0, -1, 0]])<\/p>\n<h2><strong>\u5e94\u7528\u9510\u5316\u5377\u79ef<\/strong><\/h2>\n<p>sharpened_image = convolve(image_array, sharpen_kernel)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fb9\u7f18\u68c0\u6d4b<\/strong><\/p>\n<\/p>\n<p><p>\u8fb9\u7f18\u68c0\u6d4b\u662f\u56fe\u50cf\u5904\u7406\u4e2d\u5e38\u89c1\u7684\u4efb\u52a1\uff0cSobel\u548cCanny\u7b97\u5b50\u662f\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u8fd9\u91cc\u4ee5Sobel\u7b97\u5b50\u4e3a\u4f8b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># Sobel\u8fb9\u7f18\u68c0\u6d4b<\/p>\n<p>sobel_x = np.array([[-1, 0, 1],<\/p>\n<p>                    [-2, 0, 2],<\/p>\n<p>                    [-1, 0, 1]])<\/p>\n<p>sobel_y = np.array([[-1, -2, -1],<\/p>\n<p>                    [0, 0, 0],<\/p>\n<p>                    [1, 2, 1]])<\/p>\n<h2><strong>\u5e94\u7528Sobel\u7b97\u5b50<\/strong><\/h2>\n<p>edges_x = convolve(image_array, sobel_x)<\/p>\n<p>edges_y = convolve(image_array, sobel_y)<\/p>\n<h2><strong>\u8ba1\u7b97\u8fb9\u7f18\u5f3a\u5ea6<\/strong><\/h2>\n<p>edges = np.sqrt(edges_x&lt;strong&gt;2 + edges_y&lt;\/strong&gt;2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5de5\u5177\u5e93\u6765\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef\u64cd\u4f5c\u3002\u901a\u8fc7NumPy\u3001OpenCV\u548cScipy\u7b49\u5e93\uff0c\u53ef\u4ee5\u7075\u6d3b\u5730\u8fdb\u884c\u5377\u79ef\u64cd\u4f5c\uff0c\u6ee1\u8db3\u56fe\u50cf\u5904\u7406\u7684\u5404\u79cd\u9700\u6c42\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u548c\u65b9\u6cd5\uff0c\u5c06\u6709\u52a9\u4e8e\u63d0\u9ad8\u56fe\u50cf\u5904\u7406\u7684\u6548\u7387\u548c\u6548\u679c\u3002\u4e86\u89e3\u5377\u79ef\u7684\u57fa\u672c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5\uff0c\u5bf9\u4e8e\u638c\u63e1\u56fe\u50cf\u5904\u7406\u6280\u672f\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u4ec0\u4e48\u662f\u56fe\u50cf\u5377\u79ef\uff0c\u4e3a\u4ec0\u4e48\u5728\u56fe\u50cf\u5904\u7406\u4e2d\u91cd\u8981\uff1f<\/strong><br \/>\u56fe\u50cf\u5377\u79ef\u662f\u4e00\u79cd\u6570\u5b66\u8fd0\u7b97\uff0c\u901a\u8fc7\u5c06\u4e00\u4e2a\u5377\u79ef\u6838\uff08\u6216\u6ee4\u6ce2\u5668\uff09\u5e94\u7528\u4e8e\u56fe\u50cf\uff0c\u6765\u589e\u5f3a\u6216\u63d0\u53d6\u7279\u5b9a\u7279\u5f81\u3002\u8fd9\u79cd\u6280\u672f\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8fb9\u7f18\u68c0\u6d4b\u3001\u6a21\u7cca\u5904\u7406\u548c\u56fe\u50cf\u9510\u5316\u7b49\u4efb\u52a1\u3002\u5377\u79ef\u64cd\u4f5c\u80fd\u591f\u6709\u6548\u5730\u63d0\u53d6\u56fe\u50cf\u4e2d\u7684\u6a21\u5f0f\u548c\u7eb9\u7406\uff0c\u4ece\u800c\u4e3a\u540e\u7eed\u7684\u56fe\u50cf\u5206\u6790\u548c\u5904\u7406\u63d0\u4f9b\u91cd\u8981\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef\u9700\u8981\u54ea\u4e9b\u5e93\uff1f<\/strong><br \/>\u5b9e\u73b0\u56fe\u50cf\u5377\u79ef\u901a\u5e38\u4f7f\u7528NumPy\u548cOpenCV\u5e93\u3002NumPy\u63d0\u4f9b\u4e86\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u800cOpenCV\u5219\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u5de5\u5177\u3002\u901a\u8fc7\u8fd9\u4e24\u4e2a\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u56fe\u50cf\u7684\u8bfb\u53d6\u3001\u5904\u7406\u548c\u663e\u793a\u3002\u6b64\u5916\uff0cSciPy\u5e93\u4e2d\u7684\u4fe1\u53f7\u5904\u7406\u6a21\u5757\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6267\u884c\u5377\u79ef\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u5377\u79ef\u6838\uff1f<\/strong><br \/>\u5377\u79ef\u6838\u7684\u9009\u62e9\u53d6\u51b3\u4e8e\u76ee\u6807\u4efb\u52a1\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u8fb9\u7f18\u68c0\u6d4b\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9Sobel\u6216Laplacian\u6838\uff1b\u800c\u6a21\u7cca\u5904\u7406\u5219\u53ef\u4ee5\u4f7f\u7528\u5747\u503c\u6216\u9ad8\u65af\u6838\u3002\u4e86\u89e3\u5377\u79ef\u6838\u7684\u6027\u8d28\u548c\u5e94\u7528\u573a\u666f\u5bf9\u4e8e\u83b7\u5f97\u7406\u60f3\u7684\u5904\u7406\u6548\u679c\u81f3\u5173\u91cd\u8981\u3002\u8bbe\u8ba1\u81ea\u5b9a\u4e49\u5377\u79ef\u6838\u65f6\uff0c\u9700\u8981\u8003\u8651\u6ee4\u6ce2\u7684\u5f3a\u5ea6\u548c\u65b9\u5411\u6027\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u6ee1\u8db3\u7279\u5b9a\u7684\u56fe\u50cf\u5904\u7406\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u56fe\u50cf\u5377\u79ef\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u5e93\u5b9e\u73b0\uff0c\u5305\u62ecOpenCV\u3001NumPy\u548cScipy\u7b49\u3002\u9996\u5148\uff0c\u4e86\u89e3\u5377\u79ef\u7684\u57fa\u672c\u6982\u5ff5\u662f [&hellip;]","protected":false},"author":3,"featured_media":971467,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/971456"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=971456"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/971456\/revisions"}],"predecessor-version":[{"id":971469,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/971456\/revisions\/971469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/971467"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=971456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=971456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=971456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}