0
votes

Can someone help me with this crazy algorithm please? I need to find some exact color (R,G,B model) pixel in pictures. And I need one algorithm for more pictures. I need to find one of 3 good colors against 9 bad colors in every picture with one algorithm. Do you think it's possible?

First picture

In picture you can see 3 good colors (R,G,B model) (yellow background) and 9 bad colors (green background). And I need an algorithm to chose one of the good colors when I will compare all these colors.

I have got 3 this pictures with different good and bad colors. And I need to find one algorithm, for all these pictures, that will choose one from good colors before all of bad colors in specific picture.

One algorithm, that when I use it for first set of numbers will chose each one of good (yellow) colors. and when I apply this same algorithm for second picture, it will choose one of good (yellow) colors from set of numbers for picture two and same algorithm for third picture (set of numbers).

You can find numbers in written form in xlsx file here: xlsx file

Do you think it's possible?

EDIT: i make some change in picture 3 ... and i upload new xlsx file

I compare individual pixel in bmp file something like

for (int x = 0; x < img.Width; x++)
        {
            for (int y = 0; y < img.Height; y++)
            {
                GetPixel(x, y).Color
            }
        }

and i get 3 numbers (x, y).R, (x, y).G, (x, y).B

And im finding most red pixels (there is red dot in picture) but with different lighting this red pixels can have different levels of R,G,B model. In picture 3 you can see that when is R level bigger then G and B lvl

if ((R-30>G) && (R-30>B))

it will find me only good colors (yellow background) in picture 3. But when in picture arent this colors like in picture 2.. i need use something else to find good color. But i need to combine these conditions to one algorithm that when i use for picture 3 it will find me good colors (yellow background) for this picture and when i use it on second picture it will find my good pixels for second picture...

EDIT2:

enter image description hereenter image description hereenter image description here

So here are 3 pictures. In pictures is one red thing (in yellow circle) but with different lighting. And interference (green circle). So pixels in yellow circle have got RGB model like are numbers with yellow bacground (good color) and in green circle have got RGB model like are numbers with green bacground (bad color).

1
Prepare for the imminent flood of down votes. You need to add more content to your question. Show us what code you have.alvonellos
i dont have any code for this.. i think im not so smart for this.. therefore I ask herePalike
So, this is a C# program you're trying to write? Or is this excel? You have not made any effort at all?alvonellos

1 Answers

0
votes

How is the data represented in your program?

I'm just going to assume that these values are represented as an integer array p, with three elements. Make two methods:

  1. concatenate(int[] p) { string.Join("", p); }
  2. comparergbs(string p, int[][] rgbs) { /* you fill this part in */ }

Then since your values that are [111,222,333] become "111222333", you can compare them using just a string representation to determine membership.

Edit

Or, if you're really clever with the code, you can pack the set of integer values into a 32 bit integer like @paddy suggested.