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.
-
$\begingroup$ If you will convert your image into HSV space, it would be more easy to classify objects based on their colors. $\endgroup$Eddy_Em– Eddy_Em2013年04月22日 16:12:25 +00:00Commented Apr 22, 2013 at 16:12
-
$\begingroup$ Do you think HSV would be better than HSL ? (I was planning on using HSL). $\endgroup$TylerAndFriends– TylerAndFriends2013年04月22日 16:19:11 +00:00Commented Apr 22, 2013 at 16:19
-
$\begingroup$ There's no much difference between them. $\endgroup$Eddy_Em– Eddy_Em2013年04月22日 16:22:17 +00:00Commented Apr 22, 2013 at 16:22
1 Answer 1
The general class for this problem is Template matching. The most common approach is performing a cross correlation of the template, in your example an apple, and an image which may contain the template.
A Google search for "template matching fast normalized cross correlation" will bring up some literature that should be helpful.
Explore related questions
See similar questions with these tags.