I am a beginner in image processing in Android. I am trying to build an application in which I need to separate the color channels from an image and perform calculations on them.
I have successfully extracted RGB channels from the image. I am using the code fragment given in these tutorials: https://xjaphx.wordpress.com/2011/06/21/image-processing-filter-color-channels/
Here is the code fragment:
public static Bitmap doColorFilter(Bitmap src, double red, double green, double blue) {
int width = src.getWidth();
int height = src.getHeight();
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
int A, R, G, B;
int pixel;
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
pixel = src.getPixel(x, y);
A = Color.alpha(pixel);
R = (int)(Color.red(pixel) * red);
G = (int)(Color.green(pixel) * green);
B = (int)(Color.blue(pixel) * blue);
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
}
return bmOut;
}
}
But I am unable to figure out the way to extract NIR channel from the image. My aim to extract this NIR channel is because I need to apply the NDVI (Normalised Difference Vegetation Index) indicator on the image for analysis.
Also, in this piece of code, brute-force approach has been used by running multiple for loops. Thus, the program becomes really slow with the complexity being - O(width*height). What would be an efficient way for computation of these separate channels?
Screen shot of image properties:
Kindly help me with this issue.