Can I define or change the direction of 'reshape'?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Salad Box
am 31 Jan. 2023
Kommentiert: Salad Box
am 1 Feb. 2023
Hi,
I have a sample image (below).
Generally if I use 'reshape' to change the RGB from n by m by 3 to n*m by 3, the reshape process goes vertically (in the direction of A), meaning the pixel at 1st row and 1st column is followed by the pixel at 2nd row and 1st column.
How can I define 'reshape' (or whether it is possible) so that the reshape goes horizontally (in the direction of B), meaning the pixel at 1st row and 1st column is followed by the pixel at 1st row and 2nd column?
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 31 Jan. 2023
Bearbeitet: John D'Errico
am 31 Jan. 2023
No. You cannot do so. You cannnot change how reshape works.
HOWEVER. Nothing stops you from changing that afterwards. For example...
V = 1:16;
Vr = reshape(V,[4 4])
So down the columns. That is how reshape works. And you cannot change it.
Vr = Vr'
But now acrross the rows.
You can also use permute for arrays in higher dimensions.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!