how to specify positions of the blocks in an image
古いコメントを表示
i have divided my 64x64 image into overlapping blocks of 2x2. and the block elements are stored in another array. the array contains the first block elements in first row. second block elements in the second row and so on. now can anyone please help me in finding the the starting row and col position of that block?
i used the function im2col to divide my image into blocks. thank you!
回答 (2 件)
David Young
2012 年 1 月 11 日
Suppose you have
B = im2col(A, [2 2]);
and the size of A is [64 64].
Then B(1,k) comes from A(r,c) where
c = floor((k-1)/63) + 1
r = k - (c-1)*63
More generally, if the size of A is [mm nn], and you start from
B = im2col(A, [m n]);
then B(1,k) comes from A(r,c) where
c = floor((k-1)/(mm-m+1)) + 1
r = k - (c-1)*(mm-m+1)
2 件のコメント
Prajakta Shende
2012 年 1 月 13 日
David Young
2012 年 1 月 13 日
I am sorry, but I don't understand what you're trying to do. It looks like a new question. The answer I gave is to your original question as I understood it, in the simplest form I could.
Perhaps you need to explain what you are trying to achieve as your final result.
Walter Roberson
2012 年 1 月 13 日
0 投票
Why should the min or max of the rows be only 9? You are applying the statistics to c(i,:) where c is the output of im2col() applied to p, where p is the resize of the image that was read in. im2col does not return indices, it returns array contents -- so your c is going to have whatever content the image had. Unless the image itself was confined to values in the range 0 to 9, the max() could easily exceed 9.
3 件のコメント
Prajakta Shende
2012 年 1 月 13 日
Walter Roberson
2012 年 1 月 13 日
Seems to me that there should be 15 blocks in each direction when you using overlapping 2 x 2 blocks on a 16x16 image. For any top-left image index (I,J) then (I+1,J) and (I,J+1) and (I+1,J+1) are also valid top-left indices (overlapping by one pixel of the 2x2 block); by induction, top left indices can range from 1 to 16-1 on each side, which gives 15x15 = 225 blocks.
David Young
2012 年 1 月 13 日
Walter is correct:
>> size(im2col(zeros(16), [2 2]))
ans =
4 225
カテゴリ
ヘルプ センター および File Exchange で Get Started with Computer Vision Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!