reshape matrix
I can achieve the following:
with the reshape command quite easy:
Mat a = Mat(5,1, CV_32FC3); //a is 5x1, 3 channels
Mat b = a.reshape(1); //b is 5x3, 1 channel
How about the opposite:
I was also trying with .reshape
but I couldn't manage it. (bear with me but my brain is quite fried at the moment)
Update:
I have the following image where its channel is in one big image:
so what I want to do is take each part of the image (we know the dimensions) and put it in a different channel:
in order to get the final image:
I could do it with many ways but I thought that there should be a simple way to do it like using .reshape
or something similar. Therefore, I tried with the .reshape
and what @LorenaGdL suggested or .reshape(3, image.rows)
but I do not get the result I want grrrrrr, actually I am not sure if I can do that with the reshape. (by the way at the end I will be seeing nightmares with pink panthers.....:-p )
reshape(3)
should do the trick. btw, it's friday, stop working ;)that's correct that was what I was trying. But check my update to see what I want to achieve.
Yep, it doesn't work because each consecutive column goes to a different channel. This is what you want:
@LorenaGdL thanks that indeed would solve my problem. But as I said would be able to achieve the same in a neater way. By the way make your comment an answer in order to accept it ;-).