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

조회 수: 2 (최근 30일)
Gülizar Kaya
Gülizar Kaya 2018년 7월 19일
댓글: Gülizar Kaya 2018년 7월 24일
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.
Gülizar Kaya
Gülizar Kaya 2018년 7월 19일
Sorry, I meant a double array! Changed the title! :)

댓글을 달려면 로그인하십시오.

채택된 답변

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