Skip to content
Snippets Groups Projects
Commit 2a82b57e authored by Kevin Lin's avatar Kevin Lin
Browse files

image-processing: Better pseudocode for DynamicProgrammingSeamFinder

parent f5264ef6
No related branches found
No related tags found
No related merge requests found
Pipeline #396594 passed with stages
in 45 seconds
......@@ -166,7 +166,7 @@ Design and implement an alternative graph representation and graph algorithm for
1. For each node in reverse DFS post-order, apply Dijkstra's edge relaxation step: if the distance to the neighboring node using the given edge is less than the `distTo` value to the neighboring node, update `distTo` and `edgeTo` accordingly.
`DynamicProgrammingSeamFinder`
: A [dynamic programming seam finding algorithm](https://avikdas.com/2019/05/14/real-world-dynamic-programming-seam-carving.html#bottom-up-implementation). This algorithm solves the problem by considering pixels from left to right similar to the `ToposortDAGSolver` except that it operates directly on the `Picture` rather than through an abstract `Graph` representation.
: A [dynamic programming seam finding algorithm](https://adityashrm21.github.io/Image-Compression/#seam-carving-using-dynamic-programming). This algorithm solves the problem by considering pixels from left to right similar to the `ToposortDAGSolver` except that it operates directly on the `Picture` rather than through an abstract `Graph` representation.
: 1. Initialize a 2-D `double[picture.width()][picture.height()]` to represent the cost of the **minimum energy path** from the left edge to each pixel.
1. Iteratively compute the minimum energy path to each pixel starting from the left edge of the picture and working towards the right edge by considering each pixel's preceding path costs: the **left-up**, **left-middle**, and **left-down** pixels.
1. Compute a shortest path by starting from the right edge and working back towards the left edge, adding each minimum-cost **y-coordinate** to a list.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment