<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Six methods of indexing pixels of Mat in OpenCV

      Six methods of indexing pixels of Mat in OpenCV

      .at<>()

      // modify the pixel directly
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols; ++w) {
              image.at<Vec3b>(h, w)[0] = 255;
              image.at<Vec3b>(h, w)[1] = 0;
              image.at<Vec3b>(h, w)[2] = 0;
          }
      }
      
      // modify the pixel by the reference
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols; ++w) {
              Vec3b& bgr = image.at<Vec3b>(h, w);
              bgr.val[0] = 0;
              bgr.val[1] = 255;
              bgr.val[2] = 0;
          }
      }
      
      // the image has one channel
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              image.at<uchar>(h, w) = 128;
          }
      }
      

      .ptr<>()

      // use uchar type
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              uchar* ptr = image.ptr<uchar>(h, w);
              ptr[0] = 255;
              ptr[1] = 0;
              ptr[2] = 0;
          }
      }
      // use cv::Vec3b type
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              Vec3b* ptr = image.ptr<Vec3b>(h, w);
              ptr->val[0] = 0;
              ptr->val[1] = 255;
              ptr->val[2] = 0;
          }
      }
      
      // use the row pointer and the image has one channel
      for (int h = 0; h < image.rows; ++h) {
          uchar* ptr = image.ptr(h);
          for (int w = 0; w < image.cols / 2; ++w) {
              ptr[w] = 128;
          }
      }
      
      // use the pixel pointer and the image has one channel
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              uchar* ptr = image.ptr<uchar>(h, w);
              *ptr = 255;
          }
      }
      

      iterator

      // the image has three channels
      Mat_<Vec3b>::iterator it = image.begin<Vec3b>();
      Mat_<Vec3b>::iterator itend = image.end<Vec3b>();
      for (; it != itend; ++it) {
          (*it)[0] = 255;
          (*it)[1] = 0;
          (*it)[2] = 0;
      }
      
      // the image has one channel
      Mat_<uchar>::iterator it1 = image.begin<uchar>();
      Mat_<uchar>::iterator itend1 = image.end<uchar>();
      for (; it1 != itend1; ++it1) {
          (*it1) = 128;
      }
      

      .data pointer

      // 3 channels
      uchar* data = image.data;
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              *data++ = 128;
              *data++ = 128;
              *data++ = 128;
          }
      }
      
      // 1 channel
      uchar* data = image.data;
      for (int h = 0; h < image.rows; ++h) {
          for (int w = 0; w < image.cols / 2; ++w) {
              *data++ = 128;
          }
      }
      

      .row() and .col()

      for (int i = 0; i < 100; ++i) {
          image.row(i).setTo(Scalar(0, 0, 0)); // modify the i th row data
          image.col(i).setTo(Scalar(0, 0, 0)); // modify the i th column data
      }
      

      when isContinuous() is true

      Mat image = imread("...");
      int nRows = image.rows;
      int nCols = image.cols * image.channels();
      
      if (image.isContinuous()) {
          nCols = nRows * nCols;
          nRows = 1;
      }
      
      for (int h = 0; h < nRows; ++h) {
          uchar* ptr = image.ptr<uchar>(h);
          for (int w = 0; w < nCols; ++w) {
              // ptr[w] = 128 ;
              *ptr++ = 128;
          }
      }
      

      Reference

      posted @ 2025-03-26 21:53  lart  閱讀(15)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 肉大捧一进一出免费视频| 国产精品一线天粉嫩av| 欧美成人免费全部| 成人污视频| 少妇高潮喷水在线观看| 国产精品色哟哟在线观看| 亚洲中文精品一区二区| 亚洲高清WWW色好看美女| 漂亮的保姆hd完整版免费韩国| 国产精品高清中文字幕| 讷河市| 成人片黄网站a毛片免费| 色欲国产精品一区成人精品| 亚洲国产精品热久久一区| 不卡免费一区二区日韩av| 亚洲欧美日韩在线码| 日韩精品无码一区二区视频| 一区二区三区四区亚洲自拍| 亚洲天堂男人的天堂在线| 九九在线精品国产| 在线观看潮喷失禁大喷水无码| 日韩成人无码影院| 久久综合97丁香色香蕉| 三级国产在线观看| 国产精品av免费观看| 亚洲精品午夜精品| 国产一区二区三区美女| 亚洲人成人伊人成综合网无码| 五月综合婷婷久久网站| 亚洲国产精品无码久久电影| av在线中文字幕不卡电影网| 九九热在线视频免费播放| 欧美大bbbb流白水| 国产区精品福利在线观看精品| 日本一区二区久久人妻高清| 国产午夜福利片在线观看| 国产一区二区黄色在线观看| 亚洲av无码之国产精品网址蜜芽| 野外做受三级视频| 亚洲中文字幕日产无码成人片 | 狠狠综合久久综合88亚洲|