Ask Your Question

Revision history [back]

mat.reshape giving me an offset in result

Hi,

I have been struggling with the reshape function. I have a big matrix that I convert into a 1 column mat. When I convert the I column back to the original size, the image has an offset and doesn't fit the original no more.

Here my code more or less (PS. I have simplified it to this that demonstrates my problem):

vb.net code

frame = my_Original_mat Dim SingleColumn As Mat = frame.Clone.Reshape(0, frame.Cols * frame.Rows) 'makes it a 1 column mat

Dim Mymat As New Mat

SingleColumn.Col(0).CopyTo(Mymat) 'get the single column back out again

Dim OriginalShape As Mat = Mymat.Reshape(0, frame.Rows))

CvInvoke.Imshow("Original ", frame.Clone)

CvInvoke.Imshow("OriginalShape ", OriginalShape .Clone)

image description

image description

Sorry for the bad images...but I think you can see that the reshaped one is now shifted down. What am I doing wrong? I need a way to simply extract 1 column at the time from a build up matrix (I concat into this matrix). Let me know if anything else is needed and thanks for the help in advance.

mat.reshape giving me an offset in result

Hi,

I have been struggling with the reshape function. I have a big matrix that I convert into a 1 column mat. When I convert the I column back to the original size, the image has an offset and doesn't fit the original no more.

Here my code more or less (PS. I have simplified it to this that demonstrates my problem):

vb.net codecode:

frame = my_Original_mat
Dim SingleColumn As Mat = frame.Clone.Reshape(0, frame.Cols * frame.Rows) 'makes it a 1 column mat

mat Dim Mymat As New Mat

Mat SingleColumn.Col(0).CopyTo(Mymat) 'get the single column back out again

again Dim OriginalShape As Mat = Mymat.Reshape(0, frame.Rows))

frame.Rows)) CvInvoke.Imshow("Original ", frame.Clone)

frame.Clone) CvInvoke.Imshow("OriginalShape ", OriginalShape .Clone)

image description

image description

.Clone) ![image description](/upfiles/1571063685618789.png) ![image description](/upfiles/15710637115395028.png)

Sorry for the bad images...but I think you can see that the reshaped one is now shifted down. What am I doing wrong? I need a way to simply extract 1 column at the time from a build up matrix (I concat into this matrix). Let me know if anything else is needed and thanks for the help in advance.

mat.reshape giving me an offset in result

Hi,

I have been struggling with the reshape function. I have a big matrix that I convert into a 1 column mat. When I convert the I column back to the original size, the image has an offset and doesn't fit the original no more.

Here my code more or less (PS. I have simplified it to this that demonstrates my problem):

vb.net code:

frame = my_Original_mat 
Dim SingleColumn As Mat = frame.Clone.Reshape(0, frame.Cols * frame.Rows)  'makes it a 1 column mat

Dim Mymat As New Mat

 SingleColumn.Col(0).CopyTo(Mymat)   'get the single column back out again

 Dim OriginalShape As Mat = Mymat.Reshape(0, frame.Rows))

CvInvoke.Imshow("Original ", frame.Clone)

CvInvoke.Imshow("OriginalShape ", OriginalShape .Clone)

![image description](/upfiles/1571063685618789.png)

![image description](/upfiles/15710637115395028.png)

image description

image description

Sorry for the bad images...but I think you can see that the reshaped one is now shifted down. What am I doing wrong? I need a way to simply extract 1 column at the time from a build up matrix (I concat into this matrix). Let me know if anything else is needed and thanks for the help in advance.