From the course: Fundamentals of Dynamic Programming

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Project: Finding low-energy seams

Project: Finding low-energy seams - Python Tutorial

From the course: Fundamentals of Dynamic Programming

Project: Finding low-energy seams

- [Instructor] Find the energy of the lowest energy scene ending at pixel x y. We need to look at the current pixels energy and the lowest energy seams ending in the grow above. This is the recurrence relation we'll have to implement. Because our function takes two inputs, we can rearrange the sub-problems in a grid. In fact, for this problem, the sub problems correspond exactly to the pixels and the input image. After all, there's a seam ending at every pixel. First, there's the base cases. Which correspond to all the sub problems for the top row. We can calculate these in any order. Because they don't depend on each other. A reasonable approach would be to calculate them from left to right. In the second row, our first sub problem depends on the two sub problems above it. There are only two sub problems above because we're at the left edge of the image. Each sub problem after this one depends on the two or three sub…

Contents