Borrar filtros
Borrar filtros

How to reorder pixels of a 3D matrix in the Z direction?

1 visualización (últimos 30 días)
RB
RB el 6 de Mzo. de 2018
Hello, currently I have 9 .txt files that are loaded into matlab and shaped into a 3-dimensional matrix using the following code:
a = load('0.txt'); b = load('1.txt'); c = load('2.txt'); d = load('3.txt'); e = load('4.txt'); f = load('5.txt'); g = load('6.txt'); h = load('7.txt'); i = load('8.txt'); array3d = cat(3,a,b,c,d,e,f,g,h,i);
Now, what I have is a 1000x1024 3D array with 9 values (depth-wise) in each x,y location. What I am trying to essentially do is reorder the pixels. I want to find the maximum value depthwise for each x,y location. This maximum value will be the first value in that x,y position. Then, I want to continue with the normal order of pixels until I need to loop back around to the first pixel value in the original 3D array and continue with the order of the pixels. For example, if in position (1,1) the 9 values depth wise are: 12, 2, 15, 20, 22, 0, 6, 7, 9. Then the new order of the pixels would be: 22, 0, 6, 7, 9, 12, 2, 15, 20. The maximum value for this particular x,y location was 22 (on the 5th slice of the 3D array). Therefore, the output array will start with this value and continue with the pixel values on slices 6 through 9, loop back around and continue with pixel values from slices 1 through 4. I need to complete this for each pixel and have one final output array that is a 3D array with 9 slices. Please help, anything is appreciated; thank you!!

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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!

Translated by