简体   繁体   中英

Reshape in emgu cv

I'm trying to reshape a matrix into a vector in Emgu CV in C#. The Reshape function of Emgu works completely correct when it is called for the first time in the code...but after that, it seems like it does nothing! Do you have any idea why is that? here is the code:

First usage

myImg = new Image<Bgr, Byte>(a);
myImg2 = myImg.Convert<Gray, Byte>();

Matrix<float> tmp = new Matrix<float>(myImg2.Height, myImg2.Width);
CvInvoke.cvConvert(myImg2, tmp);
tmp = tmp.Transpose();
Matrix<float> reshaped_vect = new Matrix<float>(myImg2.Height * myImg2.Width, 1);
reshaped_vect = tmp.Reshape(1, myImg2.Height * myImg2.Width);

Second usage

mySketch = new Image<Bgr, Byte>(a);
mySketch2 = mySketch.Convert<Gray, Byte>();

Matrix<float> tmp_sketch = new Matrix<float>(mySketch2.Height, mySketch2.Width);
CvInvoke.cvConvert(mySketch2, tmp_sketch);
tmp_sketch = tmp_sketch.Transpose();
Matrix<float> sketch_reshaped_vect = new Matrix<float>(mySketch2.Height * mySketch2.Width, 1);
sketch_reshaped_vect = tmp_sketch.Reshape(1, mySketch2.Height * mySketch2.Width);

Thanks for Ur helps in advance.

好吧,似乎是我误会了……显然Emgu结构的“数组”元素(系统提供的)没有提供正确的信息,因此应该检查MCvMat数据...在我的情况下,“数组”元素重塑后,矩阵的大小为144 * 151(完全不正确),但MCvMat数据显示其行数为21744,列数为1(正确)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM