OpenCV cvSet2d .....这是做什么的 [英] OpenCV cvSet2d.....what does this do

查看:135
本文介绍了OpenCV cvSet2d .....这是做什么的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在访问Pixel Data时,我正在浏览OpenCV页面中的一些代码

I was browsing over some code in the OpenCV page when it came to accessing Pixel Data

IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,3);
CvScalar s;
s=cvGet2D(img,i,j); // get the (i,j) pixel value
printf("B=%f, G=%f, R=%f\n",s.val[0],s.val[1],s.val[2]);
s.val[0]=111;
s.val[1]=111;
s.val[2]=111;
cvSet2D(img,i,j,s); // set the (i,j) pixel value

我做了类似的事情,但是我使用提供的模板类来访问像素数据……无论如何,我不确定我是否了解s.val [0] = 111 .... etc? 如果s.val [0]包含B值,那么s.val [0] = 111到底在做什么?是将其设置为黑色吗?........我不知道该怎么办?

I had done something similar, but I used the Template Class provided to access pixel data......anyways Im not sure I understand the part s.val[0]=111....etc? if s.val[0] contains the B value, what exactly is s.val[0]=111 doing? is it setting it to black?........I dont understand exactly what it's supposed to be?

我曾经习惯CVscalars等,但我不理解这种格式?具体是111是什么意思?

Im used to CVscalars and such but I dont understand this format? Specifically what 111 means?

谢谢

推荐答案

cvSet2D(img,i,j,s)函数不能访问第(i,j)个像素.它访问第(j,i)个像素.这是因为图像以矩阵形式存储-您需要先指定行(Y坐标),然后再指定列(X坐标).

The cvSet2D(img, i, j, s) functions to not access the (i,j)th pixel. It accesses the (j,i)th pixel. That is because images are stored as a matrix - you need to specify the row first (the Y coordinate) and then the column (the X coordinate).

您不是尝试使用cvGet/Set函数,而是尝试使用使用指向访问图像中的数据?

Instead of using the cvGet/Set functions, did you try using pointers to access data within an image?

这篇关于OpenCV cvSet2d .....这是做什么的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆