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.
my code:
int main()
{
Mat src=imread("/home/jaysinh/Pictures/shapes.jpg");
cout<<"rows:"<<src.rows<<endl;
cout<<"cols:"<<src.cols<<endl;
cout<<src.at<cv::Vec3b>(10,10)[0]<<endl;
waitKey(0);
return 0;
}
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: