I have an image that I try to cycle with finding pixels position.
So if it's layer 1000px x 1000px then I see this image (I just show fragment of image, I hope it will be enough for understanding):
But if I resize my image for example to 300px x 300px it looks like this (also just show fragment of image):
So as you can see after down sizing we have an extra pixels not just purple and green, but something like gradient between two colors. But I write program that try to figure out pixels position for green and for purple, so I just use 2 colors to finding appropriate position. Without resizing my program detect it well but after resizing here is an issue with detecting appropriate position of color.
In photoshop if you use for example tolerance 100 and uncheck anti aliasing check mark it works good and found right position even with gradient.
How can implement tolerance in my code. So for example I have color green that I need to compare with all tolerance colors. And if the pixel 100 percents tolerant to green, program should suppose that the pixel connected to the green color.
What I mean. For example I have RGB (0, 255, 0) color and I want to find all tolerance to it. In this case for the green.
Or for example if I have RGB (100, 255, 50) then I need to find all tolerance colors for it.
I suppose here is should be an range that I can set and the colors to check tolerance color.
As I additional I use raw data to cycle all pixels. So I can get RGBA:
float red = (rawData[byteIndex] * 1.0) / 255.0;
float green = (rawData[byteIndex + 1] * 1.0) / 255.0;
float blue = (rawData[byteIndex + 2] * 1.0) / 255.0;
float alpha = (rawData[byteIndex + 3] * 1.0) / 255.0;
So detection solid color work perfect but I have question how to recognize that gradient and decide if the color connected to green or to purple piece.
Here is also my previous question how cycle pixel.