TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Real-world dynamic programming: seam carving

412 pointsby akdasalmost 6 years ago

16 comments

matsemannalmost 6 years ago
I held a workshop once where people implemented this (and other image algorithms). The end result can be seen here [0], and the tasks here [1] (but in Norwegian). Can click the &quot;run seam carving&quot; button to watch it unfold step by step.<p>[0]: <a href="https:&#x2F;&#x2F;matsemann.github.io&#x2F;image-workshop&#x2F;" rel="nofollow">https:&#x2F;&#x2F;matsemann.github.io&#x2F;image-workshop&#x2F;</a> [1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;Matsemann&#x2F;image-workshop" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Matsemann&#x2F;image-workshop</a>
alleycat5000almost 6 years ago
This was a homework assignment in Robert Sedgewick&#x27;s Algorithms course on Coursera!<p><a href="https:&#x2F;&#x2F;www.coursera.org&#x2F;learn&#x2F;algorithms-part1" rel="nofollow">https:&#x2F;&#x2F;www.coursera.org&#x2F;learn&#x2F;algorithms-part1</a><p>Great class and fun assignment!
评论 #20287726 未加载
milliamsalmost 6 years ago
It feels like those images of the energy could have been improved by plotting the log of the energy. It would allow us to see changes at the low end where the decisions are being made.
评论 #20301211 未加载
GolDDranksalmost 6 years ago
This brings to mind the Viterbi algorithm that calculates the most likely sequence of events in a hidden Markov model (Markov model itself is just a state machine on a graph with weighed edges, where each weight on a state transition is represented as a probability of that transition).<p>It&#x27;s essentially bases to the same algorithm: you can eliminate sequences if they lead to the same event that is already part of a solution, but with lesser probability. The amount of paths would be exponential, but the ability to eliminate them keeps it polynomial. That really brings forth the beauty of dynamic programming.
评论 #20286883 未加载
评论 #20287609 未加载
评论 #20287273 未加载
andreareinaalmost 6 years ago
There&#x27;s also the approach that calculates the energy of the resulting image as opposed to the seam being removed, which allows the seams to pass through objects where doing so will minimize artifacts.<p>Paper: <a href="http:&#x2F;&#x2F;www.faculty.idc.ac.il&#x2F;arik&#x2F;SCWeb&#x2F;vidret&#x2F;index.html" rel="nofollow">http:&#x2F;&#x2F;www.faculty.idc.ac.il&#x2F;arik&#x2F;SCWeb&#x2F;vidret&#x2F;index.html</a><p>GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;axu2&#x2F;improved-seam-carving" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;axu2&#x2F;improved-seam-carving</a>
评论 #20292042 未加载
gabeiscodingalmost 6 years ago
Cool to see this popping up again. It always impresses if you haven&#x27;t seen it before and is a cool algorithm to work through.<p>The original paper was discussed on slashdot and back at that time I was inspired to build a little GUI around an open source algorithm implementation to play with my Qt skills.<p>It allows you to shrink, expand and &quot;mask out&quot; regions you don&#x27;t want touch etc.<p>Still available on Google Code archive:<p><a href="https:&#x2F;&#x2F;code.google.com&#x2F;archive&#x2F;p&#x2F;seam-carving-gui&#x2F;" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;archive&#x2F;p&#x2F;seam-carving-gui&#x2F;</a>
co0nstaalmost 6 years ago
If you like DP imaging applications like this, this old Microsoft Research technical report is neat: it uses DP to merge frames from two webcams placed left and right to synthesize a view in the middle, like having a webcam in the middle of your monitor. The DP is interesting because it has penalities set up assuming planar content because faces are pretty flat and in front of the cameras. Link: <a href="https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;publication&#x2F;efficient-dense-stereo-and-novel-view-synthesis-for-gaze-manipulation-in-one-to-one-teleconferencing&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;publication&#x2F;efficie...</a>
bcp2384almost 6 years ago
Why are DP problems so popular for interviews? I am doing leetcode now and they seem to be everywhere.
评论 #20292176 未加载
评论 #20292024 未加载
jhargeralmost 6 years ago
I remember implementing this for a class years ago, and then the professor suggested doing the inverse to try to expand the image width. The idea was you would duplicate the lowest energy seam... but all that did was create a lot of repeats of the same seam.<p>I never did finish that weird idea, but I probably needed to try something like increasing the energy of the chosen seam (and its duplicate)... I may try that again, just because I&#x27;m curious what would happen.
评论 #20288014 未加载
评论 #20288044 未加载
评论 #20288024 未加载
petschgealmost 6 years ago
This is also known as &quot;liquid rescale&quot; and there is (was?) a gimpl plugin for it. It last updated in 2013 or so. After that the developer was hired by Adobe to work on Photoshop.
评论 #20291574 未加载
ttoinoualmost 6 years ago
Great. Now adapt this to video (:
评论 #20286049 未加载
评论 #20286338 未加载
评论 #20286756 未加载
评论 #20291599 未加载
评论 #20286757 未加载
评论 #20285454 未加载
bitLalmost 6 years ago
Any good set of super hard dynamic programming problems to practice? (I mean way harder than leetcode&#x2F;hackerrank etc.)
评论 #20288029 未加载
评论 #20289548 未加载
评论 #20291033 未加载
sligalmost 6 years ago
Really interesting, thanks for sharing!<p>I believe there&#x27;s a typo here: &quot;the time complexity would still be 𝑂(𝑊)&quot; should be &quot;the space complexity would still be 𝑂(𝑊)&quot;.
评论 #20286827 未加载
trhwayalmost 6 years ago
Tangential - the turbulent water looks for me like the large scale structure of the Universe.
xemokaalmost 6 years ago
Non-medium version: <a href="https:&#x2F;&#x2F;avikdas.com&#x2F;2019&#x2F;05&#x2F;14&#x2F;real-world-dynamic-programming-seam-carving.html" rel="nofollow">https:&#x2F;&#x2F;avikdas.com&#x2F;2019&#x2F;05&#x2F;14&#x2F;real-world-dynamic-programmin...</a>
评论 #20286058 未加载
ameliusalmost 6 years ago
Isn&#x27;t there a more generic deep-learning approach (i.e. with less assumptions) for this problem?
评论 #20286487 未加载