# Revision history [back]

### Get pixel value of sobel Mat with C++

Hi,

I need to read the value of single pixels in an Mat. Normally thats no problem but I created the Mat with the Sobel command and always get an Error if I try to read the value of an Pixel. I created the Sobel Mat like that:

        // ### Sobel ###
Mat sobel_x, sobel_y;
/// Sobel X
Sobel(src, sobel_x, ddepth, 1, 0, 5, scale, delta, BORDER_DEFAULT);
/// Sobel Y
Sobel(src, sobel_y, ddepth, 0, 1, 5, scale, delta, BORDER_DEFAULT);
imshow("Sobel y", sobel_y);
imshow("Sobel x", sobel_x);


If I try to read an Pixel I get this Error:

I tried for example

        Scalar intensity1 = sobel_x.at<uchar>(100, 100);
// or this:
//Scalar intensity = sobel_x.at<uchar>(Point(100, 100));
// or this:
//Mat cropedImage = sobel_x(Rect(100, 100, 1, 1));
//Scalar intensity1 = cropedImage.at<uchar>(1, 1);
// even if I try to just the read type of the Mat I get an error:
//int type = sobel_x.type();


hopefully someone can help me with that.

Thank you very much

Paul