Accessing pixel values in an image

I’m pretty new to using OpenCV, and I have a pretty basic question; I’m using OpenCV with C++, and I’m reading a black and white image using imread and storing it in cv::Mat x (and hence Mat is a 2D Matrix here); Is there a particular way to access the pixel value, at a specified location? I’ve tried printing the output of

x.at(px, py)

on the console, but I have reason to believe it shows an incorrect value; Is there any better way to access the pixel value at a specified location?

All is in this tutorial
and at methods starts here