I have to implement a function in an Android application that return to me the color in a certain area of a image.
What I need is different from what the
getpixel() - Returns the color at the specified location
because I need to determine the color in a given area (eg. in a 3x3 px radius).
To make the idea briefly explain the operating principle of the app:
In an activity a picture of a car is shown through a TileView; each part (bonnet, bumper, wheel, etc.) is colored differently (grayscale), while the edge of the car is black.
At each touch I go to sample the color at the x, y coordinate, compare it with a list of colors present in a db and finally return the name of the component.
Everything works perfectly except when I approach the edge of the image (black), this being a JPG the edge tends to be blurred and the colors sampled can be "wrong" (belonging to other components).
What is the best solution to do this ? Is it my idea correct ?