Matrix Manipulation/Shifting
Mostrar comentarios más antiguos
I am trying to shift a 12x3 matrix using imwarp function. I know there are other ways to do this, but for future work it must be done with imwarp function though I am runnning into problems. The code:
%Shifting of a matrix
%Definng a matrix:
Matrix=[1 2 3;4 5 6;7 8 9;10 11 12;13 14 15; 16 17 18; 19 20 21;22 23 24;25 26 27;28 29 30;31 32 33; 34 35 36];
%Defining moving points and fixed points
movingp=[1,1;1,2;1,3;2,1;2,2;2,3;3,1;3,2;3,3;10,1;10,2;10,3;11,1;11,2;11,3;12,1;12,2;12,3];
fixedp=[4,1;4,2;4,3;5,1;5,2;5,3;6,1;6,2;6,3;7,1;7,2;7,3;8,1;8,2;8,3;9,1;9,2;9,3];
%Defining twarp for imwarp and running function
pleasework=fitgeotrans(movingp,fixedp,'polynomial',2);
A=imwarp(Matrix,pleasework)
I am trying to shift the top three rows and the bottom three rows of the matrix to the right by one unit with respect to the center 6 rows:
For example for the top six rows, it should look something like this:
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
31 32 33
34 35 36
I am assuming I need to better define the moving points to include a function which does the movement. I know there are other, better ways to do the matrix shifting, though this function is necessary for future work of mine so I am mostly trying to get a better understanding of how to use it. I just need help finishing the code which will shift the top 3 and bottom 3 rows to the right with respect to the center 6 rows. The purpose if for image alterations, meaning the fitgeotrans and imwarp functions should not change and are crucial. I'm assuming the function will warp the 'image' to correct for the matrix expanding and shifting of matrix values.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Computer Vision with Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


