필터 지우기
필터 지우기

how can i move a certain windw of a 3D array to another 3D array?

조회 수: 3 (최근 30일)
Sarah
Sarah 2018년 10월 26일
댓글: Sarah 2018년 11월 13일
Dear All,
my goal is to prompt user input of 2 pixels making a window of the 3D matrix to perform calculations only on the pixels of that window.
so user inputs row1, row2, col1, col2 and i use that to accumulate the pixel values from the 3D matrix to my window_cube
itried the following line
window_cube(:, :, :)= matrix3D(row1:row2, col1:col2, 1:Frames)
user will input: row1, row2, col1, col2, Frames.
However, the error I am facing is that the window_cube ends up copying the same frame of the 3D cube into every frame of the window_cube. So all frames of window_cube are now identical.
can someone explain how it is possible to gather the data of a certain window from a 3D matrix into a smaller 3D matrix? ?
  댓글 수: 5
Sarah
Sarah 2018년 10월 31일
편집: Sarah 2018년 10월 31일
Window cube size is based on user input. User inputs the indicated values in my question and accordingly that part is cut out of the original 3D array and moved to the new 3D array window_cube. This loop is for moving the data from the original cube to the window_cube.
Stephen23
Stephen23 2018년 10월 31일
"I thought colon is one way of indexing to enter array elements,..."
Sure it is, but the colon means "all of this dimension", which apparently does not suit what you are trying to do. But you did not describe how exactly that data should be allocated to window_cube: do you want to allocate the RHS subarray into a subarray of window_cube, or do you want window_cube to be RHS subarray itself, nothing more?

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

답변 (1개)

Stephen23
Stephen23 2018년 10월 31일
편집: Stephen23 2018년 10월 31일
I suspect that the indexing is a red herring, and you just want this:
window_cube = matrix3D(row1:row2, col1:col2, 1:Frames)
  댓글 수: 3
Stephen23
Stephen23 2018년 10월 31일
"...the problem is that all frames of the cube have identical data"
Why is this a problem? Does this reflect the data in matrix3D or not? What do you expect to get? Please show a minimum working example, complete with inputs and expected outputs. You can optionally upload data by clicking the paperclip button.
Sarah
Sarah 2018년 11월 13일
it is solved, I found out that my original imsge cube was accomulating the same data in all frames, i just fixed the loop for that and it worked well.
thank you :)

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by