{"id":52794,"date":"2025-08-11T19:34:48","date_gmt":"2025-08-11T11:34:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52794.html"},"modified":"2025-08-11T19:34:48","modified_gmt":"2025-08-11T11:34:48","slug":"%e6%9c%ba%e5%99%a8%e8%a7%86%e8%a7%89%ef%bc%9a%e7%ac%ac%e4%b8%89%e8%ae%b2-%e5%9b%be%e7%89%87%e8%89%b2%e5%bd%a9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52794.html","title":{"rendered":"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69"},"content":{"rendered":"<h2>\u673a\u5668\u89c6\u89c9&#xff1a;\u7b2c\u4e09\u8bb2\u2013OpenCV\u56fe\u50cf\u8272\u5f69\u57fa\u7840<\/h2>\n<p>\u7b2c\u4e00\u8bb2 \u5f00\u53d1\u73af\u5883\u642d\u5efa \u7b2c\u4e8c\u8bb2 OpenCV\u57fa\u7840\u64cd\u4f5c \u7b2c\u4e09\u8bb2&#xff1a;\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u5feb\u901f\u53d1\u5c55\u4f7f\u56fe\u50cf\u5904\u7406\u6210\u4e3a\u6838\u5fc3\u6280\u80fd&#xff0c;\u672c\u6587\u5c31\u8272\u5f69\u7a7a\u95f4\u548cOpenCV\u5bf9\u4e8e\u5bf9\u4e8e\u989c\u8272\u7a7a\u95f4\u76f8\u5173\u64cd\u4f5c\u8fdb\u884c\u8bb2\u89e3&#xff0c;\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u5b66\u4e60\u6253\u4e0b\u575a\u5b9e\u57fa\u7840\u3002<\/p>\n<p>\u5982\u6709\u9519\u8bef,\u6073\u8bf7\u6307\u6559<\/p>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u673a\u5668\u89c6\u89c9&#xff1a;\u7b2c\u4e09\u8bb2&#8211;OpenCV\u56fe\u50cf\u8272\u5f69\u57fa\u7840<\/li>\n<li>\u524d\u8a00<\/li>\n<li>\u4e00\u3001\u8272\u5f69\u7a7a\u95f4<\/li>\n<li>\n<ul>\n<li>1.\u57fa\u672c\u6982\u5ff5<\/li>\n<li>2.\u8272\u5f69\u7a7a\u95f4\u7684\u5e94\u7528\u4e0e\u610f\u4e49\u200c<\/li>\n<li>3.\u989c\u8272\u7f16\u7801\u65b9\u6cd5<\/li>\n<li>4.HSL\u548cHSV\u7684\u5dee\u5f02\u70b9<\/li>\n<li>5.RGB\u8f6c\u5316\u5230HSV\u7684\u7b97\u6cd5<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001OpenCV\u4e2d\u5bf9\u8272\u5f69\u7a7a\u95f4\u5904\u7406<\/li>\n<li>\u603b\u7ed3<\/li>\n<\/ul>\n<hr \/>\n<h2>\u524d\u8a00<\/h2>\n<p>\u672c\u6587\u5c31\u4e3b\u8981\u5bf9\u8272\u5f69\u7a7a\u95f4\u4ee5\u53caOpenCV\u5bf9\u4e8e\u8272\u5f69\u7a7a\u95f4\u7b49\u5f85\u4e00\u4e9b\u5904\u7406\u8fdb\u884c\u8bb2\u89e3<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u8272\u5f69\u7a7a\u95f4<\/h2>\n<h3>1.\u57fa\u672c\u6982\u5ff5<\/h3>\n<p>\u8272\u5f69\u7a7a\u95f4\u53c8\u79f0\u200c\u8272\u57df\u200c&#xff0c;\u662f\u8272\u5f69\u5b66\u4e2d\u901a\u8fc7\u4e00\u7ef4\u81f3\u56db\u7ef4\u5750\u6807\u7cfb\u7edf\u5bf9\u989c\u8272\u8fdb\u884c\u91cf\u5316\u63cf\u8ff0\u7684\u6570\u5b66\u6a21\u578b\u3002\u5176\u672c\u8d28\u662f\u5c06\u4eba\u7c7b\u4e3b\u89c2\u611f\u77e5\u7684\u989c\u8272\u8f6c\u5316\u4e3a\u53ef\u8ba1\u7b97\u7684\u6570\u503c&#xff0c;\u4ece\u800c\u5728\u4e0d\u540c\u8bbe\u5907\u6216\u5a92\u4ecb\u4e2d\u5b9e\u73b0\u8272\u5f69\u7684\u6807\u51c6\u5316\u8868\u8fbe\u3002\u200c\u200c<\/p>\n<p>\u5e38\u89c1\u8272\u5f69\u7a7a\u95f4\u7c7b\u578b\u200c&#xff1a;RGB&#xff0c;\u200cHSV(HSB)&#xff0c;\u200cHSL&#xff0c;\u200cCMYK&#xff0c;\u200cLab<\/p>\n<p>1\u200c.RGB\u8272\u5f69\u7a7a\u95f4\u200c&#xff1a; \u57fa\u4e8e\u7ea2&#xff08;Red&#xff09;\u3001\u7eff&#xff08;Green&#xff09;\u3001\u84dd&#xff08;Blue&#xff09;\u4e09\u539f\u8272\u7684\u52a0\u8272\u6df7\u5408\u539f\u7406&#xff0c;\u4e3b\u8981\u7528\u4e8e\u663e\u793a\u8bbe\u5907&#xff08;\u5982\u663e\u793a\u5668\u3001\u6444\u50cf\u5934&#xff09;\u548c\u56fe\u50cf\u91c7\u96c6&#xff0c;\u53ef\u8868\u793a\u7ea61677\u4e07\u79cd\u989c\u8272\u3002\u200c\u200c \u7279\u70b9&#xff1a;\u76f4\u63a5\u9002\u914d\u7535\u5b50\u8bbe\u5907&#xff0c;\u4f46\u8272\u57df\u53d7\u786c\u4ef6\u9650\u5236\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113407-6899d52f6ca37.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>2.HSV(HSB) Hue&#xff1a;\u8272\u76f8&#xff0c;\u5373\u8272\u5f69&#xff0c;\u7528\u89d2\u5ea6\u5ea6\u91cf&#xff0c;\u53d6\u503c\u8303\u56f40\u00b0~360\u00b0&#xff0c;\u4ece\u7ea2\u8272\u5f00\u59cb\u6309\u9006\u65f6\u9488\u65b9\u5411\u8ba1\u7b97&#xff0c;\u7ea2\u8272\u4e3a0\u00b0&#xff0c;\u7eff\u8272\u4e3a120\u00b0&#xff0c;\u84dd\u8272\u4e3a240\u00b0 Saturation:\u9971\u548c\u5ea6&#xff0c;\u8868\u793a\u989c\u8272\u63a5\u8fd1\u5149\u8c31\u8272\u7684\u7a0b\u5ea6&#xff0c;\u53d6\u503c\u8303\u56f40%~100%\u3002\u4e00\u79cd\u989c\u8272\u53ef\u89c6\u4e3a\u67d0\u79cd\u5149\u8c31\u8272\u4e0e\u767d\u8272\u6df7\u5408 \u7ed3\u679c\u3002\u5176\u4e2d\u5149\u8c31\u8272\u7684\u5360\u6bd4\u8d8a\u5927&#xff0c;\u989c\u8272\u8d8a\u63a5\u8fd1\u5149\u8c31\u8272&#xff0c;\u989c\u8272\u7684\u9971\u548c\u5ea6\u4e5f\u5c31\u8d8a\u9ad8\u3002 Value&#xff1a;\u660e\u5ea6&#xff0c;\u8868\u793a\u989c\u8272\u7684\u660e\u4eae\u7a0b\u5ea6&#xff0c;\u53d6\u503c\u8303\u56f40%(\u9ed1)~100%(\u767d)\u3002\u5bf9\u4e8e\u5149\u6e90\u8272&#xff0c;\u660e\u5ea6\u503c\u4e0e\u53d1\u5149\u4f53\u7684\u5149\u4eae\u5ea6\u6709\u5173\u3002\u5bf9\u4e8e\u7269\u4f53\u8272&#xff0c;\u660e\u5ea6\u503c\u4e0e\u7269\u4f53\u7684\u900f\u5c04\u6bd4\u6216\u53cd\u5c04\u6bd4\u6709\u5173\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113418-6899d53a7fceb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113434-6899d54a271df.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>3.HSL HSL\u9876\u90e8\u4e3a\u7eaf\u767d&#xff0c;\u4e0d\u7ba1\u662f\u4ec0\u4e48\u989c\u8272 Hue&#xff1a;\u8272\u76f8&#xff0c;\u5373\u8272\u5f69&#xff0c;\u7528\u89d2\u5ea6\u5ea6\u91cf&#xff0c;\u53d6\u503c\u8303\u56f40\u00b0~360\u00b0&#xff0c;\u4ece\u7ea2\u8272\u5f00\u59cb\u6309\u9006\u65f6\u9488\u65b9\u5411\u8ba1\u7b97&#xff0c;\u7ea2\u8272\u4e3a0\u00b0&#xff0c;\u7eff\u8272\u4e3a120\u00b0&#xff0c;\u84dd\u8272\u4e3a240\u00b0 Saturation:\u9971\u548c\u5ea6&#xff0c;\u7c7b\u4f3c\u4e8e\u6d53\u5ea6 Lightness:\u4eae\u5ea6 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113438-6899d54e4f100.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u200c4.CMYK\u5370\u5237\u56db\u5206\u8272\u6a21\u5f0f \u91c7\u7528\u9752&#xff08;Cyan&#xff09;\u3001\u54c1\u7ea2&#xff08;Magenta&#xff09;\u3001\u9ec4&#xff08;Yellow&#xff09;\u3001\u9ed1&#xff08;Key&#xff09;\u7684\u51cf\u8272\u6df7\u5408\u6a21\u578b&#xff0c;\u9002\u7528\u4e8e\u5370\u5237\u884c\u4e1a&#xff0c;\u901a\u8fc7\u6cb9\u58a8\u53e0\u52a0\u5b9e\u73b0\u8272\u5f69\u8fd8\u539f\u3002\u200c\u200c<\/p>\n<p>5\u200c.Lab\u8272\u5f69\u7a7a\u95f4\u200c\u3002 \u57fa\u4e8e\u4eba\u773c\u89c6\u89c9\u7684\u975e\u7ebf\u6027\u6a21\u578b&#xff0c;\u5305\u542b\u4eae\u5ea6&#xff08;L&#xff09;\u548c\u989c\u8272\u5bf9\u7acb\u7ef4\u5ea6&#xff08;a\u3001b&#xff09;&#xff0c;\u72ec\u7acb\u4e8e\u8bbe\u5907&#xff0c;\u5e38\u7528\u4e8e\u8272\u5f69\u6821\u6b63\u548c\u8de8\u5a92\u4ecb\u8272\u5f69\u5339\u914d\u3002\u200c\u200c <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113446-6899d556bca8d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2.\u8272\u5f69\u7a7a\u95f4\u7684\u5e94\u7528\u4e0e\u610f\u4e49\u200c<\/h3>\n<p>\u200c\u8bbe\u5907\u9002\u914d\u6027\u200c&#xff1a;\u4e0d\u540c\u8bbe\u5907&#xff08;\u5982\u663e\u793a\u5668\u3001\u6253\u5370\u673a&#xff09;\u7684\u8272\u57df\u5dee\u5f02\u9700\u901a\u8fc7\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362&#xff08;\u5982RGB\u2192CMYK&#xff09;\u786e\u4fdd\u989c\u8272\u4e00\u81f4\u6027\u3002\u200c\u200c<\/p>\n<p>\u200c\u89c6\u89c9\u4f18\u5316\u200c&#xff1a;YUV\u8272\u5f69\u7a7a\u95f4\u5206\u79bb\u4eae\u5ea6\u548c\u8272\u5ea6&#xff0c;\u53ef\u63d0\u5347\u89c6\u9891\u7f16\u7801\u6548\u7387&#xff1b;Lab\u7a7a\u95f4\u5219\u66f4\u7b26\u5408\u4eba\u773c\u5bf9\u4eae\u5ea6\u548c\u8272\u5f69\u7684\u654f\u611f\u5ea6\u5dee\u5f02\u3002\u200c\u200c<\/p>\n<p>\u200c\u6807\u51c6\u5316\u9700\u6c42\u200c&#xff1a;\u56fd\u9645\u7ec4\u7ec7&#xff08;\u5982ICC&#xff09;\u5236\u5b9a\u8272\u5f69\u914d\u7f6e\u6587\u4ef6&#xff08;.icm&#xff09;&#xff0c;\u7edf\u4e00\u4e0d\u540c\u8272\u5f69\u7a7a\u95f4\u7684\u6620\u5c04\u89c4\u5219&#xff0c;\u5b9e\u73b0\u8de8\u5e73\u53f0\u8272\u5f69\u7ba1\u7406\u3002\u200c\u200c<\/p>\n<h3>3.\u989c\u8272\u7f16\u7801\u65b9\u6cd5<\/h3>\n<p>YUV&#xff0c;\u662f\u4e00\u79cd\u989c\u8272\u7f16\u7801\u65b9\u6cd5\u3002\u5e38\u4f7f\u7528\u5728\u5404\u4e2a\u89c6\u9891\u5904\u7406\u7ec4\u4ef6\u4e2d\u3002 YUV\u5728\u5bf9\u7167\u7247\u6216\u89c6\u9891\u7f16\u7801\u65f6&#xff0c;\u8003\u8651\u5230\u4eba\u7c7b\u7684\u611f\u77e5\u80fd\u529b&#xff0c;\u5141\u8bb8\u964d\u4f4e\u8272\u5ea6\u7684\u5e26\u5bbd\u3002 Y\u8868\u793a\u660e\u4eae\u5ea6(Luminance\u6216Luma)&#xff0c;\u4e5f\u5c31\u662f\u7070\u9636\u503c&#xff0c;U\u548cV\u8868\u793a\u663e\u8272\u5ea6(Chrominance\u6216Chroma)&#xff0c;\u4f5c\u7528\u7c7b\u4f3c\u4e8e\u63cf\u8ff0\u5f71\u50cf\u8272\u5f69\u53ca\u9971\u548c\u5ea6&#xff0c;\u7528\u4e8e\u6307\u5b9a\u50cf\u7d20\u7684\u989c\u8272 YUUV\u7684\u53d1\u660e\u662f\u7531\u4e8e\u5f69\u8272\u7535\u89c6\u4e0e\u9ed1\u767d\u7535\u89c6\u7684\u8fc7\u6e21\u65f6\u671f&#xff0c;YUUV\u6700\u5927\u7684\u4f18\u70b9\u5728\u4e8e\u53ea\u9700\u8981\u5360\u7528\u6781\u5c11\u7684\u5e26\u5bbd 4&#xff1a;4&#xff1a;4\u4ee3\u8868\u5b8c\u5168\u53d6\u6837 4&#xff1a;2&#xff1a;2\u8868\u793a2&#xff1a;1\u7684\u6c34\u5e73\u53d6\u6837&#xff0c;\u5782\u76f4\u5b8c\u5168\u53d6\u6837&#xff0c;Y\u53d64\u4e2aUV\u5404\u53d62\u4e2a 4&#xff1a;2&#xff1a;0\u8868\u793a2&#xff1a;1\u7684\u6c34\u5e73\u53d6\u6837&#xff0c;\u5782\u76f42&#xff1a;1\u53d6\u6837&#xff0c;Y\u53d64\u4e2aU\u53d62\u4e2a\u6216V\u53d62\u4e2a&#8212;&#8212;&#8211;\u76ee\u524d\u5e38\u7528 4&#xff1a;1&#xff1a;1\u8868\u793a4&#xff1a;1\u7684\u6c34\u5e73\u53d6\u6837&#xff0c;\u5782\u76f4\u5b8c\u5168\u53d6\u6837<\/p>\n<h3>4.HSL\u548cHSV\u7684\u5dee\u5f02\u70b9<\/h3>\n<p>HSV\u4e2dS\u63a7\u5236\u7eaf\u8272\u6df7\u5165\u767d\u8272\u7684\u91cf&#xff0c;\u503c\u8d8a\u5927&#xff0c;\u767d\u8272\u8d8a\u5c11&#xff0c;\u989c\u8272\u8d8a\u7eaf\u3002V\u63a7\u5236\u7eaf\u8272\u6df7\u5165\u9ed1\u8272\u7684\u91cf&#xff0c;\u503c\u8d8a\u5927&#xff0c;\u9ed1\u8272\u8d8a\u5c11&#xff0c;\u660e\u5ea6\u8d8a\u9ad8\u3002 HSL\u4e2dS\u4e0e\u9ed1\u767d\u65e0\u5173&#xff0c;\u9971\u548c\u5ea6\u4e0d\u63a7\u5236\u989c\u8272\u4e2d\u6df7\u5165\u7684\u9ed1\u767d\u591a\u5c11&#xff0c;L\u63a7\u5236\u7eaf\u8272\u4e2d\u6df7\u5165\u7684\u9ed1\u767d\u4e24\u79cd\u989c\u8272 HSV\u4e2d\u7684S\u7c7b\u4f3c\u4e8e10ml\u7eaf\u7ea2\u52a0\u767d\u8272&#xff0c;HSL\u4e2d\u7684S\u7c7b\u4f3c\u4e8e10ml\u7eaf\u7ea2\u52a0\u6c34<\/p>\n<h3>5.RGB\u8f6c\u5316\u5230HSV\u7684\u7b97\u6cd5<\/h3>\n<p>max<span class=\"token operator\">&#061;<\/span><span class=\"token function\">max<\/span><span class=\"token punctuation\">(<\/span>R<span class=\"token punctuation\">,<\/span>G<span class=\"token punctuation\">,<\/span>B<span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span><br \/>\nmin<span class=\"token operator\">&#061;<\/span><span class=\"token function\">min<\/span><span class=\"token punctuation\">(<\/span>R<span class=\"token punctuation\">,<\/span>G<span class=\"token punctuation\">,<\/span>B<span class=\"token punctuation\">)<\/span><br \/>\nV<span class=\"token operator\">&#061;<\/span><span class=\"token function\">max<\/span><span class=\"token punctuation\">(<\/span>R<span class=\"token punctuation\">,<\/span>G<span class=\"token punctuation\">,<\/span>B<span class=\"token punctuation\">)<\/span><br \/>\nS<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span>max<span class=\"token operator\">&#8211;<\/span>min<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span>max<span class=\"token operator\">:<\/span><br \/>\n<span class=\"token keyword\">if<\/span> R <span class=\"token operator\">&#061;<\/span> max<span class=\"token punctuation\">,<\/span>H <span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span>G<span class=\"token operator\">&#8211;<\/span>B<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token punctuation\">(<\/span>max<span class=\"token operator\">&#8211;<\/span>min<span class=\"token punctuation\">)<\/span><span class=\"token operator\">*<\/span> <span class=\"token number\">60<\/span><br \/>\n<span class=\"token keyword\">if<\/span> G <span class=\"token operator\">&#061;<\/span> max<span class=\"token punctuation\">,<\/span>H <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">120<\/span><span class=\"token operator\">&#043;<\/span><span class=\"token punctuation\">(<\/span>B<span class=\"token operator\">&#8211;<\/span>R<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token punctuation\">(<\/span>max<span class=\"token operator\">&#8211;<\/span>min<span class=\"token punctuation\">)<\/span><span class=\"token operator\">*<\/span> <span class=\"token number\">60<\/span><br \/>\n<span class=\"token keyword\">if<\/span> B <span class=\"token operator\">&#061;<\/span> max<span class=\"token punctuation\">,<\/span>H <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">240<\/span> <span class=\"token operator\">&#043;<\/span><span class=\"token punctuation\">(<\/span>R<span class=\"token operator\">&#8211;<\/span>G<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token punctuation\">(<\/span>max<span class=\"token operator\">&#8211;<\/span>min<span class=\"token punctuation\">)<\/span><span class=\"token operator\">*<\/span> <span class=\"token number\">60<\/span><br \/>\n<span class=\"token keyword\">if<\/span> H <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span>H <span class=\"token operator\">&#061;<\/span> H<span class=\"token operator\">&#043;<\/span> <span class=\"token number\">360<\/span><\/p>\n<h2>\u4e8c\u3001OpenCV\u4e2d\u5bf9\u8272\u5f69\u7a7a\u95f4\u5904\u7406<\/h2>\n<table>\n<tr>\u51fd\u6570\u540d\u53c2\u6570\u529f\u80fd\u6ce8\u610f\u4e8b\u9879<\/tr>\n<tbody>\n<tr>\n<td>cvtColor()<\/td>\n<td>img&#xff0c;colorspace<\/td>\n<td>\u56fe\u7247\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362<\/td>\n<td>\u65e0<\/td>\n<\/tr>\n<tr>\n<td>split()<\/td>\n<td>img<\/td>\n<td>\u5206\u5272\u989c\u8272\u901a\u9053<\/td>\n<td>\u8fd4\u56de\u503c\u4e3a(b, g, r)\u5143\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>merge()<\/td>\n<td>(b, g, r)<\/td>\n<td>\u5408\u5e76\u901a\u9053<\/td>\n<td>\u4f20\u5165\u503c\u4e3a(b, g, r)\u5143\u7ec4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b<\/p>\n<p><span class=\"token comment\">#\u5e38\u89c1\u989c\u8272\u7a7a\u95f4\u8f6c\u6362 cv2.COLOR_BGR2GRAY\u8f6c\u4e3a\u7070\u5ea6\u56fe\u5e38\u7528<\/span><br \/>\n<span class=\"token comment\">#cv2.COLOR_BGR2RGBA,cv2.COLOR_BGR2BGRA<\/span><br \/>\n<span class=\"token comment\">#cv2.COLOR_BGR2GRAY,cv2.COLOR_BGR2HSV<\/span><br \/>\n<span class=\"token comment\">#cv2.COLOR_BGR2YUV <\/span><br \/>\n<span class=\"token comment\">#\u8fdb\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362<\/span><br \/>\ncvt_img <span class=\"token operator\">&#061;<\/span> cv2<span class=\"token punctuation\">.<\/span>cvtColor<span class=\"token punctuation\">(<\/span>img_cat<span class=\"token punctuation\">,<\/span>COLOR_BGR2GRAY<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">#\u5206\u5272\u901a\u9053<\/span><br \/>\nb<span class=\"token punctuation\">,<\/span> g<span class=\"token punctuation\">,<\/span> r <span class=\"token operator\">&#061;<\/span> cv2<span class=\"token punctuation\">.<\/span>split<span class=\"token punctuation\">(<\/span>img<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">#\u5408\u5e76\u901a\u9053<\/span><br \/>\nimg2 <span class=\"token operator\">&#061;<\/span> cv2<span class=\"token punctuation\">.<\/span>merge<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>b<span class=\"token punctuation\">,<\/span> g<span class=\"token punctuation\">,<\/span> r<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<hr \/>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u673a\u5668\u89c6\u89c9\u4e2d\u7684\u56fe\u50cf\u8272\u5f69\u57fa\u7840\u77e5\u8bc6&#xff0c;\u91cd\u70b9\u8bb2\u89e3\u4e86\u51e0\u79cd\u5e38\u89c1\u8272\u5f69\u7a7a\u95f4&#xff08;RGB\u3001HSV\u3001HSL\u3001CMYK\u3001Lab&#xff09;\u7684\u7279\u70b9\u548c\u5e94\u7528\u573a\u666f\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5404\u8272\u5f69\u7a7a\u95f4\u7684\u53c2\u6570\u542b\u4e49\u3001\u8f6c\u6362\u7b97\u6cd5&#xff0c;\u4ee5\u53caOpenCV\u4e2d\u7684\u76f8\u5173\u5904\u7406\u51fd\u6570&#xff0c;\u5305\u62ec\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362(cvtColor)\u3001\u901a\u9053\u5206\u5272(split)\u548c\u5408\u5e76(merge)\u64cd\u4f5c\u3002\u8fd9\u4e9b\u57fa\u7840\u5185\u5bb9\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u5b66\u4e60\u5960\u5b9a\u4e86\u57fa\u7840&#xff0c;\u5bf9\u7406\u89e3\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u8272\u5f69\u5904\u7406\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e31\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u673a\u5668\u89c6\u89c9\u4e2d\u7684\u56fe\u50cf\u8272\u5f69\u57fa\u7840\u77e5\u8bc6\uff0c\u91cd\u70b9\u8bb2\u89e3\u4e86\u51e0\u79cd\u5e38\u89c1\u8272\u5f69\u7a7a\u95f4\uff08RGB\u3001HSV\u3001HSL\u3001CMYK\u3001Lab\uff09\u7684\u7279\u70b9\u548c\u5e94\u7528\u573a\u666f\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5404\u8272\u5f69\u7a7a\u95f4\u7684\u53c2\u6570\u542b\u4e49\u3001\u8f6c\u6362\u7b97\u6cd5\uff0c\u4ee5\u53caOpenCV\u4e2d\u7684\u76f8\u5173\u5904\u7406\u51fd\u6570\uff0c\u5305\u62ec\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362(cvtColor)\u3001\u901a\u9053\u5206\u5272(split)\u548c\u5408\u5e76(merge)\u64cd\u4f5c\u3002\u8fd9\u4e9b\u57fa\u7840\u5185\u5bb9\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u5b66\u4e60\u5960\u5b9a\u4e86\u57fa\u7840\uff0c\u5bf9\u7406\u89e3\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u8272\u5f69\u5904\u7406\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002<\/p>\n","protected":false},"author":2,"featured_media":52788,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1460,81,125],"topic":[],"class_list":["post-52794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-opencv","tag-python","tag-125"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/52794.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e31\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u673a\u5668\u89c6\u89c9\u4e2d\u7684\u56fe\u50cf\u8272\u5f69\u57fa\u7840\u77e5\u8bc6\uff0c\u91cd\u70b9\u8bb2\u89e3\u4e86\u51e0\u79cd\u5e38\u89c1\u8272\u5f69\u7a7a\u95f4\uff08RGB\u3001HSV\u3001HSL\u3001CMYK\u3001Lab\uff09\u7684\u7279\u70b9\u548c\u5e94\u7528\u573a\u666f\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5404\u8272\u5f69\u7a7a\u95f4\u7684\u53c2\u6570\u542b\u4e49\u3001\u8f6c\u6362\u7b97\u6cd5\uff0c\u4ee5\u53caOpenCV\u4e2d\u7684\u76f8\u5173\u5904\u7406\u51fd\u6570\uff0c\u5305\u62ec\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362(cvtColor)\u3001\u901a\u9053\u5206\u5272(split)\u548c\u5408\u5e76(merge)\u64cd\u4f5c\u3002\u8fd9\u4e9b\u57fa\u7840\u5185\u5bb9\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u5b66\u4e60\u5960\u5b9a\u4e86\u57fa\u7840\uff0c\u5bf9\u7406\u89e3\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u8272\u5f69\u5904\u7406\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52794.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T11:34:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113407-6899d52f6ca37.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52794.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52794.html\",\"name\":\"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T11:34:48+00:00\",\"dateModified\":\"2025-08-11T11:34:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52794.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52794.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52794.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/52794.html","og_locale":"zh_CN","og_type":"article","og_title":"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e31\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u673a\u5668\u89c6\u89c9\u4e2d\u7684\u56fe\u50cf\u8272\u5f69\u57fa\u7840\u77e5\u8bc6\uff0c\u91cd\u70b9\u8bb2\u89e3\u4e86\u51e0\u79cd\u5e38\u89c1\u8272\u5f69\u7a7a\u95f4\uff08RGB\u3001HSV\u3001HSL\u3001CMYK\u3001Lab\uff09\u7684\u7279\u70b9\u548c\u5e94\u7528\u573a\u666f\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5404\u8272\u5f69\u7a7a\u95f4\u7684\u53c2\u6570\u542b\u4e49\u3001\u8f6c\u6362\u7b97\u6cd5\uff0c\u4ee5\u53caOpenCV\u4e2d\u7684\u76f8\u5173\u5904\u7406\u51fd\u6570\uff0c\u5305\u62ec\u8272\u5f69\u7a7a\u95f4\u8f6c\u6362(cvtColor)\u3001\u901a\u9053\u5206\u5272(split)\u548c\u5408\u5e76(merge)\u64cd\u4f5c\u3002\u8fd9\u4e9b\u57fa\u7840\u5185\u5bb9\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u7b97\u6cd5\u5b66\u4e60\u5960\u5b9a\u4e86\u57fa\u7840\uff0c\u5bf9\u7406\u89e3\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u8272\u5f69\u5904\u7406\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/52794.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T11:34:48+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113407-6899d52f6ca37.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/52794.html","url":"https:\/\/www.wsisp.com\/helps\/52794.html","name":"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T11:34:48+00:00","dateModified":"2025-08-11T11:34:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52794.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52794.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52794.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u673a\u5668\u89c6\u89c9\uff1a\u7b2c\u4e09\u8bb2\u2013\u56fe\u7247\u8272\u5f69"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=52794"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52794\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/52788"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52794"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}