Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Simply do the following...

  1. First create a mask image using inRange, here you should use your upper and lower threshold.

  2. Now using Mat::copyTo copy your source Mat to a new Mat, with the above mask.

Just see the below code

    Mat src; //Your source image
    Mat mask,dst;
    inRange(src,Scalar(300),Scalar(400),mask);
    src.copyTo(dst,mask); // Your final mat with value between 300 and 400

Simply do the following...

  1. First create a mask image using inRange, here you should use your upper and lower threshold.

  2. Now using Mat::copyTo copy your source Mat to a new Mat, with the above mask.

Just see the below codeCode:

    Mat src; //Your source image
    Mat mask,dst;
    inRange(src,Scalar(300),Scalar(400),mask);
    src.copyTo(dst,mask); // Your final mat with value between 300 and 400

Simply do the following...

  1. First create a mask image using inRange, here you should use your upper and lower threshold.

  2. Now using Mat::copyTo copy your source Mat to a new Mat, with the above mask.

Code:

    Mat src; //Your source image
    Mat mask,dst;
    inRange(src,Scalar(300),Scalar(400),mask);
inRange(src,Scalar(300),Scalar(400),mask); // Create a mask image in the range 300 and 400
    src.copyTo(dst,mask); // Your final mat with value between 300 and 400