Ask Your Question

Revision history [back]

how to detect if image is grayscale java

i like to know how to detect grayscale image, i tried using

Mat matImages = new Mat();

and then i take bitmap and convert it on that's mat when check the channel i got number 4

public String getChannel(Bitmap bitmap){
    Mat matImages = new Mat();
    Utils.bitmapToMat(bitmap, matImages);
    String value = String.valueOf(matImages.channels());
    return value;

the value i got is 4 when i try to check the channel of images, i like to detect channel with something like if channel = 1 i got grayscale image and when i got channel =3 i got rgb images. But, the only output i got is 4 channel. Can anyone explain it to me how that's can be happening