Changing an image's aspect ratio without distortion, using Liquid Rescale

Sometimes it's useful to be able to change the shape of a photo - on our website PropertyMall, we like the thumbnails on our property search results to be a nice uniform size. Rather than stretch the images, we've chosen on that site to crop them down to the correct size, however this approach can sometimes have odd results.

I've just been looking at the Liquid Rescale plugin for GIMP, which attempts to let you rescale images to different aspect ratios without having to distort or crop out the important details. The technology used is Seam Carving, which you can read about in this paper by Shai Avidan and Ariel Shamir, or watch a video about it on Youtube.

As an example, imagine I had a system that only accepted square images. Here is a picture I took a while back of some elephants:

Elephants crossing

Using traditional tools, I have two choices for making it square: I can stretch it or crop it.

Elephants pic, with comparison of stretched and cropped versions

The original, scaled and cropped versions

In the scaled version, the elephants look far too fat, while in the cropped version some of the interesting foreground and background are missing (ok, you may disagree that they're interesting but let's assume a more talented photographer took it). What Liquid Rescale offers is a way of preserving the dimensions on the Elephants, which are quite easy to spot when they're wrong, while allowing the water, riverbank and trees to be scaled because that scaling will be much harder to spot.

Just running the image through the plugin gives a slightly better result than the scaled version, but the elephants still look stretched a bit. The reason for this is presumably that the river isn't uniform enough for the algorithm to detect that it's scaleable. The plugin allows you to specify certain areas of the image as inviolable, by scribbling over them with a mask - the whole process is quite simple and gives a very acceptable result:

Elephants pic, with example mask and Liquid Rescale

The original, original with a mask, and the liquid rescaled version

As you can see, knowing that the elephants should be preserved, the algorithm has picked parts of the river and bank to stretch, and the final result is pretty good! I don't think I'd know at first glance that anything had been moved around. Designers have been doing this sort of thing for years, of course, but normally with a bit more Photoshop effort, and some gruelling use of the clone tool.

Elephants crossing, Liquid Rescaled

Of course, my main interest was in doing this automatically for website-building purposes, and I have to say the results without adding the hint mask were very disappointing. However, it seems a useful tool for meddling with my photos in future, so my time wasn't completely wasted. If I were to pursue this in future for our property thumbnails, I'd have to take a look 'under the hood' at the algorithm and see if there was a way of optimising it for 'building' colours and not for 'sky' colours, but that's not really something I'm likely to find the time for!

If you want to give it a go yourself, Linux people can get the GIMP plugin, or Photoshop users can upgrade to CS4 where the same technology is used and called 'Content Aware Scaling'.

Bookmark and Share

Comments

Commenting is currently disabled