# CPSC-425-Computer-Vision
The purpose of this assignment is to understand and implement the optical flow algorithm of Bruce D. Lucas and Takeo Kanade.
The assignment
This assignment is based on work described in the classic 1981 paper, “An iterative image registration technique with an application to stereo vision,” (PDF) by Lucas and Kanade. If you read this paper, you will realize two things. First, the term “optical flow” does not appear in the paper. As the title suggests, the target application was stereo vision. Second, the method described in the paper is much more general (and therefore more complicated) than the simple version we use here for optical flow. It is not necessary to understand the Lucas–Kanade paper in detail for this assignment. Sufficient for our purposes is to understand the Wikipedia article Lucas–Kanade method.
The zip file containing an eight frame image sequence and skeleton code is hw6.zip. Download this file to your directory and unzip with the command
unzip hw6.zip
The assign directory contains one sequence of images demonstrating optical flow taken from the Middlebury optical flow dataset. The images we use were created synthetically, an approach often used in optical flow research. Information about the dataset (Grove2), other datasets, and a paper comparing state–of–the–art approaches to optical flow, can be found at:
http://vision.middlebury.edu/flow/
You can run the skeleton program by typing
python OpticalFlow.py
at the command prompt. The script will display the first frame in the image sequence.
The Lucas–Kanade optical flow method is a dense method. That is, the method computes optical flow at every pixel in each frame. To keep things simple for this assignment, we instead compute optical flow only at a given point in each frame. The point you are assigned is based on your student number, as described in the skelton program.
As written, the script displays a red cross at the given point and a yellow diamond at the location where the given point has moved to in the next image. Of course, in the skeleton program, no actual optical flow has yet been computed. Instead, the skeleton program displays a hard-coded optical flow value (set as [-1,2]). This will allow you to orient yourself to the coordinate system used.
In this assignment, you will re-use functions from Assignment 2. Of course, you'll need to be sure your functions from Assignment 2 are debugged and working correctly.
(5 points)
We consider input images two frames at a time. The first step is to estimate the partial derivatives Ix, Iy and It. Note: Ix and Iy are partial derivatives with respect to position, x and y, in the first frame. It is the partial derivative with respect to time from the first frame to the second.
Derivatives are estimated in the function Estimate_Derivatives. A simple approach suffices. The first frame is smoothed with a 2D Gaussian (default sigma=1.5). Do this by uncommenting the first line in the function definition (where gaussconvolve2d is the function you wrote in Assignment 2).
If in doubt, display the smoothed image to confirm that it is being correctly computed.
To complete the function, estimate the partial derivatives Ix, Iy for the first frame using first central differences in the x and y directions respectively. Hint: Use the numpy function np.gradient to compute both central differences efficiently.
Finally, estimate the partial derivative It using pixel differences between the first frame and the second frame. To make this estimate a bit more robust, smooth both original frames with a boxfilter of size n (default n=3) prior to computing the pixel differences. Use your function boxfilter from Assignment 2 to compute the required boxfilter.
Before proceeding, check your implementation of Estimate_Derivatives to make sure all your partial derivative estimates returned are the same size as the original image.
(10 points)
Complete the definition of the function Optical_Flow given in the skeleton program. This is where you compute
v = (ATA)-1ATb
as described in the Wikipedia article Lucas–Kanade method.
Make sure that you compute optical flow at the single (x, y) position assigned to you, based on student number. You compute optical flow using a square window of size window_size centered at your given (x, y). We will follow the convention that window_size is an odd number (so that its center row and column are well defined). Hints: You can stack two numpy arrays using the function np.vstack. Similarly, you can flatten a 2-dimenstional numpy array to a 1-dimensional array using the function np.flatten. Also, you can use the function pinv in the numpy linalg module to compute the (Moore-Penrose) pseudo-inverse of a matrix.
A test script to run optical flow code on frame07.png and frame08.png, the first two frames in the test sequence, is included in the skeleton program. Run this for the point that you have been assigned. It will be difficult to judge the accuracy of the computed optical flow when the displacement in small. For debugging purposes, the script draws the flow directly on the first frame, increasing its magnitude (by a factor scale) so that you can confirm that the direction of optical flow is (at least qualitatively) correct.
(5 points)
There are a total of 8 frames in the test sequence. By uncommenting the last portion of the skeleton program, you can run the Optical_Flow function iteratively, using the (updated) position of your given (x,y) point at frame k as the initial point for estimating optical flow to frame k+1, for k=7,8,9,10,11,12,13,14.
You may or may not be successful in tracking your given feature over all 8 frames, given the default settings. Try experimenting with different window sizes and choices of sigma for the Gaussian smoothing that work best for your given feature. Here, “work best” means that the original feature remains within the window used to compute optical flow and continues to be well located at the window's centre row and column.
Report the last frame at which tracking was successful and document the sequence of (x, y) positions of your feature in each frame successfully tracked. Include a side-by-side image of the initial frame and the final frame (successfully tracked) with a line drawn between the initial feature location and the final feature location. Be sure to report the window size and Gaussian sigma used to obtain your best result.
Of course, you're free to experiment with other feature locations and with other image sequences. But, you are only required to report results for your assigned feature point.
(5 points)
There are locations in an image where Lucas–Kanade optical flow will fail, regardless of choice of window size and sigma for Gaussian smoothing. Describe two such situations. Note: It is sufficient to describe situations. It is not necessary to demonstrate them.
没有合适的资源?快使用搜索试试~ 我知道了~
CPSC-425-Computer-Vision
共281个文件
png:168个
jpg:64个
pkl:14个
需积分: 0 1 下载量 64 浏览量
2021-05-21
17:46:42
上传
评论
收藏 10.01MB ZIP 举报
温馨提示
CPSC-425-计算机视觉
资源详情
资源评论
资源推荐
收起资源包目录
CPSC-425-Computer-Vision (281个子文件)
a5.docx 722KB
A4.docx 361KB
A7.docx 224KB
A6.docx 184KB
a.JPG 153KB
showpyramid.jpg 67KB
tr0.jpg 64KB
trx531.jpg 64KB
trx3.jpg 64KB
trx4.jpg 63KB
trx533.jpg 63KB
trx532.jpg 63KB
trx5.jpg 63KB
trx8.jpg 63KB
trx6.jpg 63KB
trx7.jpg 63KB
tree.jpg 62KB
students.jpg 47KB
W_org.jpg 46KB
Z_org.jpg 44KB
jb2.jpg 43KB
jb3.jpg 41KB
st0.jpg 34KB
stx3.jpg 33KB
stx531.jpg 33KB
stx532.jpg 33KB
stx533.jpg 33KB
stx4.jpg 33KB
stx5.jpg 33KB
stx6.jpg 33KB
stx7.jpg 32KB
stx8.jpg 32KB
stx9.jpg 32KB
jb4.jpg 30KB
Y_org.jpg 30KB
jbx1.jpg 30KB
jbx2.jpg 30KB
jbx3.jpg 30KB
jbx533.jpg 29KB
jbx531.jpg 29KB
jbx532.jpg 29KB
jbx4.jpg 29KB
jbx5.jpg 29KB
jbx6.jpg 29KB
jb5.jpg 28KB
jbx9.jpg 28KB
jbx8.jpg 28KB
jbx7.jpg 28KB
jb6.jpg 27KB
judybats.jpg 26KB
results_Z3.jpg 25KB
results_Z0.jpg 25KB
X_org.jpg 21KB
U_org.jpg 20KB
jb1.jpg 20KB
donkey.jpg 15KB
donkey2.jpg 15KB
Denim.jpg 13KB
result_donkey.jpg 13KB
results_X50.jpg 11KB
results_X0.jpg 11KB
results_Y0.jpg 10KB
results_Y50.jpg 10KB
jb0.jpg 7KB
results_Denim.jpg 7KB
results_W0.jpg 6KB
results_U0.jpg 4KB
template.jpg 1KB
library.key 629KB
library2.key 306KB
scene.key 246KB
box.key 228KB
basmati.key 206KB
book.key 174KB
keypoints 53KB
README.md 7KB
README.md 6KB
README.md 5KB
README.md 5KB
README.md 5KB
README.md 4KB
README.md 84B
README.md 27B
library.pgm 230KB
library2.pgm 125KB
scene.pgm 108KB
box.pgm 71KB
book.pgm 53KB
basmati.pgm 45KB
Z_fill_region.pkl 156KB
Z_texture_region.pkl 156KB
X_texture_region.pkl 66KB
X_fill_region.pkl 66KB
ORG_fill_region.pkl 65KB
ORG_texture_region.pkl 65KB
Y_fill_region.pkl 49KB
Y_texture_region.pkl 49KB
Denim_fill_region.pkl 25KB
Denim_texture_region.pkl 25KB
W_fill_region.pkl 15KB
共 281 条
- 1
- 2
- 3
xianzhang
- 粉丝: 20
- 资源: 4594
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0