OpenCV function similar to matlab's “find”

后端 未结 2 808
长发绾君心
长发绾君心 2021-01-12 07:03

I am looking for a function in openCV to help me make masks of images.

for example in MATLAB:

B(A<1)=0;

or

B=zeros(size(A));

B(A==

2条回答
  •  长发绾君心
    2021-01-12 07:48

    OpenCV C++ supports the following syntax you might find convenient in creating masks:

    Mat B= A > 1;//B(A<1)=0
    

    or

    Mat B = A==10;
    B *= c;
    

    which should be equivalent to:

    B=zeros(size(A));
    B(A==10)=c;
    

    You can also use compare(). See the following OpenCV Documentation.

提交回复
热议问题