Giter VIP home page Giter VIP logo

motionamplification's Introduction

MotionAmplification

This is a Python implementation of the Motion Amplification algorithm. The algorithm is based on the paper "Eulerian Video Magnification for Revealing Subtle Changes in the World" by MIT researchers Hao-Yu Wu, Michael Rubinstein, Eugene Shih, John Guttag, Frédo Durand, and William T. Freeman. The paper can be found here.

The algorithm works by amplifying the motion in a video. It does this by first decomposing the video into its spatial and temporal components using a Laplacian pyramid. The temporal component is then amplified by a user-defined factor and added back to the spatial component. The resulting video is then reconstructed from the amplified spatial component.

How to use the code

from MotionAmp.motion_amplification import eulerian_amplification
from MotionAmp.motion_amplification import lagrangian_amplification
import time

factor = [0, 70, 0] #amplication factor per color channel
band = [0.4, 3] #bandpass filter what frequencies to amplify
downsample_level = 3 #downsample the video to speed up the process and eliuminate high frequency noise

video = eulerian_amplification('face_source.wmv', factor=factor, band=band, downsample_level=downsample_level)

#result is stored under output.mp4 in the current directory

Technical details

  • Step1: The paper first decomposes the video into its spatial and temporal components using a Laplacian pyramid. Here however we use the Gaussian pyramid to decompose the video into a lower resolution version of the video.It applies a Gaussian filter to the input image to reduce high-frequency noise. This is achieved using a convolution operation with a Gaussian kernel. After smoothing, the image is downsampled by keeping only every alternate pixel in both rows and columns. This reduces the resolution of the image by a factor of 2. This process is repeated to obtain a series of images of decreasing resolution. The resulting images are called the Gaussian pyramid.

    image

  • Step2: Now we have a low resolution version of the video. We can now amplify the motion in the video. This process is done on a pixel by pixel basis where we deconstruct the change in pixels over time using a Fast-Fourier-Transform. Using this transform we can isolate the frequency of the motion in the video and isolate a certain bandpass of frequencies to hone in on the desired frequencies.

  • Step3: After Isolating the fequencies within the Fast-Fourier Transform we amplify the bandpass-frequencies and reconstruct the video using the inverse Fast-Fourier-Transform. In the example above we amplify the frequencies by a factor of 70 and focus on a bandpass of 0.4 to 3 Hz, isolating the heart rate of the person in the video. image

  • Step4: Now that we are left with a video with amplified motion we can reconstruct the video using the inverse Gaussian pyramid. This is done by upsampling the video and adding the amplified motion to the original video. This process is repeated until we have the original resolution of the video. Because we lose some information when downsampling the video we will have to interpolate the video to fill in the missing information. Or in our case we can just use the original video to fill in the missing information by overplotting the reconstructed video on top of the original video.

motionamplification's People

Contributors

levi2234 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.