15-463 P2

Joe Gershenson

I obtained some great images from Flickr (under attribution, nonprofit license) to demonstrate how my code worked. In some cases, the results were pretty good. In others, though, the image was a particularly bad one to resize and the results were amusing! After a bit of tweaking my pixel-energy function, I settled on looking at the sum of squared differences between a pixel's RGB values and those of its neighbors. Looking at too many neighbors resulted in degrading the quality of the function, but too few neighbors didn't give me enough to work with. To solve this problem, I had the weights attached to these differences in brightness degrade as distance squared -- thus, a pixel that was completely different from its neighbor would be nine times as interesting as a pixel that was completely different from a pixel which was three pixels away. (Or, to be more precise, it was assigned nine times as many points for that difference -- it might have also picked more up from other places).

A good way to test my pixel energy function was to use the MATLAB imagesc (image scale) function, which interpreted my matrix of pixel energy values as a colormap. If the colormap did a good job of coloring the parts of the picture by importance, I could be reasonably sure that the seam-carving part of the program would work correctly.

Click on a thumbnail to see a larger image.

Good Images

Swan and Ship by Prof Shorthair

This black-and-white image resized beautifully in either direction. All the important components (ship, swan, and land) are identified as bad areas to remove, and the ripples in the sea do a great job of hiding the carve lines.

One point of interest -- when resizing it vertically, look at the water on the edges of the ship -- the algorithm is perfectly comfortable taking out sky in most places, but needs to leave the ship in here, so it takes out water instead.

Original
Vertical Resize
Horizontal Resize


Black Diamond after sunset 9-19 by ilikethenight

Resizing this picture horizontally, we can see the algorithm do a good job of identifying the interesting parts of the sky and stitching out the boring stuff in the middle and on the right. The ground scales well to match the new view.

Original
Horizontal Resize


Golden Sunrise by Cap'n Surly

Shrinking this picture vertically shows us a great argument for using this algorithm, as the buildings are preserved very well. One slight flaw -- notice the artifacts near the Space Needle. The energy function is reluctant to blur or distort the background because of its high percieved significance there, while a professional (manual) editing of the image would probably blur these clouds to make them appear naturally behind the Space Needle.

Original
Vertical Resize


Pictionary by Jeronimo's Eye

These travelers spelled out the word 'BOLIVIA' while visiting the desert there. Notice how resizing the image vertically preserves the people almost completely, as well as keeping the surreal landscape, while removing sky and desert.

Original
Vertical Resize


Once Upon the Sky by Code Poet

The algorithm did an excellent job preserving the perspective overall -- much better than distorting the image would have done. There are some tree trunks which don't look right, though -- a great approach here might be to blur lines that don't overlap after seam carving.

Original
Vertical Resize


(untitled) by Code Poet

The Alaskan landscape is preserved very well in this image -- note how the town is barely affected but the surrounding landscape is truncated.

Original
Horizontal Resize


Path Through The Trees by Prof Shorthair

The focus of this image is changed from the path to the sky, but it looks pretty good nonetheless. All of the interesting items in the picture are preserved.

Original
Horizontal Resize




Not-So-Good Images

My apologies to the original artists for mangling their work here.

Yellow Line Cat by Prof Shorthair

Actually, this image resized very well. It's just that, uh, the point of the image was the cat. And... apparently an all-black cat doesn't score very well on the energy function, except at the edges?

Original
Horizontal Resize


The show is over, say goodbye by adettara

This was one of the first images I tested, and it never worked very well at all. Any resizing leads to some very obvious effects on the stems and buds of the plants, making it clear that it's extremely difficult to hide carving along steep diagonal lines.

Also, notice how the right side of the background is essentially condensed to a single line.

Original
Horizontal Resize