Question: Dynamic Programming: Question 1 (10pt) You are given a color picture consisting of an m x n array A of pixels, where each pixel specifies
Dynamic Programming:
Question 1 (10pt) You are given a color picture consisting of an m x n array A of pixels, where each pixel specifies a triple of red, green, and blue (RGB) ntensities. 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 become 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 from a "seam" from the top row to the bottom row where successive pixels in the seam are adjacent vertically or diagonally. [8pt] Suppose now that along with each pixel Ali, j], we have calculated a real valued disruption measure d ,j, indicating how disruptive it would be to remove pixel A ' Intuitively, the lower a pixel's 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. Give a dynamic programming algorithm to find a seam with the lowest disruption measure. The space used by your algorithm must be O(mn). (For space requirement, assuming that the total disruption measure of any seam requires a constant amount of space.) The running time of your algorithm must be a polynomial in mn; calculate it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
