From the course: Fundamentals of Dynamic Programming

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solution: Using backpointers to reconstruct seams

Solution: Using backpointers to reconstruct seams - Python Tutorial

From the course: Fundamentals of Dynamic Programming

Solution: Using backpointers to reconstruct seams

- [Instructor] Let's look at how you would use back pointers in Python. We're going to focus on the file, seam_v2.py. First we needed a way to store back pointers in the seam energy with back point of class. I've chosen to store the seam energy and the X coordinate of the destination pixel. Notice that the second value defaults to none, which will be the case for the values in the first row. And that's it, just storing these two values is enough. Next up is compute vertical seam v2. Like before we start by creating a grid to store the values of the m function. The grid has the same size and shape as the input grid of energy values. But we can initialize all the values as none. Next, we extract the height and width of the image based on the grid of energy values. Filling out the top row is straightforward, here we could just use the energy values from the top row or we wrapped them in instances of seam energy with back…

Contents