# Revision history [back]

wait, if your image is CV_16UC, the only valid way to access it is:

cout<<dImg.at<ushort>(y,x)<<endl;


also, if your image is 320x240, you cannot access a pixel at (240,320), the largest(last) valid pixel is at (239,319) , remember, we start counting from 0.

wait, if your image is CV_16UC, the only valid way to access it is:

cout<<dImg.at<ushort>(y,x)<<endl;


really, you can't choose types there at will, but have to stick to what's inside your Mat.

running a DEBUG build is also recommended here, it should throw an exception, if you do something wrong.

also, if your image is 320x240, you cannot access a pixel at (240,320), the largest(last) valid pixel is at (239,319) , remember, we start counting from 0.