2014-07-24 05:25:23 -0600 | commented answer | Indexing beyond size of Mat still gives a result Thanks berak and Mathieu. I am in debug build and it was checking the bounds of my arrays that lead me to this short piece of test code. By doing a bit more googling I found that my version of OpenCV from MacPorts may have been compiled without debug symbols and by luck and luck alone it does not crash! http://stackoverflow.com/questions/20134498/debugging-a-dylib-in-xcode-that-was-built-without-debug-symbols I will try my own build using the source code form the OpenCV website |
2014-07-24 03:36:22 -0600 | asked a question | Indexing beyond size of Mat still gives a result I have loaded a jpg image that is 480 columns by 640 rows into a Mat and I want to return the pixel value at a certain position. I load a colour image and then I convert it to greyscale. Obviously I want to return pixel values between columns 0 to 479 and rows 0 to 639 but if I use an index of say (500,500) then I still get an answer without any crash or error. In fact an index up to (0,622575) works or even (1,622095), basically 622575 minus the length of 1 row (480). How is is it possible to index beyond the size of the Mat ? I am running this in Xcode 5.5.1 (debug mode) and I am using OpenCV 2.4.9 installed via MacPorts. Mat colourImage = imread("/Path_to/a.jpg"); Mat greyImage; int rowpos = 500; int colpos = 500; cvtColor(colourImage,greyImage,CV_BGR2GRAY); uchar gg = greyImage.at< uchar>(rowpos,colpos); cout << "pixel value " << (int)gg << endl; |