Seam Carving Algorithm - Used for Content Aware Image Resizing

Seam Carving Algorithm - Used for Content Aware Image Resizing


                                                       Seam Carving Algorithm

   It is an extremely elegant way to resize an image without cropping out the important content nor distorting the objects in the image, seam carving has always fascinated engineers and algorithm enthusiasts.

 It basically uses very simple logic to resize an image. It says since it is not accurate to crop an image without considering the important objects in the image, let us remove those pixels which are not at the important content of the image. By removing those pixels we anyhow reduce the overall size of the image.

 Now the question is how we find and locate those pixels which are important and which are not, because only after that would we be able to remove the unimportant pixels. (Caution - here we are not trying to remove all the unimportant pixels in the image like spaces which dont have many objects, otherwise, we might end up losing the meaning of that image that the creator has tried to convey.)

 One of the ways of locating the pixels which are important is by identifying the change in the pixel values at certain points. This practice becomes easy after we convert an image to greyscale and then test those points where the pixel values have suddenly risen up. This shows that there is an edge of an object which is significant in the image. We can use derivatives(a concept in calculus) here to find that change. After we are able to locate the edges of the objects in the image, we need to find those pixels which are not very important, i.e they lie not on the objects but away.

 In this way upon removing pixels from top to bottom in the image, we can decrease the width i.e the horizontal length, and upon removing pixels from left to right, we can reduce the vertical length of the image. This results in a resized image which has its important content and objects maintained and not erased or distorted.