Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

icrosoft C++ exception: cv::Exception at memory location

Iwant to implement a simple thresholding algorithm by comparing the pixel values of an image with some threshold and then assign either 0 or 1 to the pixels of output value correspondingly. a part of the code is:

cv::Mat gray , binary; // gray is input and binary is output image.

binary = Mat::zeros(gray.size(), gray.type());

for (int i=0;i<=row;i++)
{
    for (int j = 0; j <= col;j++)
    {

        if ((gray.at<uchar>(i, j) > NiblackThreshold)
        {
            binary.at<uchar>(i, j) = 1;
        }
        else
        {
            binary.at<uchar>(i, j) = 0;
        }

    }

Exceptions is at: template<typename _tp=""> inline _Tp& Mat::at(int i0, int i1) { CV_DbgAssert( dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1DataType<_Tp>::channels) < (unsigned)(size.p[1]channels()) && CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); return ((_Tp)(data + step.p[0]i0))[i1]; }

where is the problem?????