SubImage(HObject imageMinuend, HObject imageSubtrahend, out HObject imageSub, HTuple mult, HTuple add)
公式
x1=imageMinuend此行此列的灰度
x2=imageSubtrahend此行此列的灰度
则imageSub此行此列的灰度为;(x1-x2)*mult+add
溢出裁剪
以byte图为例,小于0,为0;大于255,为255
源码一
private void butTemp_Click(object sender, EventArgs e)
{
var img1 = WHCSHalCon.Base.CreateByteImage(new byte[] { 0 }, 1);
var img2 = WHCSHalCon.Base.CreateByteImage(new byte[] { 255 }, 1);
HObject img3;
HOperatorSet.SubImage(img2, img1, out img3, 2, 0);
byte[] b1 = WHCSHalCon.Base.ByteImageToArr(img3);
}
结果为255
源码二
private void butTemp_Click(object sender, EventArgs e)
{
var img1 = WHCSHalCon.Base.CreateByteImage(new byte[] { 0 }, 1);
var img2 = WHCSHalCon.Base.CreateByteImage(new byte[] { 255 }, 1);
HObject img3;
HOperatorSet.SubImage(img1, img2, out img3, 2, 0);
byte[] b1 = WHCSHalCon.Base.ByteImageToArr(img3);
}
结果为0
注意事项
imageMinuend和imageSubtrahend的CountObj和CountChannel必须相同。否则会崩溃文章来源:https://www.toymoban.com/news/detail-702269.html
测试环境
Win7 VS2022 Halcon12文章来源地址https://www.toymoban.com/news/detail-702269.html
到了这里,关于C# halcon SubImage的使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!