3
votes

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:

Image

Camera

Advance photo

Kindly help me with this issue.

1
there is no such thing as NIR channel.Piglet
NIR is a spectral band in a multi-spectral image. I have to apply this formula for NDVI: (NIR - Red) / (NIR + Red). So I assumed that we would be able to extract NIR from an image as well. Am I on a wrong path? @PigletHarsh Mehta
and what format is this multi-spectral image? how do you create it?Piglet
We are not creating the image. It is taken by a high-end camera in JPEG format. @PigletHarsh Mehta
@HarshMehta just read the manufacturer website, it is all there... even ImageJ examplesPiglet

1 Answers

2
votes

From the manufacturers website:

NDVI Red + NIR

This camera has a dual-band filter that captured reflected Red light in the RGB sensor's red channel and reflected Near Infrared light in the RGB sensor's blue channel. You can thus use this single camera to compute the NDVI indice, though the contrast in the resulting index image will not be as "accurate" as using the separate Red and NIR camera models.