# Revision history [back]

first of all, why not use the builtin Sobel ?

and then, you have to access a 1 channel uchar Mat like:

mGr.at<uchar>(i,j)    // not int !


same trouble with:

xMat.at<double>(i,j)  //   broken, must be 'char' since the the type of xMat is CV_8S
magnitudo.at<double>(i,j)  // broken, must be 'float' since the the type of magnitudo is CV_32F


cut a long story short: the type whithin the braces has to fit the Mat's type, you can't choose it at will.

so, you're still sure, you want to reinvent the wheel ?

first of all, why not use the builtin Sobel ?

and then, you have to access a 1 channel uchar Mat like:

mGr.at<uchar>(i,j)    // not int !


same trouble with:

xMat.at<double>(i,j)  //   broken, must be 'char' since the the type of xMat is CV_8S
magnitudo.at<double>(i,j)  // broken, must be 'float' since the the type of magnitudo is CV_32F


cut a long story short: the type whithin the braces has to fit the Mat's type, you can't choose it at will.

so, you're still sure, you want to reinvent the wheel ?

first of all, why not use the builtin Sobel ?

and then, you have to access a 1 channel uchar Mat like:

mGr.at<uchar>(i,j)    // not int !


same trouble with:

xMat.at<double>(i,j)  //   broken, must be 'char' since the the type of xMat is CV_8S
magnitudo.at<double>(i,j)  // broken, must be 'float' since the the type of magnitudo is CV_32F


cut a long story short: the type whithin the braces has to fit the Mat's type, you can't choose it at will.

so, you're still sure, you want to reinvent the wheel ?

first of all, why not use the builtin Sobel Sobel Filter ?

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#Sobel(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int,%20int,%20int)

and then, you have to access a 1 channel uchar Mat like:

mGr.at<uchar>(i,j)    // not int !


same trouble with:

xMat.at<double>(i,j)  //   broken, must be 'char' since the the type of xMat is CV_8S
magnitudo.at<double>(i,j)  // broken, must be 'float' since the the type of magnitudo is CV_32F


cut a long story short: the type whithin the braces has to fit the Mat's type, you can't choose it at will.

so, you're still sure, you want to reinvent the wheel ?

first of all, why not use the builtin Sobel Filter ?

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#Sobel(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int,%20int,%20int)

and then, you have to access a 1 channel uchar Mat like:

mGr.at<uchar>(i,j)    // not int !


same trouble with:

xMat.at<double>(i,j)  //   broken, must be 'char' since the the type of xMat is CV_8S
magnitudo.at<double>(i,j)  // broken, must be 'float' since the the type of magnitudo is CV_32F


cut a long story short: the type whithin the braces has to fit the Mat's type, you can't choose it at will.

so, you're still sure, you want to reinvent the wheel ?