I have a hypercube data with size 512 x 320 x 211. I want to divide this cube into smaller cube data size 32x32x211 and I want to get the mean value of all smaller cube data. How can I do that using Matlab? Thanks a lot.

 채택된 답변

michio
michio 2017년 8월 4일
편집: michio 2017년 8월 4일

0 개 추천

You want to divide the data into smaller pieces without any overlaps? So 512 x 320 x 211 array will be divided into 160 of 32x32x211 arrays and you want mean values from each of them, correct?
You can do it in various ways, but if you have Image Processing Toolbox, blockproc function can be useful.
myfun = @(block_struct) mean(block_struct.data(:));
I2 = blockproc(I,[32 32],myfun);
where I is your hypercube data with size 512 x 320 x 211 then I2 will be 16x10 array with mean values of each divisions.

추가 답변 (1개)

Imran Sofianto
Imran Sofianto 2017년 8월 4일

0 개 추천

Thank you very much for your answer, Michio. And then how to reshape again to hypercube data with consisting 211 band? It fails when I reshape to size 16x10x211. Thank you.
[x y] = size(I2); I3 = reshape(I2, [x y c];

댓글 수: 3

Ah, you want 16x10x211 array in the end? So the mean operation will be preformed on each slice of 512x320? In that case, the following would do the job.
myfun = @(block_struct) mean(mean(block_struct.data));
I2 = blockproc(I,[32 32],myfun);
where I is your hypercube data with size 512 x 320 x 211 then I2 will be 16x10x211 array with mean values of each divisions.
Imran Sofianto
Imran Sofianto 2017년 8월 4일
That is perfect, thank you very much, Michio. It solved my problem to analyze the hypercube data. Thanks a lot.
michio
michio 2017년 8월 5일
You are welcome :)

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

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2017년 8월 4일

댓글:

2017년 8월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by