Seam Carving | Week 2, lecture 7 | 18.S191 MIT Fall 2020

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

ความคิดเห็น • 153

  • @SinnohStarly
    @SinnohStarly 4 ปีที่แล้ว +231

    this is the best thing that has happened during the pandemic. I teach seam carving as a PhD student, but now I feel useless :D

  • @ProjectPhysX
    @ProjectPhysX 4 ปีที่แล้ว +137

    Combine a few simple algorithms - in this case edge detection and minimum energy path search - and what you get is pure black magic.
    That is why I love computer science!

    • @henrmota
      @henrmota 4 ปีที่แล้ว +10

      Computer Science gives you the power to experiment at a low cost.

    • @ProjectPhysX
      @ProjectPhysX 4 ปีที่แล้ว +3

      @@henrmota I know!! That's why I'm doing it for a living :)

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      @Arid Sohan yeah, exactly what i was thinking

  • @JudahDaniels
    @JudahDaniels 4 ปีที่แล้ว +27

    MIT are lucky to have you!

  • @ancbi
    @ancbi 4 ปีที่แล้ว +38

    "It picks up on the edginess of Mario" --- Grant Sanderson 2020

  • @NEMountainG
    @NEMountainG 4 ปีที่แล้ว +33

    I have my own classes, but I’m watching this series as well for Grant.

  • @barrycavin
    @barrycavin 4 ปีที่แล้ว +4

    How can he be very good at storytelling this kind of complicated and multilayered concepts/techniques. A genius.

  • @AV-br3bm
    @AV-br3bm 4 ปีที่แล้ว +3

    Grant's lectures are always pure gold. We need to keep the activities in the comments so the TH-cam algorithms bless this video. It will help spread knowledge and will definitely make the world a better place.

  • @zinxys
    @zinxys 2 ปีที่แล้ว +1

    i love the dynamic programming example.. changin from exponential order to multiplication just by reversing the way we do computation.. that is absolutely awesome..

  • @oghry
    @oghry 4 ปีที่แล้ว +12

    This is the best explanation of magic of content aware shrinking. Thank you! Спасибо!

  • @kindoblue
    @kindoblue 4 ปีที่แล้ว +136

    People waste time on Netflix when you have Grant around. Crazy.

    • @bessimaestro
      @bessimaestro 4 ปีที่แล้ว +15

      We need a petition to bring Grant to Netflix! Make Algebra Great Again!

    • @AndreasIndustriePro
      @AndreasIndustriePro 4 ปีที่แล้ว

      its crazy i had to go to bed half an hour ago

  • @birdbrid9391
    @birdbrid9391 4 ปีที่แล้ว +47

    in this episode grant teaches us how to optimally get over your ex

    • @sprechchor
      @sprechchor 3 ปีที่แล้ว +1

      This is Stalin's wet dream algorithm

  • @SergioRMuniz
    @SergioRMuniz 4 ปีที่แล้ว +5

    Great presentation, Grant! So clear and concise, despite the depth. Makes it look easy and natural. Really good!

  • @nonhonome4080
    @nonhonome4080 4 ปีที่แล้ว +23

    If you can, please do more of these computer science applied math on the main channel. They are really interesting, and way easier to remember thanks to your way of explaining. Also seeing your face while explaining, like you do here, I think it's better then just having the graphics full screen

  • @MrNightLifeLover
    @MrNightLifeLover 4 ปีที่แล้ว +2

    Wow I've never seen anyone to explain dynamic programming simpler!

  • @johnhausmann2391
    @johnhausmann2391 18 ชั่วโมงที่ผ่านมา

    After the first round of computing least energy to bottom for each cell, you can get the minimum energy path by just following the lowest energy cells from bottom to top. That is faster than starting from the top cells and performing least energy path computations.

  • @abhchow
    @abhchow 4 ปีที่แล้ว +24

    Isn't the idea of using a seam at every step itself a greedy algorithm? Just based on my intuition, it should be possible to carve a seam that makes other future seams significantly less optimal, perhaps by cutting half of a seam that could be a future option.
    Of course, the greedy algorithm seems to work well enough, but perhaps there's a DP approach that could let us choose better seams by looking into potential future seams.

    • @shivamjalotra7919
      @shivamjalotra7919 4 ปีที่แล้ว +1

      I don't think you can decide the behaviour of some (optimal) seam afterwards if you take the optimal one this time in linear complexity. So being greedy and taking the best I can get at some time (T) is the best option.;

    • @jjalag
      @jjalag 4 ปีที่แล้ว +4

      I was thinking the same as you. Maybe the best approach for this would be to know from the first how many paths you will want to shrink at total

    • @harshmudhar96
      @harshmudhar96 4 ปีที่แล้ว

      Could always go bottom to top.

  • @VicenteSchmitt
    @VicenteSchmitt 4 ปีที่แล้ว +1

    This is just amazing! Grant not only knows a lot but explains in a way that makes it very simple

  • @ManthaarJanyaro
    @ManthaarJanyaro 4 ปีที่แล้ว

    That's why I love algorithms, they are made by most genuine persons.

  • @John_Chakder
    @John_Chakder 4 ปีที่แล้ว +6

    Everything about this video is great

  • @christophercrawford2883
    @christophercrawford2883 ปีที่แล้ว

    Nice video. Here's an alternative justification of three rows in the Sobel filter. 1) taking a derivation requires at least two points per output, so the dimension of the convolution will be one less. 2) if you want a gradient matrix, each slice (partial derivative) should be the same size so you need to average neigboring pixels in every other dimension. 3) if you average the derivativesto reduce noise, you should also average the (averaged) dimensions for the same reasons above. This gives you the vertical weights of [1; 2; 1].

  • @adityachk2002
    @adityachk2002 4 ปีที่แล้ว +18

    This must be grants lowest views but thanks a lot for putting such content and making it accessible

  • @weinsim3856
    @weinsim3856 4 ปีที่แล้ว +26

    I live in germany and im only in 10th grade but i still really enjoy watching these videos

  • @Clashtoons
    @Clashtoons 3 ปีที่แล้ว +12

    That was so cool.

  • @truefaceofevil
    @truefaceofevil 4 ปีที่แล้ว +3

    These lectures are amazing. Thank you

  • @rineeshparai1780
    @rineeshparai1780 3 ปีที่แล้ว

    Grant is a teaching genius.

  • @enisten
    @enisten 4 ปีที่แล้ว +1

    So, is this a good summary of what we are doing?
    1. Convolve the image with a sobel kernel (vertical or horizontal), which contains some negative values
    2. The resulting RGB object may have negative values in red, green, and/or blue channels
    3. Take the L1 norm of each pixel (adding the absolute values of three color components), obtaining a non-negative number, possibly greater than 1
    4. Repeat the same procedure with the other sobel kernel (horizontal or vertical)
    5. Take the L2 norm of the two sobel results

    • @enisten
      @enisten 4 ปีที่แล้ว +2

      Actually at 5:15, he seems to first convert the image into grayscale using a function called "brightness" _and then_ apply the sobel filter. So, the sobel filter was never applied to an RGB object. The result may still be negative at some pixels, but they go away when you take the L2 norm of the two sobel filter results. This seems to be a neater approach.

    • @TheJuliaLanguage
      @TheJuliaLanguage  4 ปีที่แล้ว +1

      @@enisten that's right, brightness is actually mean of the images -- we use mean instead of sum to keep it between 0 and 1 so that we can simply call Gray.(means) to show it as an image. The scaling does not matter for the algorithm, and of course you can choose a different brightness function if you wanted to.

  • @maxmetpt
    @maxmetpt 3 ปีที่แล้ว

    This is awesome, thanks. Especially the bit at the end - great potential for mischief!

  • @sorry4all
    @sorry4all 3 ปีที่แล้ว

    What a simple clever algorithm. That should be on every photo editting tools

  • @kevinmathervideo
    @kevinmathervideo ปีที่แล้ว

    Brilliant explanation of a brilliant concept 😮

  • @aakashbakhle1458
    @aakashbakhle1458 4 ปีที่แล้ว

    Using dynamic programming to make lockscreen wallpapers would also be an apt title. I loved the teal gradients in starry night ❤️

  • @piyushsingh178
    @piyushsingh178 4 ปีที่แล้ว +4

    At 22:48 why are we adding j==1 to dir while saving min item indices

    • @TheJuliaLanguage
      @TheJuliaLanguage  4 ปีที่แล้ว +3

      That's a great question. Very observant. It's because when j==1, your slice of the least_E array, i.e. least_E[j1:j2], does not have the south-west element, it only has two elements.. This needs a special case to handle -- if findmin says 1, the direction is actually 0 (go down), if it says 2, then the direction is 1 (go south-east).

    • @PhilBoswell
      @PhilBoswell 4 ปีที่แล้ว

      @@TheJuliaLanguage so is the other special case, the other end of the row when there isn't a *south-east* element, handled automagically somehow?

    • @piyushsingh178
      @piyushsingh178 4 ปีที่แล้ว +1

      ​@@PhilBoswell You're right that on the right side of the row, the array whose min we need again has only two elements. However (-1,0,1)[idx] will work fine because it can return either -1 or 0 , it'll never return 1. Similarly in the left side also the array has only two elements, but its problematic because -1 is invalid this time. Hence we need to handle left end specially by adding 1. That's what j==1 does (julia weirdly uses 1-indexed arrays instead of 0-indexed hence j==1 and not j==0)
      Thanks Grant!!

  • @ancbi
    @ancbi 4 ปีที่แล้ว +2

    I wish I teach as well as Grant. Right now I'm blaming it on my lack of time to prepare as I teach online as a side job. But really, even if I have more time, the bar he sets is pretty high.

  • @mingshey
    @mingshey 6 หลายเดือนก่อน +1

    26:54 Creepy, he’s still holding the hand of his vanished ex-girl friend!

  • @mr2octavio
    @mr2octavio 4 ปีที่แล้ว +5

    Instead of wasting my time watching a netflix show, I enjoyed learning about a fun way to make use of a triangle

  • @ShivaramakrishnaReddy
    @ShivaramakrishnaReddy 4 ปีที่แล้ว +1

    Why do we need to go only bottom to top? How does the algorithm care if we go from top to bottom in cumulative addition?
    Also, what if we want to reduce the image so as to keep the aspect ratio constant? Shouldn't we have two cumulative addition images one for top to bottom and another for left to right?
    If it's a 16:9 image, do we need to cut out top-bottom 16 times and then left-right 9 times and repeat?

  • @arikfriedman4442
    @arikfriedman4442 3 ปีที่แล้ว

    does anyone know where can I find the "original paper" he is referring to at 02:50?

  • @usama57926
    @usama57926 2 ปีที่แล้ว +1

    Grant you're great

  • @oghry
    @oghry 4 ปีที่แล้ว

    There is also a cool looking glitch effect when you just remove N pixels with minimal entropy in each row without connection them in path

  • @최승훈-c1x
    @최승훈-c1x ปีที่แล้ว

    Getting rid of Ex's feature was just hilarious

  • @LeiosLabs
    @LeiosLabs 4 ปีที่แล้ว +8

    "The great and one and only"
    Uh oh

  • @unchaynd7266
    @unchaynd7266 ปีที่แล้ว

    Just had a crazy idea!! What if you could use this same concept to slow down a music file without distorting it?? That is a puzzle that I don't think we've solved yet!

  • @ShreyasRavibighero6
    @ShreyasRavibighero6 4 ปีที่แล้ว +8

    This guy sounds really similar to the talking pi at 3blue1brown

  • @64_bit80
    @64_bit80 2 ปีที่แล้ว

    i was like "hold on this guy sounds familiar" and then it clicked

  • @ganeshkharad
    @ganeshkharad 4 ปีที่แล้ว

    just awesome explanation...!!!

  • @Pier_Py
    @Pier_Py 4 ปีที่แล้ว

    i translated your code in Python! it is great!!

  • @LOogt
    @LOogt 4 ปีที่แล้ว

    This is awesome. Thank you!

  • @drakoumell
    @drakoumell 9 หลายเดือนก่อน

    15:00 but dijkstra is faster, no?

  • @shzaizzhang4465
    @shzaizzhang4465 4 ปีที่แล้ว

    Wow , pretty like the exercises on Dynamic Programming in Introducton To Algorithms...

  • @krisschobert4484
    @krisschobert4484 4 ปีที่แล้ว +1

    THIS IS SO DOPE!!!!!! thanks grant! cool hair too!

  • @danieladelodun9547
    @danieladelodun9547 4 ปีที่แล้ว +4

    Edgy Mario looks like he's going through an emo phase.

    • @1e1001
      @1e1001 4 ปีที่แล้ว

      yea thats why he's edgy

  • @TheBBmTV
    @TheBBmTV 4 ปีที่แล้ว +3

    This is such incredibly good content, if the universities don't pick up their slack soon, youtube will just demolish them.

    • @TheMikebo
      @TheMikebo 4 ปีที่แล้ว +10

      You are aware that this is content from a university lecture at MIT?

    • @TheBBmTV
      @TheBBmTV 4 ปีที่แล้ว

      @@TheMikebo In that case: Exceptional job MIT.

  • @rpavlik1
    @rpavlik1 4 ปีที่แล้ว

    Wow, this is great explanation of these algorithms, really awesome.
    Also, you managed to utter "picks up on the edginess of Mario", which wins the internet today.

  • @guiwenluo1774
    @guiwenluo1774 4 ปีที่แล้ว

    wonderful lecture!!

  • @ukaszszczyt4912
    @ukaszszczyt4912 4 ปีที่แล้ว +1

    Thank you

  • @eldattackkrossa9886
    @eldattackkrossa9886 4 ปีที่แล้ว +1

    go grant go!

  • @adityarjl6557
    @adityarjl6557 2 ปีที่แล้ว

    billions of people are busy watching despacito and only handful of thousand people are watching this interesting video. explains why the world is stupid.

  • @dadireddysukumar2388
    @dadireddysukumar2388 ปีที่แล้ว

    Does solving the sub problems from top to bottom rather than from bottom top,would it give the same shortest energy path?

  • @nxone9903
    @nxone9903 2 ปีที่แล้ว

    Fascinating

  • @w1d3r75
    @w1d3r75 4 ปีที่แล้ว +1

    Awesome

  • @ohno5559
    @ohno5559 4 ปีที่แล้ว +1

    After removing a seam, is it best to recalculate the energy values or to continue using the original ones?

    • @0xDEAD_Inside
      @0xDEAD_Inside 4 ปีที่แล้ว +1

      Recalculation is the best.

  • @amaurylerouxdupeyron4523
    @amaurylerouxdupeyron4523 ปีที่แล้ว

    So good 🎉

  • @gz6616
    @gz6616 2 ปีที่แล้ว

    I got a question: do you re-compute energies after each seam removal?

  • @joaopedrorocha5693
    @joaopedrorocha5693 4 ปีที่แล้ว

    Talking in terms of energy it looks like a thunderbolt going down through the path of least energy :D
    It could be called the thunderbolt algorithm.

  • @imranq9241
    @imranq9241 4 ปีที่แล้ว

    Has there been any study of seam carving with horizontal directions instead of just downward?

  • @lucha6262
    @lucha6262 4 ปีที่แล้ว

    Where can I get started learning Julia?

  • @Dhanush-zj7mf
    @Dhanush-zj7mf 4 ปีที่แล้ว +2

    Which programming did Grant used there not looks like python but almost similar to it.

    • @brandonbahret5632
      @brandonbahret5632 4 ปีที่แล้ว +4

      This course uses the Julia programming language.

    • @keshavkasat9465
      @keshavkasat9465 4 ปีที่แล้ว

      lol..read the name of the channel. I've heard this language is great for programming mathematical models.

  • @SayanSamanta123
    @SayanSamanta123 4 ปีที่แล้ว

    Can you parallel this with the concept of value functions from reinforcement learning/marcov decision processes?

  • @theadamabrams
    @theadamabrams 4 ปีที่แล้ว

    Great video! Quick question: your seams go top-to-bottom (for horizontal resizing), so why use √(vx²+vy²) instead of just |vx|, that is, only convolving with sx?

    • @deinauge7894
      @deinauge7894 4 ปีที่แล้ว +1

      that would lead to shrinking of the objects, for example the horizontal tree branch or other horizontal lines.
      what concerns me about this energy function is, that is renders single pixels and one pixel wide lines as completely unimportant, even if they have the biggest contrast to their surroundings. the energy of the neighboring pixels would be considered very high though ^^

  • @soejrd24978
    @soejrd24978 4 ปีที่แล้ว

    Didn't know it was you Grant :)

  • @fburton8
    @fburton8 4 ปีที่แล้ว

    Quality!

  • @IJaba27
    @IJaba27 3 ปีที่แล้ว

    No link to the notebook ?

  • @markcase9534
    @markcase9534 2 ปีที่แล้ว

    Gold mine

  • @cicigg2045
    @cicigg2045 4 ปีที่แล้ว +3

    Grant so handsome, lecture so amazing, using my whole attention to learn this material! Thanks~

  • @henrmota
    @henrmota 4 ปีที่แล้ว

    Just one question. After eliminating one steam? We have to recalculate everything again? Because of steam pixel overlap.

    • @estivale8193
      @estivale8193 3 ปีที่แล้ว +1

      you can recalculate everything, or you can recalculate only parts that can be affected by the removal of a seam.
      Seam: X
      Original value: O
      for recalculation: Y
      OOOOOXOOO
      OOOOOXOOO
      OOOOXOOOO
      OOOOXOOOO
      OOOXOOOOO
      Then you recalulate these:
      YYYYYYYY
      YYYYYYYO
      OYYYYYOO
      OOYYYOOO
      OOOOOOOO
      bottom row should not be recalculated because it never changes.

    • @henrmota
      @henrmota 3 ปีที่แล้ว

      @@estivale8193 Thanks, because I am trying to implement this in the web with the gpu support. But this is a very particular calculation.

  • @DjNarda
    @DjNarda 4 ปีที่แล้ว

    Is the full course getting uploaded?

    • @TheJuliaLanguage
      @TheJuliaLanguage  4 ปีที่แล้ว

      yes it will be. you can bookmark mitmath.github.io/18S191/Fall20/ to keep tabs. Schedule is on the front page

  • @ahmadmoussa3771
    @ahmadmoussa3771 4 ปีที่แล้ว

    Why hasn't this been used more as a preprocessing step for deep learning models?

    • @shivamjalotra7919
      @shivamjalotra7919 4 ปีที่แล้ว +1

      I think the idea of preprocessing in DL models is to provide just enough knowledge to make the model generalise and not overfit. Here almost all the knowledge remains intact, so using it for preprocessing would not be beneficial.

    • @ahmadmoussa3771
      @ahmadmoussa3771 4 ปีที่แล้ว

      @@shivamjalotra7919 I understand what you mean. I could see it useful for models that take as input images of a fixed resolution. Resizing images to fit this resolution can be detrimental sometimes, I would rather use this algorithm for that purpose. But I understand your point of view and I agree, I would use this step for pre-processing to make all the images the same size, but then still add rotation and translation pre-processing

  •  4 ปีที่แล้ว

    Oh I missed the live class!

  • @johnwaczak8028
    @johnwaczak8028 4 ปีที่แล้ว

    Anyone catch the title of the seam-carving paper?

    • @franksonjohnson
      @franksonjohnson 4 ปีที่แล้ว +5

      Found it: "Seam Carving for Content-Aware Image Resizing". graphics.cs.cmu.edu/courses/15-463/2012_fall/hw/proj3-seamcarving/imret.pdf

  • @obi-wankenobi2591
    @obi-wankenobi2591 4 ปีที่แล้ว

    This feature is alredy implemented in photoshop works both ways

  • @turtles-qt3ry
    @turtles-qt3ry 4 ปีที่แล้ว

    Other profs: 200 views
    Grant: 1.6k views

  • @voxhominem
    @voxhominem 4 ปีที่แล้ว

    what programming language is he using?

  • @silberlinie
    @silberlinie 4 ปีที่แล้ว

    Photoshop can do it perfectly well.
    It’s called content preserving scaling

    •  4 ปีที่แล้ว

      Probab photoshop does this way as well

  • @Ganondurk
    @Ganondurk 4 ปีที่แล้ว

    Content aware scaaaaaalle

  • @shivamjalotra7919
    @shivamjalotra7919 3 ปีที่แล้ว +1

    12:56

  • @luanmagioli8108
    @luanmagioli8108 3 ปีที่แล้ว

    What is the animations software?

    • @bigmistqke
      @bigmistqke 2 ปีที่แล้ว +1

      Manim, 3b1b's custom software

    • @luanmagioli8108
      @luanmagioli8108 2 ปีที่แล้ว

      Thanks!!!!! 🤝🏼

  • @microhoarray
    @microhoarray 4 ปีที่แล้ว

    Is this a some kind of magic?🤏

  • @neoqueto
    @neoqueto 4 ปีที่แล้ว

    I'm not a programmer but seam duplication with interpolation should also be easily doable?

  • @andregn4483
    @andregn4483 4 ปีที่แล้ว

    I wonder what the results would be if you used some Machine Learning attention activation (like a GAM) instead of a simple edge detection. Maybe it could "understand" the important regions and perform better.

  • @echolee601
    @echolee601 4 ปีที่แล้ว

    Cool!

  • @mirellahi5187
    @mirellahi5187 4 ปีที่แล้ว

    or a toilet brush to clean all of that yest thats been accumulating for years in the khukhus

  • @neve177
    @neve177 2 ปีที่แล้ว

    It's the meme algorithm

  • @herohamp2
    @herohamp2 4 ปีที่แล้ว

    Where do I know his voice from?

  • @wacesferpit
    @wacesferpit 4 ปีที่แล้ว

    I mean, isn't this already a thing anyway? Content Aware Scaling

  • @aniksamiurrahman6365
    @aniksamiurrahman6365 4 ปีที่แล้ว

    But why did Julia drop OpenCL support?

  • @PacificBird
    @PacificBird 4 ปีที่แล้ว

    Is this Loopop lol

  • @justforfun2238
    @justforfun2238 4 ปีที่แล้ว +2

    Is he the 3b1b guy?

    • @Dezomm
      @Dezomm 4 ปีที่แล้ว +1

      yes he is!

  • @mirellahi5187
    @mirellahi5187 4 ปีที่แล้ว

    yors mathas dripping khus khus.

  • @noninvasive_rectal_probe8990
    @noninvasive_rectal_probe8990 4 ปีที่แล้ว +1

    LOVE GRANT LOVE GRANT LOVE GRANT LOVE GRANT
    I AM DEEPLY DEPRESSED THAT HE WILL DIE

  • @nberggie5784
    @nberggie5784 4 ปีที่แล้ว

    no squish? lol look at that pomegranate

  • @williammorris1763
    @williammorris1763 5 หลายเดือนก่อน

    You're 3Blue1Brown change my mind.