필터 지우기
필터 지우기

Split a matrix into smaller sub matricies

조회 수: 3 (최근 30일)
John Draper
John Draper 2016년 2월 12일
답변: Image Analyst 2016년 2월 12일
I've seen this answered on the web many times but none of the answers seem to give me what I need, so here it goes...
As a simple example, I have a 100x100 matrix
if true
x = ones(100)
% code
end
I would like to split this into 100 sub matrices, of size 10x10.
I would then like to sum each element of each sub matrix to give me a 10x10 matrix of these sums.
I am using these Matrices I quiver3 after this so I cannot use the mat2cell (as far as I understand) function to manipulate them into sizes I want.
Any suggestions appreciated, as always, thanks in advance for your help. John.
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2016년 2월 12일
What is the specification of the split, evenly split the row and column into 10, like 1 to 10, 11 to 20, ..., 91 to 100?

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

채택된 답변

Matt J
Matt J 2016년 2월 12일
Using SEPBLOCKFUN ( Download )
result = sepblockfun(yourMatrix, [10,10], 'sum');
  댓글 수: 1
John Draper
John Draper 2016년 2월 12일
Yes this works but it gives me the wrong answer. I think the problem lies elsewhere. Thank you though.

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

추가 답변 (2개)

Image Analyst
Image Analyst 2016년 2월 12일
What are your complaints about both of the two methods in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F ?
  댓글 수: 1
John Draper
John Draper 2016년 2월 12일
Sorry, which methods are you referring to?

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


Image Analyst
Image Analyst 2016년 2월 12일
You can use blockproc() if you have the Image Processing Toolbox, both to split up the image and take the mean of each block:
meanFilterFunction = @(theBlockStructure) mean2(theBlockStructure.data(:));
blockSize = [10, 10];
blockyImage = blockproc(grayImage, blockSize, meanFilterFunction);
See attach demo script below the image for a full demo.

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by