CS 194-26 Project 6 [acc id: aez]
Overview
Lightfield Camera
Part 1: Depth Refocusing
- The main idea was to shift all the images to align to the central image of position
images[8, 8]
out of a 17x17 grid of images. To vary the depth, I scaled the shifts appropriately
- The basic shifts were computed with the image coordinates (information embedded within the images of the Stanford Lightfield Archive)
- The scaled shifts were computed by scaling the basic shifts. I found that the scales of range
[-0.4, 0.4]
worked well
- Mathematically:
shift = scale * (coords[8, 8] - coords[x, y])
Images
Image |
|
|
|
Scale |
-0.4 |
0.04 |
0.4 |
Gif
Part 2: Aperature Adjustment
- A small aperature gives the image little depth of field, meaning that every object is clear. A large aperature gives the image depth of field, aka “focus/bokeh”.
- Small aperature is achieved by taking the average small number of images
- Large aperature is achieved by taking the average of most/all images
- To simulate the effect of adjusting the aperature, I varied the number of images to be averaged as a function of the distance from the central point
images[8,8]
out of the 17x17 grid images.
- The distances to center based on range
[0, 100]
adequately captured the different aperatures
Images
Image |
|
|
|
Distance from center |
10 |
50 |
100 (all images) |
Gif
Coolest thing learnt
- Probably the power/concepts of parallax in varying depth! Initially I thought that to vary parallax to refocus the image, you would have to vary which point all the images should align to. I later found that the scale is what affects the refocusing.
- In that vein, I wonder if there would be any effects on varying where all the images are centered on. For this project, I picked
images[8,8]
and tried other positions but there were no noticeable changes. I am curious to see if this is true for other images.
Seam Carving
Part 1: Implementation
Energy function
- Implemented by taking a simple squared difference between neighboring pixels. Another possible energy function would be a gradient function similar to that in Project 2.
- This function is used to generate the energy matrix.
Seam identification
- A cumulative energy path marix is generated from the energy matrix from the top to bottom to find vertical seams.
- With the cumulative energy path matrix, the vertical seam is found simply by retracing back from the bottom to the top of the cumulative energy matrix by finding the minimum path.
Horizontal vs. vertical
- I did the implementation to find and remove vertical seams, and simply transposed the input to do horizontal seam removal.
Part 2: Carving (Horizontal and Vertical)
Horizontal
Vertical
Part 3: Failure Cases
- I found two photos to be particularly tricky and consider them failure cases.
Water bottle
- The image only had one main feature - what I expected the algorithm to do would be to trim the background. Instead, my bottle ended up being carved
- This could be due to the relative uniformity in color of the bottle as compared to the surrounding surface which captures shadows of light
Original |
Carved |
|
|
Celebrity photo
- This is a smaller failure cases. But I noted that distortions in certain faces can be seen when more than 150 pixels were shaved off from the original image
Original |
Carved (150px) |
Carved (300px) |
|
|
|
Part 4: Bells and Whistles
Optimization
- I implemented optimization by creating and offline and online function
- Offline: precomputes all the seams and saves them in an array
- Online: based on the target resize
Seam Insertion
- I implemented seam insertion simply by identifying seams for removal as per in seam carving, and then inserted a seam at those target locations based on the average of the neighboring seams.
Results
Original |
Seam Insertion |
|
|
Coolest thing learnt!
- When implementing seam insertion, I learnt that if you iteratively inserted seams based on the lowest energy seam, seams would always be inserted at the same location.
- I followed the direction of the paper and instead inserted seams at positions based on seams identified for removal.
References
- Lightfield Camera: Photos were taken from Stanford Lightfield Archive
- Seam Carving: All photos are taken by me, except for the following taken from Google images
- Celebrity photograph (seen in part 3)
- Memorial glade (seen in both part 2 and part 4)
CS 194-26 Project 6 [acc id: aez]
Overview
Lightfield Camera
Part 1: Depth Refocusing
images[8, 8]
out of a 17x17 grid of images. To vary the depth, I scaled the shifts appropriately[-0.4, 0.4]
worked wellshift = scale * (coords[8, 8] - coords[x, y])
Images
Gif
Part 2: Aperature Adjustment
images[8,8]
out of the 17x17 grid images.[0, 100]
adequately captured the different aperaturesImages
Gif
Coolest thing learnt
images[8,8]
and tried other positions but there were no noticeable changes. I am curious to see if this is true for other images.Seam Carving
Part 1: Implementation
Energy function
Seam identification
Horizontal vs. vertical
Part 2: Carving (Horizontal and Vertical)
Horizontal
Vertical
Part 3: Failure Cases
Water bottle
Celebrity photo
Part 4: Bells and Whistles
Optimization
Seam Insertion
Results
Coolest thing learnt!
References