title: What is the best way to get a single-channel region from a three-channel cv::Mat?
body: <pre><code>#include &quot;opencv2/opencv.hpp&quot;
  using namespace std;
  
  int main(int argc, char** argv) {
      cv::Mat img = cv::imread(&quot;an_img_from_internet.png&quot;, cv::IMREAD_COLOR);
      cv::Mat img_float;
      img.convertTo(img_float, CV_32FC3, 1.0/255);
  
      cv::Mat region = img_float(cv::Range(0, 5), cv::Range(0, 3));
      return 0;
  }
  </code></pre>
  <p>The code above tries to get a three-channel region from an image. But I just wanna get a single-channel region. I know a solution</p>
  <pre><code>std::vector&lt;cv::Mat&gt; img_float_vec; 
  cv::split(img_float, img_float_vec); 
  cv::Mat region = img_float_vec[0](cv::Range(0, 5), cv::Range(0, 3));
  </code></pre>
  <p>which is a little inconvenient. So I wonder if there is a better way to solve it in just one line, kind of like <code>cv::Mat region = img_float(cv::Range(0, 5), cv::Range(0, 3))[0]</code>?</p>