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());