A simple summary of the method of OpenCV accessing pixel values

Source: Internet
Author: User
OPENCV Accessing image pixel values

Briefly summarize the methods of accessing image pixel values in several data types in OpenCV, with mat type, iplimage type, Cvmat type. The following are for grayscale, color map is actually the operation of the corresponding three channels. 1. Mat type

for (int i = 0, i < img.rows; i++)
{for
 (int j = 0; J < Img.cols; J + +)
  {
    cout << (int) img.at& Lt;uchar> (i, J) << "";
  }
}
2. Iplimage type
iplimage* srcimg;
for (int i = 0, i < srcimg->height; i++)
{for
  (int j = 0; J < srcimg->width; J + +)
   {
     Temp = CVGET2D (Srcimg, I, J). Val[0];
      cout << temp << endl;
   }
}
3.CvMat type
void Printmat (cvmat* mat)//Print mat matrix
{for
    (int i = 0; i < mat->rows; i++)
    {for
        (int j = 0; J < ; mat->cols; J + +)
        {
            cout << cvmget (Mat, I, J) << "";
        }
        cout << Endl;
    }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.