MATLAB Answers

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

1 view (last 30 days)
Sarah
Sarah on 26 Oct 2018
Commented: Sarah on 13 Nov 2018
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 Comments
Stephen
Stephen on 31 Oct 2018
"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?

Sign in to comment.

Answers (1)

Stephen
Stephen on 31 Oct 2018
Edited: Stephen on 31 Oct 2018
I suspect that the indexing is a red herring, and you just want this:
window_cube = matrix3D(row1:row2, col1:col2, 1:Frames)
  3 Comments
Sarah
Sarah on 13 Nov 2018
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 :)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!