Tuesday, January 27, 2009

I Love Technology!

Have you ever wanted to crop an image to a different aspect ratio, i.e. switch from landscape to a portrait layout, but just couldn't quite crop it without cutting out some of the picture content you really like. Well I was looking through some picture imaging information and discovered this dandy new image processing tool called seam carving also known as content aware image resizing that does just what you would want it to do, with some compromises of course. To get a feel for what I am talking about, take a look at the three images below. The first one is the original image which was taken in a 4:3 aspect ratio cropped to portrait landscape of 8x10 (5:4 aspect ratio) with 2824x2253 final pixels, a compressed version is shown below.



I then downloaded and processed the image in the nifty program called Seam Carving Gui and "resized" the image by highlighting each of us as regions not to tamper with and told it to convert the image to a portrait layout 8x10 (4:5) image with pixel dimensions of 1800x2253 and this is the final result (compressed version shown here).

Et Voila!



Now comparing the two images you can see certain distortions (the compromises I spoke of) especially with regards to the sun, the rocks to the right, the waves to the left are noisier and slightly curved, and a few other small details, but overall I am quite impressed. The horizon is still flat, sun, ships, and rocks still present, and we look exactly the same.

For comparison, here is the original image cropped to the same dimensions (1800x2253) using the traditional cropping technique.


As to which is actually better is arguable but I was able to keep the sun and some other details intact using the seam carving method that I couldn't do with the cropping method. My one complaint is that the output file from the seam carved image is only a 306 kB jpg file indicating some loss in picture quality when compared to the original image starting with 2.85MB, and the standard cropping method still yielding a 1.57 MB jpg file size meaning much of the image quality is retained in a "lossless" manner. A substantial file size reduction despite having the same exact same number of pixels. Of course the alternative is to take the cropped image above and paste the sun back into the picture which may even yield a better result but this method is fun to use and pretty cool. It turns out there are all sorts of versions of this process implementing different algorithms and such written in all sorts of different programming languages if you want to check them out. I only tested a couple (an ImageJ plugin and some other one called Dirt) but I found the Seam Carving Gui software to be convenient, inexpensive, and faster than most. Apparently this technique is already incorporated into Adobe Photoshop CS4 if you have it already but since I don't have the software I can't really try it out.

Enjoy!


2 comments:

Zach 'n' Jack said...

wow..... That was a fairly in-depth post. All being said and done, nice picture :-) You guys are one of our favorite fams!

Britt-Marie said...

That's pretty interesting. Thanks for sharing. I'll have to play with that.