今天做项目时,需要去访问一张二值图某一坐标点的问题,和往常一样是使用int tmp = Mat.at(i, j);
但是!经过对比,竟然拿到的像素是错的(经过ps对比之后)
经过多次查找资料
竟然!
官网给出了说明(官网)
In order to get pixel intensity value, you have to know the type of an image and the number of channels. Here is an example for a single channel grey scale image (type 8UC1) and pixel coordinates x and y:
intensity.val[0] contains a value from 0 to 255. Note the ordering of x and y. Since in OpenCV images are represented by the same structure as matrices, we use the same convention for both cases - the 0-based row index (or y-coordinate) goes first and the 0-based column index (or x-coordinate) follows it. Alternatively, you can use the following notation:
所以
Mat.at(i, j) 其实访问的是(j, i)点;
一定要注意顺序
Mat.at(Point(i, j)) 访问的才是(i, j)点