First off, I am not sure if this is the correct stackexchange site to ask this question on, so moderators can feel free to move it.
I am working on an application that identifies an object in an image. For example, let's say that the object is an apple, and the apple can be green, red, or both.
My plan is to create an array the same size as the image, then scan through the image, pixel by pixel, and if the current pixel is within my range of colors (green-ish or red-ish), add a 1 to the corresponding location in the array, else add a 0.
After this scan through the array, I will have an array of 1s and 0s, which will hopefully contain a concentration of 1s, representing the apple.
I am a computer science student, but have yet to take an AI class. So my question is: is this a good way to go about doing this? Or are there more established AI methods (or algorithms) for identifying objects in an image based on color?
EDIT: I should clarify that the problem isn't identifying if the image contains an apple, the problem is identifying where the apple is in the image.