Reshape and merge an array of images

Hi, I have an array of images and I simply want to merge them into one, efficiently.
Say that my array has 6 images, I would want to form something like;

1 2  or  1 2 3
3 4      4 5 6
5 6      

At the time I’m doing this with nested loops and it seems unnecessary, there should be an easier way, like reshape(arr, (2, 3)) and merge them together at the same time.

It looks like hvcat can be used here: Concatenating in comprehension


Yes!! That was it.

using TestImages
ARR = [testimage(“cameraman”) for i in 1:6];
hvcat(3, ARR…)
hvcat(2, ARR…)

does the trick.

Thank you so much for your answer.

1 Like

If your images are of different sizes, there’s also the MosaicViews package.