opencv:访问像素
来源:互联网 发布:阿里云服务器客服 编辑:程序博客网 时间:2024/05/22 03:41
a.使用指针
#include <opencv.hpp>using namespace cv;using namespace std;int main(){ //指针访问每个像素并赋值 Mat img = imread("001.jpg"); for (int i = 0; i < img.rows; i++) { uchar* data = img.ptr<uchar>(i); // 获取每i行的首地址 for (int j = 0; j < (img.cols*img.channels())/*列数乘以通道数*/; j++) data[j] = 200; } imshow("2", img); waitKey(0); return 0;}
b.通过迭代器
#include <opencv.hpp>using namespace cv;using namespace std;int main(){ //使用迭代器 Mat img = imread("001.jpg"); Mat_<Vec3b>::iterator it = img.begin<Vec3b>(); // 迭代器的初始位置 Mat_<Vec3b>::iterator itend = img.end<Vec3b>(); // 迭代器的终止位置 for (; it != itend; it++) { (*it)[0] = 0; (*it)[2] = 0; (*it)[1] = 255; } imshow("2", img); waitKey(0); return 0;}
c.通过地址计算
#include <opencv.hpp>using namespace cv;using namespace std;int main(){ //动态地址计算 use .at Mat img = imread("001.jpg"); for (int i = 0; i < img.rows; i++) for (int j = 0; j < img.cols; j++) { img.at<Vec3b>(i, j)[0] = 0; img.at<Vec3b>(i, j)[1] = 0; img.at<Vec3b>(i, j)[2] = 244; } imshow("2", img); waitKey(0); return 0;}
阅读全文
0 0
- opencv访问图像像素
- 用迭代器访问像素OPENCV
- opencv访问图像像素
- Opencv访问图像像素
- opencv:访问像素
- OpenCV 2 访问图像像素
- OpenCV之像素访问优化
- OpenCV 访问图像像素点
- Opencv访问像素点方法
- Opencv用指针访问像素
- opencv 访问每个像素点
- 用指针访问像素OPENCV
- OpenCV:访问图像中的像素
- opencv(8)---访问图像像素
- Opencv并行访问图像像素
- opencv访问像素三个方法
- opencv像素的访问(Mat)
- OpenCV访问修改图像的像素值
- opencv:图像的创建和储存
- opencv:创建滑动条
- opencv:基本图形绘制
- HDU 4283 You Are the One(区间DP)
- opencv:鼠标操作
- opencv:访问像素
- opencv:通过滑动条调节亮度和对比度
- opencv:傅里叶变换
- opencv:图像的掩码操作
- opencv:直方图操作
- C++:lambda表达式
- 省略号和可变参数模板
- plupload上传插件多图片上传操作
- static-静态类型