im trying to access and modify pixel values from an image I read into opencv. I read several posts on how to do this, however, they dont seem to work for me.
gives me the result:
In this image im trying to see the pixel values at location (10,10) in the image. I tried to output all the values of the image but they still look like special characters.
I also tried Scalar and unchar types instead of Vec3b but nothing seems to give me the appropriate value (between 0-255). Type double gives me -NaN for every pixel location. I checked the src.type() of the image and that returned 16 which I figure is 16S type.
How can I modify the image or somehow access the image pixel values of this type and modify it?
Thanks in advance!
(here is the image im trying to access:
cout interprets your byte as a char, and tries to print something ascii ;) so just cast to int:
cout << int(src.at<Vec4b>(3,3)) << endl; // 100
or print the whole pixel:
cout << src.at<Vec4b>(3,3) << endl; // [100, 23, 90]
yes, you can manipulate it:
Vec3b & pixel = src.at<Vec4b>(3,3); pixel += 5; cout << src.at<Vec4b>(3,3) << endl; // [100, 28, 90]