Filter löschen
Filter löschen

How to resize a 3D matrix?

12 Ansichten (letzte 30 Tage)
Sandhiya Prakash
Sandhiya Prakash am 14 Mär. 2017
Kommentiert: SojM am 17 Jul. 2020
Hi, I want to reduce the size of a 3D image by averaging the values in 3D. For example if the image is 160*216*176. I wrote the code below to process the image to average the values in every 4*4*4 cube thereby creating a new matrix that is 40*54*44 in size.my code is below
X(1:40)=4;
Y(1:54)=4;
Z(1:44)=4;
A=mat2cell(imagestack_1,[X],[Y],[Z]);
average=cellfun(@mean2,A);
But this shows an error
Error using mat2cell (line 97)
Input arguments, D1 through D3, must sum to each dimension of the input matrix size, [160 216 176].'
Anyone who knows Please guide me!!
  3 Kommentare
Sandhiya Prakash
Sandhiya Prakash am 14 Mär. 2017
I am using MatlabR2016a.
Sandhiya Prakash
Sandhiya Prakash am 14 Mär. 2017
I think i must give variable in which 3D image is stored instead of imagestack_1. Kindly guide me.I am new to matlab.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Mär. 2017
You probably had previous values in your X, Y, or Z, making them longer than what would be created with just the above code.
  6 Kommentare
Walter Roberson
Walter Roberson am 14 Mär. 2017
The boundary points do not have 27 neighbors. You should either calculate only on the interior, or you should define what you want the boundary calculation to be.
SojM
SojM am 17 Jul. 2020
After the resize of the matrix, how to save new 3D matrix as stack of 2D images?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by