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.

Solution: Removing low-energy seams

Solution: Removing low-energy seams - Python Tutorial

From the course: Fundamentals of Dynamic Programming

Solution: Removing low-energy seams

- [Instructor] Let's look at how you would remove seams in Python. We're going to focus on the file, carve.py. First up was the remove seam from image function, the implementation simply copies over the input grid of colors. Omitting the color, if it's X coordinate matches the corresponding X coordinate in seam Xs. Next up is the remove and lowest seams from image function. We're going to loop N times, where N is the number of seams to remove. In my implementation, I've chosen to print out some helpful output to know what iteration is currently executing and what step is running. The actual calculation entails calling the compute energy function, calling the compute vertical seam V2 function, visualizing the current lowest energy seam and saving the result in an intermediate file, and finally calling remove seam from image. At this point, the output of this iteration becomes the input for the next iteration. Now you can…

Contents