1 | initial version |
This work for me in C++. The one that I learnt from http://answers.opencv.org/question/5395
double cont_meas(const Mat&img)
{
Mat dx, dy;
Sobel(img, dx, CV_32F, 1, 0, 3);
Sobel(img, dy, CV_32F, 0, 1, 3);
magnitude(dx, dy, dx);
return sum(dx)[0];
}
int main(int argc, const char** argv)
{
//my coding
Mat contrast = cont_meas(face) / 1e3; //face is my image name
//my coding
}
2 | No.2 Revision |
This work for me in C++. The one that I learnt from http://answers.opencv.org/question/5395
double cont_meas(const contrast_measure(const Mat&img)
{
Mat dx, dy;
Sobel(img, dx, CV_32F, 1, 0, 3);
Sobel(img, dy, CV_32F, 0, 1, 3);
magnitude(dx, dy, dx);
return sum(dx)[0];
}
int main(int argc, const char** argv)
{
//my coding
Mat contrast = cont_meas(face) std::cout << "contrast=" << contrast_measure(face) / 1e3; 1e3 << std::endl; //face is my image name
//my coding
}