From the course: Fundamentals of Dynamic Programming
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Solution: Finding low-energy seams - Python Tutorial
From the course: Fundamentals of Dynamic Programming
Solution: Finding low-energy seams
- [Instructor] Let's look at how you would implement the seam finding algorithm in Python. We're going to focus on the file seam_v1.py. The only function we needed to implement was compute vertical seam V one. The first thing we'll do in this function is create 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 zero. Next, we can extract the height and width of the image based on the grid of energy values. The first thing we have to do is fill out the top row. Here, we could just copy over the energy values from the top row, exactly as our base case is defined. Now, we can loop through each element of the grid of energy values. Remember, this grid corresponds one-to-one with the pixels of the original image. Because we primarily care about X and Y coordinates of each pixel, we use the range function in Python…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
What is content-aware image resizing?3m 26s
-
(Locked)
Preprocessing: Defining the energy of an image2m 31s
-
(Locked)
Project: Calculating the energy of an image3m 41s
-
(Locked)
Solution: Calculating the energy of an image2m 20s
-
(Locked)
Using dynamic programming to find low-energy seams3m 31s
-
(Locked)
Project: Finding low-energy seams3m 26s
-
(Locked)
Solution: Finding low-energy seams2m 42s
-
(Locked)
Project: Using backpointers to reconstruct seams3m 50s
-
(Locked)
Solution: Using backpointers to reconstruct seams3m 9s
-
(Locked)
Project: Removing low-energy seams2m 12s
-
(Locked)
Solution: Removing low-energy seams2m 13s
-
-
-