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

3 vues (au cours des 30 derniers jours)
Gülizar Kaya
Gülizar Kaya le 19 Juil 2018
Commenté : Gülizar Kaya le 24 Juil 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 commentaires
Jan
Jan le 19 Juil 2018
In the title you mention a cell array, but later you ask for a 3D double array.
Gülizar Kaya
Gülizar Kaya le 19 Juil 2018
Sorry, I meant a double array! Changed the title! :)

Connectez-vous pour commenter.

Réponse acceptée

Jason Whitfield
Jason Whitfield le 19 Juil 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, :);

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by