Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 150 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 150 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), greenMask); // try

    Mat res = new Mat();
    Mat NotGreenMask = new Mat();
    bitwise_not(greenMask, NotGreenMask);
    pyrDown.copyTo(res, greenMask);


    Bitmap imageMatched = Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 150 120 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), greenMask); // try

    Mat res = new Mat();
    Mat NotGreenMask = new Mat();
    bitwise_not(greenMask, NotGreenMask);
    pyrDown.copyTo(res, greenMask);


    Bitmap imageMatched = Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 120 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), greenMask); yellowMask ); // try

    Mat res = new Mat();
    Mat NotGreenMask = NotYellowMask= new Mat();
    bitwise_not(greenMask, NotGreenMask);
NotYellowMask);
    pyrDown.copyTo(res, greenMask);
yellowMask );


    Bitmap imageMatched = Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 120 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), yellowMask ); // try

    Mat res = new Mat();
    Mat NotYellowMask= new Mat();
    bitwise_not(greenMask, NotYellowMask);
    pyrDown.copyTo(res, yellowMask );


    Bitmap imageMatched = Bitmap.createBitmap(res.cols(), =Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}
click to hide/show revision 6
retagged

updated 2019-07-29 13:02:28 -0600

berak gravatar image

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 120 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), yellowMask ); // try

    Mat res = new Mat();
    Mat NotYellowMask= new Mat();
    bitwise_not(greenMask, NotYellowMask);
    pyrDown.copyTo(res, yellowMask );


    Bitmap imageMatched =Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}
click to hide/show revision 7
retagged

updated 2019-07-29 13:08:44 -0600

berak gravatar image

HSV values in openCV

Hi,

I've tried to isolate yellow-orange-ish color from an image, using inRange function.

I've used an online color picker (https://pinetools.com/image-color-picker)

and than tried to isolate by the values it gave me - even with half of Hue value.

but it failed.

The Hue value that the picker gave me is 30 (tried half - also incorrect) The true value is around 120 - I know this because I've started to 'play' with the value, until I get the desired result.

for future reference, What is wrong here ? The online picker ?

code :

public void colorMask(View view)
{
    //Image Input :
    Bitmap one =
            drawableToBitmap(getResources().getDrawable(R.drawable.dsc_1250, this.getTheme()));
    Mat img1 = new Mat();
    Utils.bitmapToMat(one, img1, true);// moving one to img1 Mat structure.
    //one.recycle(); //Undefined behaviour ..
    System.gc();


    // downsize the image.
    Mat pyrDown = new Mat();
    Imgproc.resize(img1, pyrDown, new Size(img1.cols() / 4, img1.rows() / 4));
    img1.release();

    Mat hsvImg = new Mat();
    cvtColor(pyrDown, hsvImg, COLOR_BGR2HSV);


    Mat yellowMask = new Mat();
    Mat greenMask = new Mat();



    inRange(hsvImg, new Scalar(100, 41, 40), new Scalar(130, 255, 255), yellowMask ); // try

    Mat res = new Mat();
    Mat NotYellowMask= new Mat();
    bitwise_not(greenMask, NotYellowMask);
    pyrDown.copyTo(res, yellowMask );


    Bitmap imageMatched =Bitmap.createBitmap(res.cols(), res.rows(), Bitmap.Config.RGB_565);
    Utils.matToBitmap(res, imageMatched);
    imageViewMy.setImageBitmap(imageMatched);


}