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

3 次查看(过去 30 天)
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 个评论
Jan
Jan 2018-7-19
In the title you mention a cell array, but later you ask for a 3D double array.

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by