and 位与
<p>[TOC]</p>
<h5>简要描述</h5>
<ul>
<li>位与,可增强对比度,使得图像轮廓更清晰。可掩码处理图像、可过滤不需要的部分
位与真值表:
1 1 1
1 0 0
0 1 0
0 0 0</li>
</ul>
<h5>参数</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">mat1</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">mat</td>
<td>参与计算的mat对象。</td>
</tr>
<tr>
<td style="text-align: left;">mat2</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">mat</td>
<td>参与计算的mat对象。</td>
</tr>
</tbody>
</table>
<h5>返回参数说明</h5>
<p>mat | null</p>
<h5>示例 通过AND运算分离RGB通道</h5>
<pre><code class="language-java"> //加载图片
var mat=cvImg.loadFromFile("/sdcard/Pictures/t6.png");
//创建另一个运行对象
var mat_mask=cvImg.zeros(cvImg.getWidth(mat),cvImg.getHeight(mat),cvImg.getType(mat),[255,0,0,255]);
//and计算
var mat_and=cvImg.and(mat,mat_mask);
//保存到文件
cvImg.toFile(mat_and,"/sdcard/Pictures/tem1.jpg");
//释放
cvImg.release(mat);
cvImg.release(mat_mask);
cvImg.release(mat_and);</code></pre>
<p>原图
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=6d8529de83d56d32a86c0df403b23d3f&file=file.png" alt="" /></p>
<p>结果(需要自己调节颜色值)
红通道
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=afb1b5591de04207763e9e50b9122c55&file=file.jpg" alt="" />
绿通道
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=e1e4a5e9c80e6c55ef3ddb9953be4040&file=file.jpg" alt="" />
蓝通道
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=c22fa098976469ad9f6e9ba0e681fdc1&file=file.jpg" alt="" /></p>
<p>红+蓝
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=6045a4bcc2de58a2f921b27084ac8c43&file=file.jpg" alt="" /></p>
<p>红+绿
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=6a5eefe8d1d10ded139aec17acdfdc00&file=file.jpg" alt="" /></p>
<p>蓝+绿
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=bfe2f277102deb915ed3bb87f52e241b&file=file.jpg" alt="" /></p>