what is the formula to divide an image into number of blocks?

1 vue (au cours des 30 derniers jours)
anu
anu le 8 Fév 2018
I know how to divide image into blocks using Matlab. But I want to know generalized formula to divide an image into blocks.
  1 commentaire
Adam
Adam le 8 Fév 2018
If you know how to do it in Matlab then it isn't really a Matlab question to understand the generalized maths.
You can divide an image up however you want though. There isn't one formula that works for every kind of dividing up you would ever want to do.

Connectez-vous pour commenter.

Réponses (2)

KSSV
KSSV le 8 Fév 2018

Walter Roberson
Walter Roberson le 8 Fév 2018
Converting from block numbers to matrix indices:
starting matrix position in a direction = (block number in that direction, minus 1) times (block size in that direction), then plus 1
ending matrix position in a direction = (block number in that direction) times (block size in that direction), but never more than matrix size in that direction (because the last block in the direction might be a partial block)
Converting from matrix indices to block number:
block number in a direction = floor( (matrix position in that direction) minus 1) divided by block size in that direction) plus 1
For example if the block size was 64, the matrix index 219 would be block number floor((219-1)/64) + 1 = 4 in that direction. The first block would be index 1 to 64, the second block would be 65 to 128, the third block would be 129 to 192, the fourth block would be 193 to 256, so block #4 in the direction is correct for matrix index 219.

Community Treasure Hunt

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

Start Hunting!

Translated by