Confusion on total number of blocks produced after splitting image into overlapping blocks.

1 visualizzazione (ultimi 30 giorni)
So apparently i found out about the principle that states the total number of blocks produced from splitting an image into overlapping blocks is computed with the following equation.
(M-B+1)(N-B+1)
where M and N are the dimensions of the input image and B is the block size. So i suggest that, if i want to split an image of dimension 256x256 into 8x8 overlapping blocks, then according to the equation i would get:
(256-8+1)(256-8+1) = 62001 blocks in total
I'm assuming that the +1 indicates overlap by 1 pixel? Correct me if I'm wrong.
However, what would it be if i were to split into 8x8 overlapping blocks with an overlap of 4 pixels? Would the equation be:
(256-8+4)(256-8+4) = 63504 blocks in total?
I also realize that somehow the equation doesn't take into account partial blocks? Is this principle reliable, or am i interpreting it wrongly?

Risposta accettata

Guillaume
Guillaume il 14 Ago 2019
Modificato: Guillaume il 14 Ago 2019
I don't think you got it right.
First, starts with non-overlapping blocks, how many blocks do you have if divide M columns into blocks of size P: M/P blocks (assuming that image size is a multiple of block size). Niow, if you slide these blocks by one column and ignoring edge effects, you get another M/P blocks. How many times can you slide these blocks before you've shifted by the full width of a block: P-1 times. Therefore, for an offest of 1, you'll have: blocks (the P-1 shifted blocks plus the orginal unshifted blocks.
Now, if you change the shift, and assuming it's a divisor of of the block size, you'll have in total P/S (S: shift) shifts before you've shifted by the full with, so you'll have in total: blocks.
Now all the above assumes that you allow the last block to shift partially out of the image. If not, you'll obviously have the last P-1 blocks you need to remove, so indeed, you'll end up with blocks. But for the case where S > 1, you'll need to remove the last blocks, so the number of blocks is .
Obviously, the same applies to the rows.
  2 Commenti
Guillaume
Guillaume il 15 Ago 2019
Padding or shrinking them. It's up to you to decide what's more appropriate for your algorithm.
nlfilter and colfilt will always pad the image.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by