How to split a double array in left and right sides?

2 visualizaciones (últimos 30 días)
Gülizar Kaya
Gülizar Kaya el 19 de Jul. de 2018
Comentada: Gülizar Kaya el 24 de Jul. de 2018
Dear experts,
I have a 3d array with dim 51x75x55 double and I want to calculate the N elements above a certain threshold (>2.3). However, I want to compare N elements above threshold in the left side of the original image with N elements above threshold in the right side of the image. How do I split a 3d array into a left and right side, according to the original image, which is a map of brain activation patterns?
I am still a kind of noob when it comes to matlab, so I appreciate simple explanations. :) p.s.: I don't have any matlab toolboxes available, so I can't use functions from e.g. the image processing toolbox.
Thank you in advance!
  2 comentarios
Jan
Jan el 19 de Jul. de 2018
In the title you mention a cell array, but later you ask for a 3D double array.
Gülizar Kaya
Gülizar Kaya el 19 de Jul. de 2018
Sorry, I meant a double array! Changed the title! :)

Iniciar sesión para comentar.

Respuesta aceptada

Jason Whitfield
Jason Whitfield el 19 de Jul. de 2018
You can do this with just matrix indexing. To get the left half of a matrix, you can index it with the expression "1:floor(end/2)". As you can see, this indexes from the first element to the middle element (located halfway to the end of the matrix). The "floor" function rounds down, which is necessary if the matrix has an odd number of elements, since you can't select half an element. For the right half, it would be a similar expression, "ceil(end/2):end". In this case, we index from the middle element (rounded up) to the end of the matrix. In the case of a 3D matrix where you want to split by column, your code would look similar to the following:
Left = MyImage(:, 1:floor(end/2), :);
Right = MyImage(:, ceil(end/2):end, :);

Más respuestas (0)

Categorías

Más información sobre Images 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