Aishwarya Singh — Published On February 6, 2018

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.

About the Author

Aishwarya Singh
Aishwarya Singh

An avid reader and blogger who loves exploring the endless world of data science and artificial intelligence. Fascinated by the limitless applications of ML and AI; eager to learn and discover the depths of data science.

Our Top Authors

Download Analytics Vidhya App for the Latest blog/Article

One thought on "Resize Image efficiently using Dynamic Programing"

Paul says: March 20, 2018 at 7:35 am
Implementations of this algorithm (without face detection) are available as Liquid Rescale in ImageMagick and Gimp and as Content Aware Scale in Photoshop Reply

Leave a Reply Your email address will not be published. Required fields are marked *