{"id":1159432,"date":"2025-01-13T18:52:45","date_gmt":"2025-01-13T10:52:45","guid":{"rendered":""},"modified":"2025-01-13T18:52:48","modified_gmt":"2025-01-13T10:52:48","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e6%98%be%e7%a4%ba%e7%81%b0%e5%ba%a6%e5%9b%be%e5%83%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1159432.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u663e\u793a\u7070\u5ea6\u56fe\u50cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25201139\/6bc5ec54-be40-4c09-a2df-ad6b2f2346e8.webp\" alt=\"python\u4e2d\u5982\u4f55\u663e\u793a\u7070\u5ea6\u56fe\u50cf\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Matplotlib\u3001OpenCV\u3001Pillow\u7b49\u5e93<\/strong>\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528Matplotlib\u548cOpenCV\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4f7f\u7528Matplotlib\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528Matplotlib\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/h3>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684Python\u7ed8\u56fe\u5e93\uff0c\u4e3b\u8981\u7528\u4e8e\u521b\u5efa\u9759\u6001\u3001\u52a8\u753b\u548c\u4ea4\u4e92\u5f0f\u7684\u53ef\u89c6\u5316\u56fe\u8868\u3002\u5b83\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u3002\u4f7f\u7528Matplotlib\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Matplotlib\u5e93<\/strong>\uff1a\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5Matplotlib\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong>\uff1a\u4f7f\u7528Matplotlib\u52a0\u8f7d\u56fe\u50cf\uff0c\u53ef\u4ee5\u4f7f\u7528<code>matplotlib.pyplot.imread<\/code>\u51fd\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u8bfb\u53d6\u56fe\u50cf\u5e76\u5c06\u5176\u8f6c\u6362\u4e3aNumPy\u6570\u7ec4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u56fe\u50cf<\/strong>\uff1a\u4f7f\u7528<code>matplotlib.pyplot.imshow<\/code>\u51fd\u6570\u663e\u793a\u56fe\u50cf\uff0c\u5e76\u8bbe\u7f6e\u989c\u8272\u6620\u5c04\u4e3a\u7070\u5ea6\u56fe\u50cf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import matplotlib.image as mpimg<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>img = mpimg.imread(&#39;path_to_your_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>plt.imshow(img, cmap=&#39;gray&#39;)<\/p>\n<p>plt.axis(&#39;off&#39;)  # \u5173\u95ed\u5750\u6807\u8f74<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528OpenCV\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/h3>\n<\/p>\n<p><p>OpenCV\u662f\u4e00\u4e2a\u5f00\u6e90\u8ba1\u7b97\u673a\u89c6\u89c9\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u8f6f\u4ef6\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\u3002\u4f7f\u7528OpenCV\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5OpenCV\u5e93<\/strong>\uff1a\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5OpenCV\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\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<\/strong>\uff1a\u4f7f\u7528OpenCV\u7684<code>cv2.imread<\/code>\u51fd\u6570\u52a0\u8f7d\u56fe\u50cf\uff0c\u5e76\u6307\u5b9a\u52a0\u8f7d\u6a21\u5f0f\u4e3a\u7070\u5ea6\u56fe\u50cf\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u56fe\u50cf<\/strong>\uff1a\u4f7f\u7528<code>cv2.imshow<\/code>\u51fd\u6570\u663e\u793a\u56fe\u50cf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>img = cv2.imread(&#39;path_to_your_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>cv2.imshow(&#39;Gray Image&#39;, img)<\/p>\n<p>cv2.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>tKey(0)  # \u7b49\u5f85\u6309\u952e<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Pillow\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/h3>\n<\/p>\n<p><p>Pillow\u662fPython Imaging Library (PIL) \u7684\u4e00\u4e2a\u5206\u652f\uff0c\u589e\u52a0\u4e86\u4e00\u4e9b\u65b0\u7279\u6027\u548c\u6539\u8fdb\u3002\u4f7f\u7528Pillow\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Pillow\u5e93<\/strong>\uff1a\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5Pillow\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pillow<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong>\uff1a\u4f7f\u7528Pillow\u7684<code>Image.open<\/code>\u51fd\u6570\u52a0\u8f7d\u56fe\u50cf\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u56fe\u50cf<\/strong>\uff1a\u4f7f\u7528<code>Image.show<\/code>\u51fd\u6570\u663e\u793a\u56fe\u50cf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>img = Image.open(&#39;path_to_your_image.jpg&#39;)<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>gray_img = img.convert(&#39;L&#39;)<\/p>\n<h2><strong>\u663e\u793a\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>gray_img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5904\u7406\u7070\u5ea6\u56fe\u50cf\u7684\u5176\u4ed6\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5904\u7406\u7070\u5ea6\u56fe\u50cf\u4e0d\u4ec5\u4ec5\u662f\u663e\u793a\uff0c\u8fd8\u5305\u62ec\u56fe\u50cf\u7684\u5904\u7406\u3001\u5206\u6790\u548c\u53d8\u6362\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u7070\u5ea6\u56fe\u50cf\u5904\u7406\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u8c03\u6574\u56fe\u50cf\u5927\u5c0f<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>img = cv2.imread(&#39;path_to_your_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u8c03\u6574\u56fe\u50cf\u5927\u5c0f<\/strong><\/h2>\n<p>resized_img = cv2.resize(img, (100, 100))<\/p>\n<h2><strong>\u663e\u793a\u8c03\u6574\u540e\u7684\u56fe\u50cf<\/strong><\/h2>\n<p>cv2.imshow(&#39;Resized Image&#39;, resized_img)<\/p>\n<p>cv2.waitKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u56fe\u50cf\u9608\u503c\u5904\u7406<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>img = cv2.imread(&#39;path_to_your_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u5e94\u7528\u4e8c\u503c\u5316\u9608\u503c<\/strong><\/h2>\n<p>_, binary_img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)<\/p>\n<h2><strong>\u663e\u793a\u4e8c\u503c\u5316\u540e\u7684\u56fe\u50cf<\/strong><\/h2>\n<p>cv2.imshow(&#39;Binary Image&#39;, binary_img)<\/p>\n<p>cv2.waitKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u56fe\u50cf\u6ee4\u6ce2<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>img = cv2.imread(&#39;path_to_your_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u5e94\u7528\u9ad8\u65af\u6ee4\u6ce2<\/strong><\/h2>\n<p>blurred_img = cv2.GaussianBlur(img, (5, 5), 0)<\/p>\n<h2><strong>\u663e\u793a\u6ee4\u6ce2\u540e\u7684\u56fe\u50cf<\/strong><\/h2>\n<p>cv2.imshow(&#39;Blurred Image&#39;, blurred_img)<\/p>\n<p>cv2.waitKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u8fb9\u7f18\u68c0\u6d4b<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>img = cv2.imread(&#39;path_to_your_image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u5e94\u7528Canny\u8fb9\u7f18\u68c0\u6d4b<\/strong><\/h2>\n<p>edges = cv2.Canny(img, 100, 200)<\/p>\n<h2><strong>\u663e\u793a\u8fb9\u7f18\u68c0\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>cv2.imshow(&#39;Edges&#39;, edges)<\/p>\n<p>cv2.waitKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u7070\u5ea6\u56fe\u50cf\u7684\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u7070\u5ea6\u56fe\u50cf\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u56fe\u50cf\u5904\u7406\u9886\u57df\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u56fe\u50cf\u5206\u5272<\/strong>\uff1a\u7070\u5ea6\u56fe\u50cf\u5728\u56fe\u50cf\u5206\u5272\u4e2d\u5e38\u88ab\u4f7f\u7528\uff0c\u56e0\u4e3a\u5b83\u4eec\u7b80\u5316\u4e86\u8ba1\u7b97\u8fc7\u7a0b\u3002\u56fe\u50cf\u5206\u5272\u662f\u5c06\u56fe\u50cf\u5206\u5272\u6210\u591a\u4e2a\u533a\u57df\u7684\u8fc7\u7a0b\uff0c\u6bcf\u4e2a\u533a\u57df\u901a\u5e38\u4ee3\u8868\u4e0d\u540c\u7684\u5bf9\u8c61\u6216\u90e8\u5206\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7279\u5f81\u63d0\u53d6<\/strong>\uff1a\u5728\u673a\u5668\u5b66\u4e60\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\uff0c\u7279\u5f81\u63d0\u53d6\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6b65\u9aa4\u3002\u7070\u5ea6\u56fe\u50cf\u53ef\u4ee5\u7528\u6765\u63d0\u53d6\u56fe\u50cf\u7684\u5173\u952e\u7279\u5f81\uff0c\u5982\u8fb9\u7f18\u3001\u89d2\u70b9\u548c\u7eb9\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u56fe\u50cf\u589e\u5f3a<\/strong>\uff1a\u7070\u5ea6\u56fe\u50cf\u53ef\u4ee5\u8fdb\u884c\u56fe\u50cf\u589e\u5f3a\u5904\u7406\uff0c\u5982\u76f4\u65b9\u56fe\u5747\u8861\u5316\u3001\u5bf9\u6bd4\u5ea6\u8c03\u6574\u548c\u53bb\u566a\u3002\u8fd9\u4e9b\u5904\u7406\u6709\u52a9\u4e8e\u63d0\u9ad8\u56fe\u50cf\u8d28\u91cf\uff0c\u4f7f\u5f97\u540e\u7eed\u7684\u56fe\u50cf\u5206\u6790\u66f4\u52a0\u51c6\u786e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6a21\u5f0f\u8bc6\u522b<\/strong>\uff1a\u5728\u6a21\u5f0f\u8bc6\u522b\u4e2d\uff0c\u7070\u5ea6\u56fe\u50cf\u5e38\u7528\u4e8e\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6a21\u578b\u3002\u7070\u5ea6\u56fe\u50cf\u7b80\u5316\u4e86\u6570\u636e\u7ed3\u6784\uff0c\u51cf\u5c11\u4e86\u8ba1\u7b97\u590d\u6742\u5ea6\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u6a21\u578b\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u533b\u5b66\u56fe\u50cf\u5904\u7406<\/strong>\uff1a\u5728\u533b\u5b66\u9886\u57df\uff0c\u7070\u5ea6\u56fe\u50cf\u5e7f\u6cdb\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u533b\u5b66\u56fe\u50cf\uff0c\u5982X\u5149\u7247\u3001CT\u626b\u63cf\u548cMRI\u56fe\u50cf\u3002\u8fd9\u4e9b\u56fe\u50cf\u7684\u5904\u7406\u6709\u52a9\u4e8e\u533b\u751f\u8bca\u65ad\u75be\u75c5\u548c\u89c4\u5212\u6cbb\u7597\u65b9\u6848\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u7528\u7684\u5e93\u5305\u62ecMatplotlib\u3001OpenCV\u548cPillow\u3002\u4f7f\u7528\u8fd9\u4e9b\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u52a0\u8f7d\u3001\u663e\u793a\u548c\u5904\u7406\u7070\u5ea6\u56fe\u50cf\u3002\u901a\u8fc7\u5bf9\u7070\u5ea6\u56fe\u50cf\u8fdb\u884c\u5904\u7406\uff0c\u53ef\u4ee5\u5b9e\u73b0\u56fe\u50cf\u5206\u5272\u3001\u7279\u5f81\u63d0\u53d6\u3001\u56fe\u50cf\u589e\u5f3a\u548c\u6a21\u5f0f\u8bc6\u522b\u7b49\u5e94\u7528\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9009\u62e9\u5408\u9002\u7684\u5e93\u548c\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8\u56fe\u50cf\u5904\u7406\u7684\u6548\u7387\u548c\u6548\u679c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u7070\u5ea6\u56fe\u50cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>OpenCV<\/code>\u6216<code>PIL<\/code>\u5e93\u8bfb\u53d6\u7070\u5ea6\u56fe\u50cf\u3002\u4f7f\u7528<code>OpenCV<\/code>\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>cv2.imread(&#39;image_path&#39;, cv2.IMREAD_GRAYSCALE)<\/code>\u6765\u8bfb\u53d6\u56fe\u50cf\uff0c\u800c\u4f7f\u7528<code>PIL<\/code>\u5219\u53ef\u4ee5\u4f7f\u7528<code>Image.open(&#39;image_path&#39;).convert(&#39;L&#39;)<\/code>\u3002\u8fd9\u4e24\u79cd\u65b9\u6cd5\u90fd\u80fd\u6709\u6548\u5730\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6\u683c\u5f0f\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Matplotlib\u663e\u793a\u7070\u5ea6\u56fe\u50cf\uff1f<\/strong><br \/><code>Matplotlib<\/code>\u5e93\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u3002\u53ef\u4ee5\u4f7f\u7528<code>plt.imshow(image, cmap=&#39;gray&#39;)<\/code>\u6765\u663e\u793a\u56fe\u50cf\uff0c\u5176\u4e2d<code>image<\/code>\u662f\u8bfb\u53d6\u7684\u7070\u5ea6\u56fe\u50cf\u6570\u7ec4\uff0c<code>cmap=&#39;gray&#39;<\/code>\u53c2\u6570\u786e\u4fdd\u56fe\u50cf\u4ee5\u7070\u5ea6\u5f62\u5f0f\u663e\u793a\u3002\u8c03\u7528<code>plt.show()<\/code>\u540e\uff0c\u56fe\u50cf\u4f1a\u5728\u4e00\u4e2a\u65b0\u7684\u7a97\u53e3\u4e2d\u5c55\u793a\u3002<\/p>\n<p><strong>\u5982\u4f55\u8c03\u6574\u7070\u5ea6\u56fe\u50cf\u7684\u5bf9\u6bd4\u5ea6\u548c\u4eae\u5ea6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7<code>OpenCV<\/code>\u5e93\u6765\u8c03\u6574\u7070\u5ea6\u56fe\u50cf\u7684\u5bf9\u6bd4\u5ea6\u548c\u4eae\u5ea6\u3002\u4f7f\u7528<code>cv2.convertScaleAbs(image, alpha=contrast_factor, beta=brightness_offset)<\/code>\u65b9\u6cd5\uff0c<code>contrast_factor<\/code>\u63a7\u5236\u5bf9\u6bd4\u5ea6\uff0c<code>brightness_offset<\/code>\u63a7\u5236\u4eae\u5ea6\u3002\u901a\u8fc7\u8c03\u6574\u8fd9\u4e24\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u56fe\u50cf\u6548\u679c\u7684\u81ea\u5b9a\u4e49\u4fee\u6539\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u663e\u793a\u7070\u5ea6\u56fe\u50cf\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Matplotlib\u3001OpenCV\u3001Pillow\u7b49\u5e93\uff0c\u5176\u4e2d\u6700\u5e38\u7528 [&hellip;]","protected":false},"author":3,"featured_media":1159436,"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\/1159432"}],"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=1159432"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1159432\/revisions"}],"predecessor-version":[{"id":1159441,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1159432\/revisions\/1159441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1159436"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1159432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1159432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1159432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}