0

Hi all I am developing an application where in i'm extracting red colored apple from the image. I have thresholded the image [cvInRangeS(imgHSV, cvScalar(160,100,40), cvScalar(180,256,256), imgThresh);] so that i'm able to get a binary mask of the apple. How can i combine that mask along with the original image, so that i will extract only the apple part from the original image...?

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174

2 Answers2

0

if your image is in HSV color Model try to convert it to RGB and than split it in 3 matrix R, G and B and run the threshold only on R channel you kann use the threshold (use the threshold Binray) result as mask with the copyTo. I hope this help!

Engine
  • 5,360
  • 18
  • 84
  • 162
0

You can use Mat::copyTo():

inputMat.copyTo(outputMat, maskMat);
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174