I tried to find a specific pixel with rgb color but the same pixel have different colors on different devices, on python with pyautogui for image search i can use confidence to handle that.
Anyone know a solution for that? I would be very grateful if someone could find a solution.
From my comments:
"Confidence" is just color values within a certain tolerance range. In other words, take the Math.Abs(actual value - desired value) and see if that number is less than a certain tolerance (like within 10-15). If all channels are within tolerance, then you are "confident" it is the "same color".
Here's a quick example:
public static bool colorConfidence(Color targetColor, Color actualColor, int confidence) {
int deltaA = Math.Abs(targetColor.A - actualColor.A);
int deltaR = Math.Abs(targetColor.R - actualColor.R);
int deltaG = Math.Abs(targetColor.G - actualColor.G);
int deltaB = Math.Abs(targetColor.B - actualColor.B);
return (deltaA <= confidence) && (deltaR <= confidence) && (deltaG <= confidence) && (deltaB <= confidence);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.