I have two objects cv::Scalar, and I want to calculate the color difference.
I came up with this code:
cv::Scalar a(255, 128, 255);
cv::Scalar b(100, 100, 100);
cv::Scalar d = b - a;
double distance = sqrtl(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
It looks pretty awkward. Is there an easier way to express this or another metric, for example. a way to express a point product d*d, or a way of saying a direct distance from two cv::Scalaror cv::Vec4ito which it can be added afaik?
source
share