I go through a bitmap in android and i want to get a the color of each pixel and count it if it has a certain value i.e if it is brown.
I use the following code. The code works but it is extremely slow due to the big number of pixels in the image, which of course I need for correct results.
for(int i = 1; i <= 100; i++){
for(int j = 1; j <= 100; j++) {
int pixel = bitmap.getPixel(i,j);
R1 = Color.red(pixel);
G1 = Color.green(pixel);
B1 = Color.blue(pixel);
if((R1 == 155) && (G1 == 155) && (B1 == 155)) {
countthecolor = countthecolor + 1;
}
}
}