Accessing pixels in a Mat vector
I have reshape a 2d grayscale image to a 1d Mat.I want to access and change each pixel.Each pixel should be 0-255
Mat input_img = imread(argv[1], IMREAD_GRAYSCALE);
Mat input_vector = input_img.reshape(0,1);
std::cout << input_1d_vector.at<int>(0,1);
However it is not ouputing a sensible pixel value.My apologies if its a dumb question , i am new with opencv
what are you really trying to achieve here ? what is the purpose of it ?
NO, you shouldn't do things per-pixel at all. XY-problem here !
I want to convert the 2d representation ofan image to 1d to apply RLE(run length encoding) on it
different story, then. ;)
is this "homework" ? (smells pretty much like it !)
No its not homework , it just need help in accessing the pixels in the Mat , not with RLE
then again no, you shouldn't.
opencv is a high level matrix library. use appropriate functions, don't reinvent square wheels !