mat和matND有什么区别? [英] What is the difference between mat and matND?

查看:141
本文介绍了mat和matND有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从二进制掩码中提取数据.一切顺利,但是更改为python将导致数据移动几个像素.够了,所以我找不到中心.但是保存图像将足够早地在正确的位置显示像素

I am trying to extract data from a binary mask. All goes well but changing to python will cause the data to shift a few pixels. It is enough so I cannot find the center. However saving the image will oldly enough display the pixels at the correct location

这是我的代码.我基本上创建了一个普通的垫子用作输出.但是,会根据文档输出matnd

Here is my code. I basically create a normal mat to use as output. However a matnd is outputed according to the docs

我是否正确提取数据?如果是这样,请告诉我.我试图找到沿中心给定的点的中心.我不愿意让我的数据转移.

Am I extracting the data properly? If so tell me. I am trying to find the center given points along the center. I kidda dont want my data to be shifted.

import cv2.cv as cv

def main():

   imgColor = cv.LoadImage(OPTICIMAGE, cv.CV_LOAD_IMAGE_COLOR)
   center, radius = centerandradus(imgColor)

def centerandradus(cvImg, ColorLower=None,ColorUpper=None):
   lowerBound = cv.Scalar(130, 0, 130);
   upperBound = cv.Scalar(171, 80, 171);
   size =  cv.GetSize(cvImg)

   output = cv.CreateMat(size[0],size[1],cv.CV_8UC1)
   cv.InRangeS(cvImg, lowerBound, upperBound,output)
   mask = np.asarray( output[:,:] )
   x,y = np.nonzero(mask)
   x, y = np.array(x),np.array(y)
   h,k  =  centerEstimate(x,y)
   return np.array([h,k]), radius

def centerEstimate(xList,yList):
   x_m = np.mean( np.r_[xList])
   y_m = np.mean( np.r_[yList])
   return x_m, y_m

我认为这是matND的问题,因为当我尝试打印数据时,我注意到数据已经转移.如果您需要更多信息,请询问

I think it the problem with matND, since i notice the data is already shifted when I try to print out the data. If you need any more information please ask

谢谢您的时间

推荐答案

Mat和MatND之间似乎没有更多区别. MatND现在已过时.

It seems there is no more differences between Mat and MatND. MatND is now obsolete.

通过查看opencv2/core.hpp(版本2.4.8):

By looking at opencv2/core.hpp (version 2.4.8):

typedef Mat MatND;

这篇关于mat和matND有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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