Using blockproc() or other to get specific number of blocks from various image sizes

2 views (last 30 days)
I've been using blockproc()to process a dataset, using variable B to indicate the number of both vertical and horizontal blocks e.g. using B = 10 would divide the image in to 11 by 11 = 121 blocks, with 10 by 10 equal blocks and the rightmost column and bottom row being the remainders. After each block is processed the results are shaped into a 1,[] array of doubles, and they are all of the same length (depending on B. Here they would be 121 long).
This is fine when my images do not have a dimension exactly devisible by B, but now I've expanded the dataset I'm getting images that have dimensions that can divide by B, resulting in exactly 10 by 10 blocks, or even 10 by 11, or, 11 by 10.
This produces an output of varying lengths which causes problems with vertcat, and more importantly when comparing outputs.
Is there a way of partitioning images of differing sizes in to an equal number of blocks based on an input integer B? Blocks do not necesarilly need to be all of equal size, but they should be consistent ie, if there is a remainder row/column they should always be in the same position. The key for me is to get output arrays of equal lengths.
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 7 Nov 2019
Edited: KALYAN ACHARJYA on 7 Nov 2019
but now I've expanded the dataset I'm getting images that have dimensions that can divide by B, resulting in exactly 10 by 10 blocks, or even 10 by 11, or, 11 by 10.
Is zero padding or any other means allowable?
Stephen
Stephen on 7 Nov 2019
Edited: Stephen on 7 Nov 2019
Apologies, I meant to include this. I experimented with padding, but I believe this pads an -extra- row column. So an image with dims 400x300 could be divided in to 10 rows 10 columns, but a 405x305 would be divided in to 11 by 11 with the last row and column padded.
Is this correct? It seems strange but when I padded I still got outputs of unqual lengths.
Either way, the solution I am hoping for is a set amount of rows and columns (here 10) with the remainder (if any) in the final row and/or column.

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!