OpenCV指针、迭代器

1、cv::Ptr
https://docs.opencv.org/3.4/d0/de7/structcv_1_1Ptr.html
A Ptr pretends to be a pointer to an object of type T. Unlike an ordinary pointer, however, the object will be automatically cleaned up once all Ptr instances pointing to it are destroyed.
2、迭代器
Mat img = Mat::eye(3,3,CV_8U);
cout<<img<<endl;
Mat_::iterator it = img.begin();
Mat_::iterator itend = img.end();//end是最后一行最后一列的再后一位
for(; it != itend; ++it)
{
*it = *it * 2 + 1;
cout<<(int)*it<<endl;
}

在这里插入图片描述
Mat img = Mat::eye(3,3,CV_8UC3);
cout<<img<<endl;
MatIterator_ it = img.begin();
MatIterator_ itend = img.end();//end是最后一行最后一列的再后一位

for(; it != itend; ++it)
{
    (*it)[1] = (*it)[1] * 2 + 3;
    //cout<<(int)(*it)<<endl;
}
cout << img<<endl;

在这里插入图片描述
In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the Vec3b name. To access the n-th sub column we use simple operator[] access. It’s important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple uchar iterator you’ll be able to access only the blue channel values.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值