What is the best way to calculate the Weber ratio for an image?
I am new to openCV and am taking a class in digital image processing. I am working through prior years assignment in preparation for our upcoming assignment.
- Write a program to display information about an image. The information we are interested in is the dimensions of the image, its average gray scale intensity, its Weber ratio, and its format (gif/jpeg/tiff). If the input image is color, convert it to grayscale before computing the above attributes, and output a message that the input image is in color.
Is there a better way to calculate the Weber Ratio? I have used the following code so far to calculate the mean overall intensity, should I take absolute value |meanval - each point intensity| divided by meanval to get this ratio?:
CvSize dim = cvGetSize(image);
Mat img(image);
Mat grayimg;
imgtype = img.type();
chanl = img.channels();
cout << "The image type is: " << imgtype << endl;
if (chanl == 3)
{
cout << "The original image was in color. Channels = :" << chanl << endl;
cvtColor( img, grayimg, CV_BGR2GRAY );
}
else
{
grayimg = img;
}
Scalar meanval = mean(grayimg,noArray());
"should I take absolute value |meanval - each point intensity| divided by meanval to get this ratio?" - sounds good ;) try and come back.. btw, docs
Auwch
CvSize dim = cvGetSize(image);
you are starting to learn OpenCV then leave every function with a Cv in front alone and jump to its C++ counterside! It will spare you HEAPS of troubles in the long run.Remember, your professor may be on this forum as well. And he probably gave you example code using the C++ interface.