Giter Site home page Giter Site logo

vision-hw3's Introduction

CSE 455 Homework 3

Welcome friends,

It's time for optical flow!

To start out this homework, copy over your process_image.c, filter_image.c, resize_image.c, harris_image.c, andpanorama_image.c files from hw2 to the src directory in this homework. We will be continuing to build out your image library.

1.1 Integral images

Optical flow has to run on video so it needs to be fast! We'll be calculating structure matrices again so we need to do aggregated sums over regions of the image. However, instead of smoothing with a Gaussian filter, we'll use integral images to simulate smoothing with a box filter.

Fill in make_integral_image as described in the wikipedia article. You may not want to use the get_pixel methods unless you do bounds checking so you don't run into trouble.

1.2 Smoothing using integral images

We can use our integral image to quickly calculate the sum of regions of an image. Fill in box_filter_image so that every pixel in the output is the average of pixels in a given window size.

2. Lucas-Kanade optical flow

We'll be implementing Lucas-Kanade optical flow. We'll use a structure matrix but this time with temporal information as well. The equation we'll use is:

2.1 Time-structure matrix

We'll need spatial and temporal gradient information for the flow equations. Calculate a time-structure matrix. Spatial gradients can be calculated as normal. The time gradient can be calculated as the difference between the previous image and the next image in a sequence. Fill in time_structure_matrix.

2.2 Calculating velocity from the structure matrix

Fill in velocity_image to use the equation to calculate the velocity of each pixel in the x and y direction. For each pixel, fill in the matrix M, invert it, and use it to calculate the velocity.

Try calculating the optical flow between two dog images:

a = load_image("data/dog_a.jpg")
b = load_image("data/dog_b.jpg")
flow = optical_flow_images(b, a, 15, 8)
draw_flow(a, flow, 8)
save_image(a, "lines")

It may look something like:

3. Optical flow demo using OpenCV

Using OpenCV we can get images from the webcam and display the results in real-time. Try installing OpenCV and enabling OpenCV compilation in the Makefile (set OPENCV=1). Then run:

optical_flow_webcam(15,4,8)

4. Turn it in

Turn in your flow_image.c on canvas under Assignment 3.

vision-hw3's People

Contributors

pjreddie avatar

Stargazers

Mahdiyar Molahasani avatar

Watchers

James Cloos 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.