Shift Values in Array of ones and zeros
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a 512x512x100 array of ones and zeros. How do i shift the ones in by a certain integer factor in any direction (up,down,right,left) in all 100 images
the code will have to find all the ones in the 512x512x100 array and shift them in that direction without changing the array size. so the ones will be shifted to take over another zero's place and not shift the zeros with it to create a larger/smaller array. Can you please use code that will work for 3D arrays
example:
shift up
0 0 0 0 0
0 0 0 1 0
0 1 1 1 0
0 0 1 0 0
0 0 0 0 0
becomes:
0 0 0 1 0
0 1 1 1 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
And my images don't have any ones in the outermost border of the 512x512 images so that shouldn't be a problem trying to shift a one on the corners
0 comentarios
Respuestas (1)
Matthias Walle
el 30 de Sept. de 2019
Editada: Matthias Walle
el 30 de Sept. de 2019
If you have Image Processing Toolbox this would be the easiest in my opinion
A=[0 0 0 0 0;
0 0 0 1 0;
0 1 1 1 0;
0 0 1 0 0;
0 0 0 0 0];
A_new=imtranslate(A,[0, -1],'OutputView','same');
Or you look at affine transformation in the documentation
0 comentarios
Ver también
Categorías
Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!