Hello, I want to check pixel values with this program, however the results are not convincing at all for me. I am loading an image in grayscale and the colors are of course very different as it can be seen in the image
However when I pass the mouse (with the implemented mouse callback function) I receive white colors with values of 90 for example, or black colors with values of 130.
include <iostream>
include <stdio.h>
include <opencv2 opencv.hpp="">
include <highgui.h>
using namespace cv; using namespace std;
Mat image; char window_name[20]="Get coordinates";
static void onMouse( int event, int x, int y, int f, void* ){ image = imread("/home/diego/Humanoids/imageGreen0.png"); int intensity = (int)image.at<uchar>(Point(x,y));
cout << "x: "<< x << " y: " << y << " value: " << intensity << endl;
}
int main() { namedWindow( window_name, CV_WINDOW_NORMAL ); image = imread("/home/diego/Humanoids/imageGreen0.png"); imshow( window_name, image ); setMouseCallback( window_name, onMouse, 0 ); waitKey(0); return 0; }
I want to learn how to use this because I want to get rid of the bottle shadow (by the way, here I put the green value of each pixel from an RGB image into the correspondent pixel in a grayscale image --> It's a green bottle) and I thought that maybe there can be a difference between the values of the bottle and the reflection from the sun which can allow me to make a threshold.
Can anyone help me telling me what is the error here? I am trying to stop being a newbie in OpenCV and C++, but I think that there is still a long way for it. Thank you