OpenCV for Android – 访问Mat的元素

OpenCV for Android – 访问Mat的元素,第1张

概述在OpenCV4 Android中访问和修改Mat的各个元素的标准方法是什么?另外,BGR的数据格式(我认为是默认值)和灰度等级是什么? 编辑:让我们更具体一点. mat.get(row,col)返回一个double数组.这个数组是什么? What is the standard way to access and modify individual elements of a Mat in Op 在OpenCV4 Android中访问和修改Mat的各个元素的标准方法是什么?另外,BGR的数据格式(我认为是默认值)和灰度等级是什么?
编辑:让我们更具体一点. mat.get(row,col)返回一个double数组.这个数组是什么?解决方法

What is the standard way to access and modify indivIDual elements of a Mat in OpenCV4AndroID?

Mat就是我们在数学中称之为“矩阵”的东西 – 由行和列组成的矩形数组.那些“量”表示在图像Mat的情况下的像素(例如,矩阵的每个元素可以是图像Mat中的每个像素的颜色).从this教程:

07001

in the above image you can see that the mirror of the car is nothing
more than a matrix containing all the intensity values of the pixel
points.

那你怎么去迭代矩阵呢?这个怎么样:

for (int row=0; row<mat.rows(); row++) {  for (int col=0; col<mat.cols(); coL++ ) {    //...do what you want..     //e.g. get the value of the 3rd element of 2nd row     //by mat.get(2,3);  }}

What is the standard way to access and modify indivIDual elements of a Mat in OpenCV4AndroID?

通过使用函数get(x)(y)得到Mat元素的值,其中x是第一个坐标(行号),y是元素的第二个坐标(列号).例如,要获取名为bgrImageMat的BGR图像Mat的第7行的第4个元素,请使用Mat的get方法获取double类型的数组,其大小为3,每个数组元素代表每个Blue,BGR图像格式的绿色和红色通道.

double [] bgrcolor = bgrImageMat.get();

Also,what is the format of the data for BGR (which is the default,I think) and grayscale? edit: Let’s make this more specific. mat.get(row,col) returns a double array. What is in this array?

您可以从网上阅读有关BGR颜色格式和灰度的信息.例如BGR和Grayscale.

简而言之,BGR颜色格式有3个通道:蓝色,绿色和红色.所以当mat是BGR图像时,mat.get(row,col)返回的double数组是一个大小为3的数组,它的每个元素分别包含每个蓝色,绿色和红色通道的值.

同样,灰度格式是1通道颜色格式,因此返回的double将具有1的大小.

总结

以上是内存溢出为你收集整理的OpenCV for Android – 访问Mat的元素全部内容,希望文章能够帮你解决OpenCV for Android – 访问Mat的元素所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1138742.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存