((uchar*) (Img1->imagedata + img1->widthstep*pt.y)) [Pt.x] the specific meaning

Source: Internet
Author: User
Widthstep refers to the number of bytes per row of an image.


The main and width differences:
Width is the number of pixels per line that represents the image, and widthstep refers to how many bytes are required to store a single row.
In the OpenCV, the widthstep must be a multiple of 4, thus achieving byte alignment, which is advantageous to increase the computational speed.
If the 8U single-channel image has a width of 3, then the Widthstep is 4, plus one byte. The line of this image requires 4 bytes,
Use only the first 3, the last one is empty. That is, a width of 3 high 3 image of the ImageData data size is 4*3=12 bytes.



ImageData is a pointer to an array of image pixel values, which is the first address of the array, pt.y refers to the line coordinates of the pixel, so Img->imagedata + img->widthstep* Pt.y is the first address of the row where the pixel is located, and then with the column where the pixel is located, that is, pt.x, you get the address of that pixel, so your code can be written
((uchar*) (Img1->imagedata + img1->widthstep*pt.y+pt.x)), which refers to the pixel value of the pixel.

((uchar*) (Img1->imagedata + img1->widthstep*pt.y)) [Pt.x] the specific meaning

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.