Image compression by seam carving We are given a color | StudySoup

Textbook Solutions for Introduction to Algorithms

Chapter 15 Problem 15-8

Question

Image compression by seam carving We are given a color picture consisting of an m n array A1 : : m; 1 : : n of pixels, where each pixel specifies a triple of red, green, and blue (RGB) intensities. Suppose that we wish to compress this picture slightly. Specifically, we wish to remove one pixel from each of the m rows, so that the whole picture becomes one pixel narrower. To avoid disturbing visual effects, however, we require that the pixels removed in two adjacent rows be in the same or adjacent columns; the pixels removed form a seam from the top row to the bottom row where successive pixels in the seam are adjacent vertically or diagonally. a. Show that the number of such possible seams grows at least exponentially in m, assuming that n>1. b. Suppose now that along with each pixel Ai; j , we have calculated a realvalued disruption measure di; j , indicating how disruptive it would be to remove pixel Ai; j . Intuitively, the lower a pixels disruption measure, the more similar the pixel is to its neighbors. Suppose further that we define the disruption measure of a seam to be the sum of the disruption measures of its pixels. Dynamic Programming Give an algorithm to find a seam with the lowest disruption measure. How efficient is your algorithm?

Solution

Step 1 of 3)

The first step in solving 15 problem number 8 trying to solve the problem we have to refer to the textbook question: Image compression by seam carving We are given a color picture consisting of an m n array A1 : : m; 1 : : n of pixels, where each pixel specifies a triple of red, green, and blue (RGB) intensities. Suppose that we wish to compress this picture slightly. Specifically, we wish to remove one pixel from each of the m rows, so that the whole picture becomes one pixel narrower. To avoid disturbing visual effects, however, we require that the pixels removed in two adjacent rows be in the same or adjacent columns; the pixels removed form a seam from the top row to the bottom row where successive pixels in the seam are adjacent vertically or diagonally. a. Show that the number of such possible seams grows at least exponentially in m, assuming that n>1. b. Suppose now that along with each pixel Ai; j , we have calculated a realvalued disruption measure di; j , indicating how disruptive it would be to remove pixel Ai; j . Intuitively, the lower a pixels disruption measure, the more similar the pixel is to its neighbors. Suppose further that we define the disruption measure of a seam to be the sum of the disruption measures of its pixels. Dynamic Programming Give an algorithm to find a seam with the lowest disruption measure. How efficient is your algorithm?
From the textbook chapter Dynamic Programming you will find a few key concepts needed to solve this.

Step 2 of 7)

Visible to paid subscribers only

Step 3 of 7)

Visible to paid subscribers only

Subscribe to view the
full solution

Title Introduction to Algorithms 3 
Author Thomas H. Cormen
ISBN 9780262033848

Image compression by seam carving We are given a color

Chapter 15 textbook questions

×

Login

Organize all study tools for free

Or continue with
×

Register

Sign up for access to all content on our site!

Or continue with

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back