Resize Image efficiently using Dynamic Programing

Aishwarya Singh 06 Feb, 2018 • 2 min read

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:

 

Source

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.

Aishwarya Singh 06 Feb 2018

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.

Frequently Asked Questions

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

Responses From Readers

Clear

Paul
Paul 20 Mar, 2018

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