how to reduce the resolution of a matrix?

18 ビュー (過去 30 日間)
trailokya
trailokya 2014 年 11 月 22 日
コメント済み: wesley lima 2021 年 6 月 24 日
I have a matrix of dimension 140*140. i want to make it to dimension 35*35 by averaging grids. how can i do it in a simpler way? Actually i want to reduce the dimension by averaging the grids like [(1,1),(1,2),(2,1),(2,2)] and so on....
  1 件のコメント
Image Analyst
Image Analyst 2014 年 11 月 22 日
It's like 1 or 2 lines if you use blockproc(), which is available in the Image Processing Toolbox. Do you have that toolbox? Or you can use mean2() in a for loop (also requires IPT).

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2014 年 11 月 22 日
This executes quickly on your small (140x140) matrix:
M = randn(140, 140); % Create Data
for k1 = 1:4:size(M,1)-3
idxr = 1+fix(k1/4);
for k2 = 1:4:size(M,2)-3
idxc = 1+fix(k2/4);
MF = M(k1:k1+3,k2:k2+3); % Matrix Frame (4x4)
MR(idxr,idxc) = mean(MF(:));
end
end
Look = MR(1:5,1:5) % View Sample Results
  3 件のコメント
Star Strider
Star Strider 2014 年 11 月 22 日
My pleasure!
wesley lima
wesley lima 2021 年 6 月 24 日
hi, i have a similar problem that i am not able to solve, i have a matrix of 922x, 649x492 and i would like it to be 230x173x492.

サインインしてコメントする。

その他の回答 (1 件)

Orion
Orion 2014 年 11 月 22 日
There was the same problem here
Several solution have been proposed, pick the one you prefer, like
  1 件のコメント
trailokya
trailokya 2014 年 11 月 22 日
thanks

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by