I translated some matlab code in C ++ using opencv. I want to get the values ββof a matrix that satisfies the condition. I created a mask for this, and when I apply it to the original matrix, I get the same size of the original matrix, but with 0 values ββthat are not in the mask. But my question is how to get only values ββother than zero in the matrix and assign them to another matrix.
My matlab code is:
for i= 1:size(no,1) mask= labels==i; op = orig(mask, :); //op only contains the values from the orig matrix which are in the mask. So orig size and op size is not the same ..... end
Now I have a C ++ translation:
for (int i=0; i<n.rows; i++) { Mat mask; compare(labels,i,mask,CMP_EQ); Mat op; orig.copyTo(op,mask);
So, how can I create a matrix that has only values ββthat match the mask?
c ++ opencv
user1583647
source share