If we just average all the images generated by the lightfield camera, we will get an average image that focuses on parts that are displaced less than others. In general, this will result in the faraway objects being in focus while the closer objects will be out of focus. Therefore, to adjust the focus of the average image, we can shift all the images around a designated center image. Doing this will make the average image focus on the designated center image (as it isn't displaced at all).
By scaling the shifts by a factor alpha, we can adjust how much, and which parts, of the image are in focus or out of focus.
To similate different aperture sizes, we can use the same displacement shift algorithm described in part 1 but limit the number of images we use. To accomplish this, I set an arbitrary R value and only used the images that were displaced within R away from the center image.