Getting negative value of pixel openCV Java

asked 2017-07-09 14:34:52 -0600

arqam gravatar image

In a java project when trying to access pixel value, I am getting negative value.

Code ::

Mat srcImage = imageToMatFormat(imgSource);
    byte[]  buffer = new byte[3];
    for (int x = 0; x < srcImage.rows(); x++) {
        for (int y = 0; y < srcImage.cols(); y++) {
            srcImage.get(x, y, buffer);
            if(buffer[0]!=0)
                System.out.println(buffer[0] + buffer[1] + buffer[2]);
        }
    }

Some values that I am getting is

126-119-115
125-120-116
124-121-117

So what does this negative number in here signi

edit retag flag offensive close merge delete

Comments

rather : System.out.print(srcImage);

it is get(y,x), the type() of the Mat probably is not bytes, and buffer[0] + buffer[1] + buffer[2] is probably an addition, not a string concatenation

berak gravatar imageberak ( 2017-07-09 21:43:31 -0600 )edit

@berak How is it get(y,x) when the we are parsing srcImage.rows for x and srcImage.cols for y?

arqam gravatar imagearqam ( 2017-07-21 00:43:16 -0600 )edit