필터 지우기
필터 지우기

how can i split an image into 25 blocks using for loop?

조회 수: 3 (최근 30일)
eman
eman 2015년 1월 5일
편집: Mohammad Abouali 2015년 1월 6일
i have a lot of images i need to split each image into blocks then i have to convert each block into one vector (now i have 25 vectors) i need to concatenate these vectors in one row vector finally i want to obtain an array each row in this array is a large vector(25 concatenated vectors) of one image how can i do this thanks in advance

채택된 답변

Mohammad Abouali
Mohammad Abouali 2015년 1월 5일
편집: Mohammad Abouali 2015년 1월 5일
B = im2col(your_image,[m n],'distinct');
B=B(:)';
m and n are the image block sizes.
B at the end is one row vector with your image blocks in it.
  댓글 수: 8
Image Analyst
Image Analyst 2015년 1월 6일
allvectors = [];
Mohammad Abouali
Mohammad Abouali 2015년 1월 6일
편집: Mohammad Abouali 2015년 1월 6일
As image analyst mentioned before entering the loop initialize all vectors to an empty variable. Something like this:
allvectors=[];
some code here
for i=1:n
some more code
vector= ....
allvectors = [allvectors, vector];
end

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

추가 답변 (2개)

Image Analyst
Image Analyst 2015년 1월 5일
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F For each block, you can turn it from a 2D subimage into a 1D vector with
vector1d = image2d(:);

Matt J
Matt J 2015년 1월 5일
Using MAT2TILES ( Download ),
blocks=mat2tiles(YourImage,25,25);

Community Treasure Hunt

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

Start Hunting!

Translated by