samedi 28 mars 2015

Take elements that match from a pair of arrays (C++/OpenCV)


I'm using an OpenCV function that takes matching elements from two single channel matrices and gives you a resulting array with only that element. The function is called compare



cv::compare(maskMat, cv::GC_FGD, result, cv::CMP_EQ);


maskMat is my matrix containing any value from 0, 1, 2, or 3.


cv::GC_FGD is just a matrix with each element equal to 1.


cv::CMP_EQ is a flag that checks if the two elements are equal.


What I'd also like to take any values of cv::GC_PR_FGD, which is 3. So basically, I wish I do something like (cv::GC_FGD || cv::GC_PR_FGD), taking any element whose value is 1 or 3 for my new resulting matrix.


Is there a simple way to do this? Thanks




Aucun commentaire:

Enregistrer un commentaire