## Merging non-overlapping array blocks

Question

I divided a (512x512) 2-dimensional array to 2x2 blocks using this function.

```
skimage.util.view_as_blocks (arr_in, block_shape)
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
>>> B = view_as_blocks(A, block_shape=(2, 2))
>>> B[0, 0]
array([[0, 1],
[4, 5]])
>>> B[0, 1]
array([[2, 3],
[6, 7]])
```

Now I need to put the same blocks to their original places after manipulation but I couldn't see any function in skimage for that.

What's the best way to merge the non-overlapping arrays as it was before?

Thank you!

Show source

## Answers ( 1 )

Use transpose/swapaxes to swap the second and third axes and then reshape to have the last two axes merged -

Sample run -