{"id":1185696,"date":"2025-01-15T19:43:53","date_gmt":"2025-01-15T11:43:53","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1185696.html"},"modified":"2025-01-15T19:43:55","modified_gmt":"2025-01-15T11:43:55","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%88%b6%e4%bd%9c%e7%94%bb%e5%83%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1185696.html","title":{"rendered":"\u5982\u4f55\u7528python\u5236\u4f5c\u753b\u50cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25134727\/e5882756-b649-4909-b8e3-670770794839.webp\" alt=\"\u5982\u4f55\u7528python\u5236\u4f5c\u753b\u50cf\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u7528Python\u5236\u4f5c\u753b\u50cf\uff1f<\/strong><br \/>\u4f7f\u7528Python\u5236\u4f5c\u753b\u50cf\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5176\u4e2d\u4e00\u4e9b\u4e3b\u8981\u5de5\u5177\u548c\u5e93\u5305\u62ec<strong>Pillow\u3001Matplotlib\u3001OpenCV\u3001Turtle<\/strong>\u7b49\u3002\u6bcf\u79cd\u5de5\u5177\u5404\u6709\u5176\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\u3002\u4f8b\u5982\uff0c<strong>Pillow<\/strong>\u9002\u5408\u5904\u7406\u548c\u751f\u6210\u56fe\u7247\uff0c<strong>Matplotlib<\/strong>\u9002\u5408\u521b\u5efa\u6570\u636e\u53ef\u89c6\u5316\u56fe\u8868\uff0c<strong>OpenCV<\/strong>\u5e7f\u6cdb\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\uff0c<strong>Turtle<\/strong>\u5219\u9002\u5408\u7ed8\u5236\u7b80\u5355\u7684\u56fe\u5f62\u548c\u56fe\u6848\u3002<strong>\u5728\u6b64\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Pillow\u5e93\u6765\u5236\u4f5c\u753b\u50cf<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5\u548c\u5bfc\u5165Pillow\u5e93<\/h3>\n<\/p>\n<p><p>Pillow\u5e93\u662fPython\u56fe\u50cf\u5904\u7406\u7684\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5Pillow\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install pillow<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5728\u4f60\u7684Python\u811a\u672c\u4e2d\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image, ImageDraw, ImageFont<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u50cf<\/h3>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u50cf\u5bf9\u8c61\uff0c\u4f60\u53ef\u4ee5\u6307\u5b9a\u56fe\u50cf\u7684\u6a21\u5f0f\u548c\u5c3a\u5bf8\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2aRGB\u6a21\u5f0f\u7684\u767d\u8272\u56fe\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">image = Image.new(&#39;RGB&#39;, (800, 600), color = &#39;white&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u7ed8\u5236\u56fe\u5f62<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528ImageDraw\u6a21\u5757\u4e2d\u7684Draw\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u7ed8\u56fe\u5bf9\u8c61\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u7ed8\u56fe\u5bf9\u8c61\u6765\u7ed8\u5236\u5404\u79cd\u5f62\u72b6\u548c\u56fe\u6848\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">draw = ImageDraw.Draw(image)<\/p>\n<h2><strong>\u753b\u4e00\u4e2a\u77e9\u5f62<\/strong><\/h2>\n<p>draw.rectangle([(50, 50), (200, 200)], outline=&quot;black&quot;, fill=&quot;blue&quot;)<\/p>\n<h2><strong>\u753b\u4e00\u4e2a\u5706<\/strong><\/h2>\n<p>draw.ellipse([(300, 50), (450, 200)], outline=&quot;black&quot;, fill=&quot;red&quot;)<\/p>\n<h2><strong>\u753b\u4e00\u6761\u7ebf<\/strong><\/h2>\n<p>draw.line([(50, 300), (750, 300)], fill=&quot;black&quot;, width=5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u6dfb\u52a0\u6587\u672c<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528ImageFont\u6a21\u5757\u6765\u52a0\u8f7d\u5b57\u4f53\uff0c\u5e76\u4f7f\u7528draw.text\u65b9\u6cd5\u6765\u6dfb\u52a0\u6587\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">font = ImageFont.truetype(&quot;arial.ttf&quot;, 40)<\/p>\n<p>draw.text((50, 400), &quot;Hello, World!&quot;, fill=&quot;black&quot;, font=font)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u4fdd\u5b58\u56fe\u50cf<\/h3>\n<\/p>\n<p><p>\u5b8c\u6210\u6240\u6709\u7ed8\u5236\u64cd\u4f5c\u540e\uff0c\u4f60\u53ef\u4ee5\u5c06\u56fe\u50cf\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">image.save(&#39;output.png&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u66f4\u591aPillow\u529f\u80fd<\/h3>\n<\/p>\n<p><p>Pillow\u5e93\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5176\u4ed6\u529f\u80fd\uff0c\u4f8b\u5982\u56fe\u50cf\u7684\u7f29\u653e\u3001\u65cb\u8f6c\u3001\u6ee4\u955c\u6548\u679c\u7b49\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4f7f\u7528\u8fd9\u4e9b\u529f\u80fd\u6765\u8fdb\u4e00\u6b65\u5904\u7406\u548c\u7f8e\u5316\u4f60\u7684\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><h4>\u56fe\u50cf\u7f29\u653e\u548c\u65cb\u8f6c<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528resize\u548crotate\u65b9\u6cd5\u6765\u8c03\u6574\u56fe\u50cf\u7684\u5927\u5c0f\u548c\u65b9\u5411\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">resized_image = image.resize((400, 300))<\/p>\n<p>rotated_image = image.rotate(45)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5e94\u7528\u6ee4\u955c<\/h4>\n<\/p>\n<p><p>Pillow\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u6ee4\u955c\u6548\u679c\uff0c\u4f8b\u5982\u6a21\u7cca\u3001\u9510\u5316\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import ImageFilter<\/p>\n<p>blurred_image = image.filter(ImageFilter.BLUR)<\/p>\n<p>sharpened_image = image.filter(ImageFilter.SHARPEN)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528Matplotlib\u5236\u4f5c\u6570\u636e\u53ef\u89c6\u5316\u56fe\u8868<\/h3>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u6570\u636e\u53ef\u89c6\u5316\u56fe\u8868\u7684\u5f3a\u5927\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u751f\u6210\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u8868\uff0c\u5305\u62ec\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u997c\u56fe\u7b49\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5\u548c\u5bfc\u5165Matplotlib<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5Matplotlib\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5728\u4f60\u7684Python\u811a\u672c\u4e2d\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u521b\u5efa\u6298\u7ebf\u56fe<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528plot\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6298\u7ebf\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 3, 5, 7, 11]<\/p>\n<p>plt.plot(x, y)<\/p>\n<p>plt.xlabel(&#39;X-axis&#39;)<\/p>\n<p>plt.ylabel(&#39;Y-axis&#39;)<\/p>\n<p>plt.title(&#39;Simple Line Plot&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u521b\u5efa\u67f1\u72b6\u56fe<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528bar\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u67f1\u72b6\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">categories = [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;]<\/p>\n<p>values = [4, 7, 1, 8]<\/p>\n<p>plt.bar(categories, values)<\/p>\n<p>plt.xlabel(&#39;Categories&#39;)<\/p>\n<p>plt.ylabel(&#39;Values&#39;)<\/p>\n<p>plt.title(&#39;Simple Bar Chart&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u521b\u5efa\u997c\u56fe<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528pie\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u997c\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">labels = [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;]<\/p>\n<p>sizes = [15, 30, 45, 10]<\/p>\n<p>colors = [&#39;gold&#39;, &#39;yellowgreen&#39;, &#39;lightcoral&#39;, &#39;lightskyblue&#39;]<\/p>\n<p>explode = (0.1, 0, 0, 0)<\/p>\n<p>plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct=&#39;%1.1f%%&#39;, shadow=True, startangle=140)<\/p>\n<p>plt.axis(&#39;equal&#39;)<\/p>\n<p>plt.title(&#39;Simple Pie Chart&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528OpenCV\u8fdb\u884c\u9ad8\u7ea7\u56fe\u50cf\u5904\u7406<\/h3>\n<\/p>\n<p><p>OpenCV\u662f\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93\uff0c\u5e7f\u6cdb\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u3001\u89c6\u9891\u5206\u6790\u7b49\u9886\u57df\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5\u548c\u5bfc\u5165OpenCV<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5OpenCV\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install opencv-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5728\u4f60\u7684Python\u811a\u672c\u4e2d\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8bfb\u53d6\u548c\u663e\u793a\u56fe\u50cf<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528imread\u548cimshow\u65b9\u6cd5\u6765\u8bfb\u53d6\u548c\u663e\u793a\u56fe\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">image = cv2.imread(&#39;input.jpg&#39;)<\/p>\n<p>cv2.imshow(&#39;Image&#39;, image)<\/p>\n<p>cv2.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>tKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u56fe\u50cf\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528cvtColor\u65b9\u6cd5\u6765\u8fdb\u884c\u56fe\u50cf\u7684\u989c\u8272\u7a7a\u95f4\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u56fe\u50cf\u5e73\u6ed1<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528GaussianBlur\u65b9\u6cd5\u6765\u8fdb\u884c\u56fe\u50cf\u5e73\u6ed1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">blurred_image = cv2.GaussianBlur(image, (5, 5), 0)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528Turtle\u7ed8\u5236\u7b80\u5355\u56fe\u5f62<\/h3>\n<\/p>\n<p><p>Turtle\u662fPython\u5185\u7f6e\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u9002\u5408\u7528\u4e8e\u7ed8\u5236\u7b80\u5355\u7684\u56fe\u5f62\u548c\u56fe\u6848\u3002<\/p>\n<\/p>\n<p><h4>\u5bfc\u5165Turtle\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u5728\u4f60\u7684Python\u811a\u672c\u4e2d\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u7ed8\u5236\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528Turtle\u6a21\u5757\u4e2d\u7684\u65b9\u6cd5\u6765\u7ed8\u5236\u5404\u79cd\u5f62\u72b6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">turtle.speed(1)<\/p>\n<p>turtle.forward(100)<\/p>\n<p>turtle.right(90)<\/p>\n<p>turtle.forward(100)<\/p>\n<p>turtle.right(90)<\/p>\n<p>turtle.forward(100)<\/p>\n<p>turtle.right(90)<\/p>\n<p>turtle.forward(100)<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u7efc\u5408\u6848\u4f8b\uff1a\u4f7f\u7528Pillow\u548cOpenCV\u5236\u4f5c\u590d\u6742\u753b\u50cf<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7ed3\u5408\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u548c\u5e93\u6765\u5236\u4f5c\u590d\u6742\u7684\u753b\u50cf\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Pillow\u751f\u6210\u57fa\u672c\u56fe\u50cf\uff0c\u7136\u540e\u4f7f\u7528OpenCV\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u5904\u7406\u548c\u7f8e\u5316\u3002<\/p>\n<\/p>\n<p><h4>\u521b\u5efa\u57fa\u672c\u56fe\u50cf<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f7f\u7528Pillow\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684\u56fe\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image, ImageDraw, ImageFont<\/p>\n<p>image = Image.new(&#39;RGB&#39;, (800, 600), color = &#39;white&#39;)<\/p>\n<p>draw = ImageDraw.Draw(image)<\/p>\n<p>draw.rectangle([(50, 50), (200, 200)], outline=&quot;black&quot;, fill=&quot;blue&quot;)<\/p>\n<p>draw.ellipse([(300, 50), (450, 200)], outline=&quot;black&quot;, fill=&quot;red&quot;)<\/p>\n<p>draw.line([(50, 300), (750, 300)], fill=&quot;black&quot;, width=5)<\/p>\n<p>font = ImageFont.truetype(&quot;arial.ttf&quot;, 40)<\/p>\n<p>draw.text((50, 400), &quot;Hello, World!&quot;, fill=&quot;black&quot;, font=font)<\/p>\n<p>image.save(&#39;basic_image.png&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8fdb\u4e00\u6b65\u5904\u7406\u56fe\u50cf<\/h4>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528OpenCV\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u5904\u7406\uff0c\u4f8b\u5982\u6dfb\u52a0\u6ee4\u955c\u6548\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<p>image = cv2.imread(&#39;basic_image.png&#39;)<\/p>\n<p>blurred_image = cv2.GaussianBlur(image, (15, 15), 0)<\/p>\n<p>cv2.imwrite(&#39;final_image.png&#39;, blurred_image)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5e93\u548c\u5de5\u5177\u6765\u5236\u4f5c\u753b\u50cf\uff0c\u4ece\u7b80\u5355\u7684\u5f62\u72b6\u7ed8\u5236\u5230\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\uff0c\u5e94\u6709\u5c3d\u6709\u3002<strong>Pillow<\/strong>\u5e93\u9002\u5408\u5904\u7406\u548c\u751f\u6210\u56fe\u7247\uff0c<strong>Matplotlib<\/strong>\u5e93\u9002\u5408\u6570\u636e\u53ef\u89c6\u5316\uff0c<strong>OpenCV<\/strong>\u5e93\u7528\u4e8e\u9ad8\u7ea7\u56fe\u50cf\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\uff0c<strong>Turtle<\/strong>\u6a21\u5757\u9002\u5408\u7ed8\u5236\u7b80\u5355\u7684\u56fe\u5f62\u548c\u56fe\u6848\u3002\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u5236\u4f5c\u51fa\u5404\u79cd\u5404\u6837\u7684\u753b\u50cf\uff0c\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Python\u5e93\u6765\u5236\u4f5c\u753b\u50cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u591a\u4e2a\u5e93\u53ef\u4ee5\u7528\u4e8e\u5236\u4f5c\u753b\u50cf\uff0c\u5176\u4e2d\u5e38\u7528\u7684\u5305\u62ecPIL\uff08Pillow\uff09\u3001OpenCV\u548cMatplotlib\u3002Pillow\u9002\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u548c\u7b80\u5355\u7684\u56fe\u50cf\u751f\u6210\uff0cOpenCV\u5219\u66f4\u52a0\u5f3a\u5927\uff0c\u9002\u5408\u8fdb\u884c\u590d\u6742\u7684\u56fe\u50cf\u64cd\u4f5c\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\uff0cMatplotlib\u5219\u53ef\u4ee5\u7528\u4e8e\u7ed8\u5236\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u5f62\u548c\u6570\u636e\u53ef\u89c6\u5316\u3002\u6839\u636e\u4f60\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u5c06\u5e2e\u52a9\u4f60\u66f4\u52a0\u9ad8\u6548\u5730\u5b8c\u6210\u9879\u76ee\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5236\u4f5c\u753b\u50cf\u9700\u8981\u54ea\u4e9b\u57fa\u672c\u6b65\u9aa4\uff1f<\/strong><br \/>\u5236\u4f5c\u753b\u50cf\u7684\u57fa\u672c\u6b65\u9aa4\u901a\u5e38\u5305\u62ec\uff1a\u9009\u62e9\u56fe\u50cf\u5e93\uff0c\u52a0\u8f7d\u6216\u521b\u5efa\u56fe\u50cf\uff0c\u5e94\u7528\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff08\u5982\u8c03\u6574\u5927\u5c0f\u3001\u8fc7\u6ee4\u3001\u7ed8\u5236\u7b49\uff09\uff0c\u6700\u540e\u4fdd\u5b58\u6216\u663e\u793a\u56fe\u50cf\u3002\u5177\u4f53\u6d41\u7a0b\u53ef\u80fd\u56e0\u6240\u4f7f\u7528\u7684\u5e93\u800c\u5f02\uff0c\u4f46\u6574\u4f53\u4e0a\uff0c\u8fd9\u4e9b\u6b65\u9aa4\u662f\u76f8\u4f3c\u7684\u3002\u786e\u4fdd\u5728\u5f00\u59cb\u4e4b\u524d\u719f\u6089\u6240\u9009\u5e93\u7684\u57fa\u672c\u529f\u80fd\u548cAPI\u6587\u6863\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u56fe\u50cf\u7684\u989c\u8272\u548c\u6ee4\u955c\u6548\u679c\uff1f<\/strong><br \/>\u4f7f\u7528Pillow\u5e93\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u8c03\u6574\u56fe\u50cf\u7684\u989c\u8272\u548c\u5e94\u7528\u6ee4\u955c\u6548\u679c\u3002\u53ef\u4ee5\u4f7f\u7528<code>ImageEnhance<\/code>\u6a21\u5757\u6765\u8c03\u6574\u4eae\u5ea6\u3001\u5bf9\u6bd4\u5ea6\u548c\u9971\u548c\u5ea6\u3002\u5bf9\u4e8e\u6ee4\u955c\u6548\u679c\uff0cPillow\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u7684\u6ee4\u955c\uff0c\u5982\u6a21\u7cca\u548c\u9510\u5316\u3002OpenCV\u540c\u6837\u652f\u6301\u4e30\u5bcc\u7684\u989c\u8272\u8f6c\u6362\u548c\u56fe\u50cf\u6ee4\u955c\u529f\u80fd\uff0c\u4f7f\u4f60\u80fd\u591f\u5b9e\u73b0\u66f4\u591a\u6837\u7684\u89c6\u89c9\u6548\u679c\u3002\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u4f60\u7684\u753b\u50cf\u66f4\u52a0\u751f\u52a8\u548c\u5438\u5f15\u4eba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u7528Python\u5236\u4f5c\u753b\u50cf\uff1f\u4f7f\u7528Python\u5236\u4f5c\u753b\u50cf\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5176\u4e2d\u4e00\u4e9b\u4e3b\u8981\u5de5\u5177\u548c\u5e93\u5305\u62ecPillow\u3001Ma [&hellip;]","protected":false},"author":3,"featured_media":1185703,"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\/1185696"}],"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=1185696"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1185696\/revisions"}],"predecessor-version":[{"id":1185709,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1185696\/revisions\/1185709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1185703"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1185696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1185696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1185696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}