Learn everything about Analytics

Home » Resize Image efficiently using Dynamic Programing

Resize Image efficiently using Dynamic Programing

Every now and then we resize or crop our images so as to fit them into the limited space as per our requirement. Often while resizing, the subject of the image gets distorted or looses its original quality. How would you feel if I tell you that you can now resize your image intelligently. Interesting? Right?

You can now use Caire to resize your image while preserving its most significant parts. Unlike the usual image cropping, Carie resizes the image maintaining the ratio of people or building in the image. Let us know more about Caire and see how it works!

Caire is an image resize library which uses the Seam Carving algorithm. Seam carving is an algorithm for content-aware image resizing. The main idea of Seam Carving algorithm is to identify the least important parts in an image and remove them in order to reduce the size of the image. Seam carving also allows manually defining areas in which pixels may not be modified, and features the ability to remove whole objects from photographs.

Carie uses this algorithm to resize objects in an image, based on heat-map and edge detection techniques, that is, it does not resize each part of the image with same metric, instead it identifies the important objects to preserve and least important parts to be removed.

When an image is provided, edge detection technique is used to generate an energy map for the image. Based on the energy level values, it recognizes the parts with lower energy levels as ‘least important’. These least important parts in the image are referred to as ‘seams’ which are generated using dynamic programming approach.

Here’s the step by step illustration of the algorithm:

1. Original Image:

2. Energy map created using dynamic mapping:

3. Seams Identified:

4. Resized Image:



Our take on this:

The previously existing techniques for image photoshop or rising would blindly follow the users instructions resulting in an image with distorted proportions. Using dynamic programming, Carie can resize image more efficiently, providing better results than ever.

You can also read this article on our Mobile APP Get it on Google Play
This article is quite old and you might not get a prompt response from the author. We request you to post this comment on Analytics Vidhya's Discussion portal to get your queries resolved

One Comment

  • Paul says:

    Implementations of this algorithm (without face detection) are available as Liquid Rescale in ImageMagick and Gimp and as Content Aware Scale in Photoshop