I'm doing an image manipulation project using OpenCV . I need to parse the pixels values of a "binarized" image, for this I am trying to convert my Mat file image to a array
of integers, more specifically an array of integers. I'm trying to do this:
Mat m;
m = imread("C:/Users/Syn/Desktop/filtesteBranco.jpg");
int matriz[this->m.size().width][this->m.size().height];
int i, j;
// inicializar matriz com zeros //
for (i = 0; i < (m.rows); i++){
for (j = 0; j <(m.cols); j++)
{
matriz[i][j] = 0;
}
}
for (int x = 0; x < (m.rows); x++) // varredura da matriz
{
for (int y = 0; y<(m.cols); y++)
{
matriz[x][y] = m.at<uchar>(x,y); // capturando os pixels
}
}
However, when you try to display the array and compare its integer values with the image, the values do not match the pixels in the original image lines. Am I capturing the pixels values in the wrong way? Would anyone know the right way to do this? Thanks in advance.
EDIT:
Below is the test I'm doing, I added 3 white pixels at the beginning and end of the last line of the image. The image in question is 674x35 in size, so I posted two zoomed images to show what I'm doing.
Whenprintingthevaluesofthelastlineoftheimage,Igetthefollowingvalues,however,theydonotmatchthepixelsoftheimage:
The initial and final values of the line are completely wrong. Would anyone know what might be happening?