1 | initial version |
The HSV color wheel can be used for color complementary, analogous such as color distance. The H channel from OpenCV BGR2HSV conversion is the Hue, in other words is the angle of the color on the color wheel. You might consider the difference between hues as colors distance without involve darkness or lightness.
Remember that
Using the conversion as @LBerger answer, this should check color distance between pt1 and pt2
Point pt1(x1,y1), p2(x2,y2);
Vec3b hsv1 = hsv.at<Vec3b>(p1); // get HSV values for the pixel. Hue is the 1st in the vector
Vec3b hsv2 = hsv.at<Vec3b>(p2);
d1 = abs(hsv1(0)-hsv2(0)); // absolute distance
d = min(d1,180-d1); // correct distance if cross 0deg . full circle at 180 because of Hue scaling
2 | No.2 Revision |
The HSV color wheel can be used for color complementary, analogous such as color distance. The H channel from OpenCV BGR2HSV conversion is the Hue, in other words is the angle of the color on the color wheel. You might consider the difference between hues as colors distance without involve darkness or lightness.
Remember that
RED -> ROSE = 31°
and RED -> GREEN = 119°
!Using the conversion as @LBerger answer, this should check color distance between pt1 and pt2
Point pt1(x1,y1), p2(x2,y2);
Vec3b hsv1 = hsv.at<Vec3b>(p1); // get HSV values for the pixel. Hue is the 1st in the vector
Vec3b hsv2 = hsv.at<Vec3b>(p2);
d1 = abs(hsv1(0)-hsv2(0)); // absolute distance
d = min(d1,180-d1); // correct distance if cross 0deg . full circle at 180 because of Hue scaling
3 | No.3 Revision |
The HSV color wheel can be used for color complementary, analogous such as color distance. The H channel from OpenCV BGR2HSV conversion is the Hue, in other words is the angle of the color on the color wheel. You might consider the difference between hues as colors distance without involve darkness or lightness.
Remember that
RED -> ROSE = 31°
and RED -> GREEN = 119°
!0..180
(or 0..255 if COLOR_BGR2HSV_FULL is Using the conversion as @LBerger answer, this should check color distance between pt1 and pt2
Point pt1(x1,y1), p2(x2,y2);
Vec3b hsv1 = hsv.at<Vec3b>(p1); // get HSV values for the pixel. Hue is the 1st in the vector
Vec3b hsv2 = hsv.at<Vec3b>(p2);
d1 = abs(hsv1(0)-hsv2(0)); // absolute distance
d = min(d1,180-d1); // correct distance if cross 0deg . full circle at 180 because of Hue scaling