필터 지우기
필터 지우기

How to create a new square matrix with entries of each middle point of each subsection of another larger square matrix?

조회 수: 2 (최근 30일)
I have a square matrix of size 611x611 in which I want to create a grid on of 47 rows and 47 collums (I believe I can do this with matt2cell command?). Then I want to construct a new square matrix of size 47x47, in which every entry is the middle or approximate middle entry (doesn't have to be exactly the middle one) of each grid square in the 611x611 square matrix. I hope it is clear what I am trying to ask!
PS: If doing it with the middle entry is very difficult or not possible, then every entry of the the 47x47 square matrix being the average of the values of the grids in the 611x611 square matrix is also fine!

채택된 답변

Rik
Rik 2020년 11월 4일
The code below requires the Image Processing toolbox, although you can do it with loops and mat2cell as well.
A=imread('pears.png');A=A(1:400,1:400,:);A=imresize(A,[611 611]);imshow(A)
fun_pick_middle=@(block) block.data(round(end/2),round(end/2),:);
B = blockproc(A,[611/47 611/47],fun_pick_middle);
imshow(B)
  댓글 수: 8
Borys Bulka
Borys Bulka 2020년 11월 4일
This makes much more sense now to me, thank you so much for your explenation it helped me a lot!
Rik
Rik 2020년 11월 4일
You're welcome. If I solved your question, please consider marking my answer as accepted answer. If not, feel free to post a comment with your remaining issues.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by