I have a lot of images, different sizes and aspect ratios. Is it possible to make a montage of them? I mean to optimally arrange them in rows after I set a common height for the images which build up a common row. Images aspect ratios aren't allowed to modify of course, and none of the images are allowed to omit from the final montage nor duplication.
The height of picture rows in the montage usually aren't equal, but their values should be kept in a minimal range (in statistical sense) or in other words: standard deviation from the mean value of the row heights must be minimized.
Desired width and height of the montage are given (a.)
Or the width and an allowed ratio range (or equivalently height range) is given (b.), for example width must be 1024 pixel, height must be so that w/h < 0.9 and w/h > 0.8
1.) Images must be packed in the montage in their initial fixed order. In this case one must find the images after what a new image row should be started in the montage (easy).
2.) Order of images is allowed to be altered. In this case one must find a permutation which lead to a minimalization of the standard deviation of the final row heights when each image is packed into the montage (hard).
For example: