how to specify positions of the blocks in an image
4 views (last 30 days)
Show older comments
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!
0 Comments
Answers (2)
David Young
on 11 Jan 2012
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 Comments
David Young
on 13 Jan 2012
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
on 13 Jan 2012
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 Comments
Walter Roberson
on 13 Jan 2012
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.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!