mku*_*use 2 c++ opencv roi mask elementwise-operations
我有cv::Mat
A
,有CV_32F
.但它保存整数值,如1,2 .... 100.我想形成一个大小相同的面具A
.
但是如果A(x,y)不等于5(假设),则掩码必须包含零.如果A(x,y)等于5(假设),则掩码必须包含1.
我想稍后将其用作ROI.
// you will have a much simpler construct,
// this is just for demonstration
Mat_<float> A(3,3); mf << 1,5,5,2,5,5,1,2,3;
// now use a simple MatExpr to get a mask:
Mat mask = (A == 5);
// show results:
cerr << A << endl;
cerr << mask << endl;
------------------------------
[1, 5, 5;
2, 5, 5;
1, 2, 3]
[0, 255, 255;
0, 255, 255;
0, 0, 0]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1893 次 |
最近记录: |