Thursday, 15 April 2010

Intelligent Image Scaling

Intelligent modification of images is all the rage at the moment, especially with Photoshop CS5's fancy new tools for healing imperfections in the image... This is my take on a classic implementation of intelligent image shrinking, using an edge detection to determine the bits of the picture that are "interesting" then drawing seams down the image through the boring regions and then removing pixels along this path.

This implementation is 100% coded from scratch and can be used for any project under the terms of the GPL v2 or later.

The test image:
The edge detection to find objects:
And 5 example low detail vertical "seams" which run through the image. These are the lines of boring pixels which will be removed to make the image narrower.
Removing 100 seams of pixels makes the image 100px narrower. See the following images for an example of the resizing in progress:
You can watch the scaling of four example images at YouTube.
Download the code for the ImageJ macro (used for rescaling of these images) here.

Software used:
Image creation: ImageJ
Video transcoding: VLC media player

No comments:

Post a Comment