The goal of this project is to use content-aware image resizing to shrink images to the desired dimensions. To do this, we must identify the lowest energy seam traveling in a certain direction, and remove that seam. That way, we can preserve the important parts of the image while cutting out parts of the background.
To find the lowest energy seam, we first define an energy function that would assign an energy value to every pixel. The energy function I used was the gradient of the pixel in each direction. Then, we use the following dynamic programming relation to find the total energy of a seam (either vertically or horizontally):
After calculating the total energy of each seam, we identify the seam with the lowest total energy, and remove it from the image. We repeat this procedure until we reach our desired dimensions.
Some examples did not work out as well as the ones above, mainly because seam carving does not work well with faces or objects with detailed shapes or features.
We create the tilt shift effect by first specifying the focus area. The user can select the upper and lower bound of the focus area, and from that we create a rectangular mask. We then make a Gaussian stack of the original image, and a Gaussian stack of the mask, using the mask stack to determine how blurry each pixel of the output image is. The output image would then have the focus area in focus, and the areas surrounding it increasingly blurred. This creates the fake miniature effect that we're looking for:
To have complex DOF regions, we need to account for masks that are not horizontal and rectangular. We define the masks manually, then perform the same blurring procedure as above to create the output images. As we can see, these look much better for some input images:
All images used in this project are either original or found online with permission to distribute.