if I have a std::array<std::array<int, 4>, 4> mydata
, how would I split this into smaller chunks or std::array<std::array<int, 2>, 2>
, so it would look like this (visually):
where each color is one std::array<std::array<int, 2>, 2>
?
I have read some questions but they don't always ask the same or are incomplete:
Split array into chunks in C/C++ - asks how to split one continous stream of data into smaller continous bits, one dimensional
Split an image into 64x64 chunks - no source or explaination provided for ProcessChunk
?
The way I would do it is by not splitting the image at all.
let me elaborate:
if you create new arrays, you will have to copy the arrays over some new structure, probably std::vectors, since you don't know the different sizes at compile time.
What you can do instead, is keeping the original structure, and have a vector of Areas, where an Area is described by the 4 vertices that describe your inner square.
If you need to use less information, you could store only two corners and compute the other two, you actually only need 4 ints to know the area.