opencv像素操作

1–bit_depth—比特数—代表8bite,16bites,32bites,64bites—举个例子吧–比如说,如
如果你现在创建了一个存储–灰度图片的Mat对象,这个图像的大小为宽100,高100,那么,现在这张
灰度图片中有10000个像素点,它每一个像素点在内存空间所占的空间大小是8bite,8位–所以它对
应的就是CV_8
2–S|U|F–S–代表—signed int—有符号整形
U–代表–unsigned int–无符号整形
F–代表–float———单精度浮点型
3–C—-代表—一张图片的通道数,比如:
1–灰度图片–grayImg—是–单通道图像
2–RGB彩色图像———是–3通道图像
3–带Alph通道的RGB图像–是–4通道图像

如果使用的是uchar则使用Vec3b
如果使用的是float则使用Vec3f

float d = matDepthImage.at(row, col);

p.r = matRGBImage.ptr(row)[col * 3];
p.g = matRGBImage.ptr(row)[col * 3 + 1];
p.b = matRGBImage.ptr(row)[col * 3 + 2];

cv::Mat image = cv::imread(“Q:\test.jpg”, CV_LOAD_IMAGE_COLOR);
for(int k = 0; k < 1000; k++)
{
int i = rand() % image.cols;
int j = rand() % image.rows;
image.at(i, j)[0] = 255;
image.at(i, j)[1] = 255;
image.at(i, j)[2] = 255;
}

cv::Mat_ ima = image;
cv::namedWindow(“Origin image”, cv::WINDOW_NORMAL);
cv::imshow(“Origin image”, image);

for(int k = 0; k < 1000; k++)
{
int i = rand() % ima.cols;
int j = rand() % ima.rows;
ima(i, j)[0] = 255;
ima(i, j)[1] = 255;
ima(i, j)[2] = 255;
}

http://blog.csdn.net/liyuanbhu/article/details/48894973

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值