Q:

How to get the color of a pixel?

I have to get the most dominant (most common) color in an image, using Android Studio and OpenCV, so I'm trying to iterate over each pixel in the image and get its color. I then count how many pixels of each color (red, green, blue, yellow, other) are in the image and get the maximum color (the one with the most pixels) and print its first letter (r - red, g - green, y - yellow, b - blue, x - other).
My code works, but it doesn't produce the wanted output. Here's how I do it:
            int color = imageBitmap.getPixel(j, i);

            if(color == Color.RED){
                red++;
            }else if(color == Color.GREEN){
                green++;
            }else if(color == Color.YELLOW){
                yellow++;
            }else if(color == Color.BLUE){
                blue++;
            }else{
                other++;
            }

Also, I've tried this (first convert RGB image into HSV), but it doesn't produce the wanted output too:
            if(hue > 340 || hue < 20){
                red++;
            }
            else if(hue > 20 && hue < 45){
                orange++;
            }
            else if(hue > 45 && hue < 70){
                yellow++;
            }
            else if(hue > 90 && hue < 140){
                green++;
            }
            else{
                other++;
            }

Any ideas how can I solve this problem?
SOLUTION: I finally did it, here's my solution (thanks to Shiva kumar):
    int red = 0;
    int green = 0;
    int yellow = 0;
    int orange = 0;
    int other = 0;

    Bitmap newBitmap = Bitmap.createScaledBitmap(imageBitmap, 1, 1, true);
    final int color = newBitmap.getPixel(0, 0);
    newBitmap.recycle();

    int redValue = Color.red(color);
    int greenValue = Color.green(color);
    int blueValue = Color.blue(color);

    float[] hsv = new float[3];
    Color.RGBToHSV(redValue, greenValue, blueValue, hsv);

    float hue = hsv[0];
    float saturation = hsv[1];
    float value = hsv[2];

    if(hue > 340 || hue < 20){
        red++;
    }
    else if(hue > 20 && hue < 45){
        orange++;
    }
    else if(hue > 45 && hue < 70){
        yellow++;
    }
    else if(hue > 90 && hue < 140){
        green++;
    }
    else{
        other++;
    }

A:

int pixel = bitmap.getPixel(x,y);
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
With that rgb values try to get the color!!

