{"id":6847,"date":"2015-03-01T15:45:06","date_gmt":"2015-03-01T20:45:06","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=6847"},"modified":"2015-03-01T15:45:06","modified_gmt":"2015-03-01T20:45:06","slug":"05-cvinranges-%e6%89%be%e5%87%ba%e7%89%b9%e5%ae%9a%e9%a1%8f%e8%89%b2","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=6847","title":{"rendered":"05  cvInRangeS \u627e\u51fa\u7279\u5b9a\u984f\u8272"},"content":{"rendered":"<h1>\u76ee\u7684\uff1a<\/h1>\n<pre><tt class=\"descname\"><span class=\"highlighted\">cvInRangeS \u627e\u51fa\u7279\u5b9a\u7684\u984f\u8272<\/span><\/tt><\/pre>\n<h2>\u51fd\u6578\u4ecb\u7d39\uff1a<\/h2>\n<pre><tt class=\"descname\"><span class=\"highlighted\">cvInRangeS \u627e\u51fa\u7279\u5b9a\u7684\u984f\u8272\uff0c\u627e\u5230\u7684\u8a71\uff0c\u5c31\u986f\u793a\u70ba\u767d\u8272\uff0c\u4e0d\u7136\u70ba\u9ed1\u8272\u3002<\/span><\/tt><\/pre>\n<p>&nbsp;<\/p>\n<h2>\u53c3\u6578\u503c\uff1a<\/h2>\n<pre><strong>C:<\/strong><tt class=\"descname\"> <\/tt>void <tt class=\"descname\"><span class=\"highlighted\">cvInRangeS<\/span><\/tt><big>(<\/big>const CvArr* <strong>src<\/strong>, CvScalar <strong>lower<\/strong>, CvScalar <strong>upper<\/strong>, CvArr* <strong>dst<\/strong><big>)<\/big><\/pre>\n<table class=\"docutils field-list\" frame=\"void\" rules=\"none\">\n<colgroup>\n<col class=\"field-name\" \/>\n<col class=\"field-body\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr class=\"field-odd field\">\n<th class=\"field-name\">Parameters:<\/th>\n<td class=\"field-body\">\n<ul class=\"first last simple\">\n<li><strong>src<\/strong> \u2013 first input array.<\/li>\n<li><strong>lowerb<\/strong> \u2013 inclusive lower boundary array or a scalar.<\/li>\n<li><strong>upperb<\/strong> \u2013 inclusive upper boundary array or a scalar.<\/li>\n<li><strong>dst<\/strong> \u2013 output array of the same size as <tt class=\"docutils literal\"><span class=\"pre\">src<\/span><\/tt> and <tt class=\"docutils literal\"><span class=\"pre\">CV_8U<\/span><\/tt> type.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4f7f\u7528\u7bc4\u4f8b\uff1a<\/h2>\n<p>sample12_cvInRangeS<\/p>\n<p>\u4f8b\u5982\u627e\u51fa\u984f\u8272\u5728<\/p>\n<p>0&gt;=B&gt;=21<\/p>\n<p>200&gt;=G&gt;=255<\/p>\n<p>0&gt;=R&gt;=20<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;\/pre&gt;\r\n&lt;span class=&quot;s1&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;opencv2\/core\/core.hpp&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s1&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;opencv2\/highgui\/highgui.hpp&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s1&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;opencv2\/opencv.hpp&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s1&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;iostream&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s1&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;string.h&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;#include &lt;\/span&gt;&lt;span class=&quot;s3&quot;&gt;&lt;fstream&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;using&lt;\/span&gt; &lt;span class=&quot;s2&quot;&gt;namespace&lt;\/span&gt;&lt;span class=&quot;s4&quot;&gt; cv;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s5&quot;&gt;int&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt; main(&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;int&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt; argc,&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;char&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt; **argv)&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;{&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;int&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt; width,height;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;if&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;(argc&lt;=&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;1&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;)&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;{&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 \u00a0 \u00a0 &lt;\/span&gt;std::cout&lt;&lt;&lt;\/span&gt;&lt;span class=&quot;s3&quot;&gt;&quot;Error:Please Load a picture!&quot;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;&lt;std::endl;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 \u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;return&lt;\/span&gt; &lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;}&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;IplImage *image;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\/\/&lt;\/span&gt;&lt;span class=&quot;s7&quot;&gt;\u5efa\u7acb\u8996\u7a97&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;namedWindow(&lt;\/span&gt;&lt;span class=&quot;s3&quot;&gt;&quot;image&quot;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;,CV_WINDOW_AUTOSIZE);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\/\/&lt;\/span&gt;&lt;span class=&quot;s7&quot;&gt;\u8b80\u53d6\u5716\u7247&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;image=cvLoadImage(argv&#x5B;&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;1&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;]);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;width=image-&gt;width;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;height=image-&gt;height;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s8&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s9&quot;&gt;\/\/ &lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\u756b\u51fa\u6b63\u65b9\u5f62\u7684\u5916\u6846&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;IplImage * img2=cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, &lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;1&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;cvInRangeS(image, cvScalar(&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;200&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;), cvScalar(&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;21&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;255&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;20&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;), img2);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\/\/ cvInRangeS(image, CV_RGB(255,200,255), CV_RGB(255,250,255), img2);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;cvShowImage(&lt;\/span&gt;&lt;span class=&quot;s3&quot;&gt;&quot;image&quot;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;, image);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;waitKey(&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;cvShowImage(&lt;\/span&gt;&lt;span class=&quot;s3&quot;&gt;&quot;image2&quot;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;, img2);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;waitKey(&lt;\/span&gt;&lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0\u00a0 \u00a0&lt;\/span&gt;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;cvDestroyAllWindows();&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\/\/cvReleaseImage(&amp;image);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s4&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;\/\/system(&quot;pause&quot;);&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;\u00a0 \u00a0 &lt;\/span&gt;&lt;\/span&gt;&lt;span class=&quot;s5&quot;&gt;return&lt;\/span&gt; &lt;span class=&quot;s6&quot;&gt;0&lt;\/span&gt;&lt;span class=&quot;s2&quot;&gt;;&lt;\/span&gt;\r\n\r\n&lt;span class=&quot;s2&quot;&gt;}&lt;\/span&gt;\r\n&lt;pre&gt;\r\n\r\n<\/pre>\n<h2>\u7d50\u679c\uff1a<\/h2>\n<p><a href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=6848\" rel=\"attachment wp-att-6848\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6848\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM.jpg\" alt=\"Screen Shot 2015-03-01 at 12.37.17 PM\" width=\"512\" height=\"278\" srcset=\"https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM.jpg 512w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-300x163.jpg 300w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-316x172.jpg 316w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-120x65.jpg 120w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-210x114.jpg 210w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-496x269.jpg 496w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-12.37.17-PM-140x76.jpg 140w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<h2>\u88dc\u5145\u8cc7\u6599\uff1a<\/h2>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684\uff1a cvInRangeS \u627e\u51fa\u7279\u5b9a\u7684\u984f\u8272 \u51fd\u6578\u4ecb\u7d39\uff1a cvInRangeS \u627e\u51fa\u7279\u5b9a\u7684\u984f\u8272\uff0c\u627e\u5230\u7684\u8a71\uff0c\u5c31\u986f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6848,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[248],"tags":[],"class_list":["post-6847","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ch02-opencv-api"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6847"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6847"}],"version-history":[{"count":1,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6847\/revisions"}],"predecessor-version":[{"id":6849,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6847\/revisions\/6849"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/6848"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}