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