MircoWerner / SeamCarving

Seam Carving algorithm in Java.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SeamCarving

My implementation of the Seam Carving algorithm (in Java). Given an input image, the algorithm determines and removes the vertical pixel path in the image that has the least energy, i.e. the least change in color along the path, using dynamic programming. With this method, the size of an image can be successively reduced by removing mostly the background of the image while leaving relevant objects almost unchanged.

This small project was inspired by the MIT lecture https://www.youtube.com/watch?v=rpB6zQNsbQU by Grant Sanderson. For more information on the algorithm watch the lecture or see the wikipedia page https://en.wikipedia.org/wiki/Seam_carving.

IMAGE ALT TEXT

Build and Usage

  1. mvn package
  2. cd target
  3. java -jar SeamCarving-1.0.0.jar <path to input image> <path to output folder> <number of iterations> <store debug images> <store final result only>
    • path to input image: string
    • path to output folder: string
    • number of iterations: integer (how many paths to cut; the image is resized to original_width minus iterations in pixels)
    • store debug images: boolean [true|false] (store images showing the luminance, gradient, path)
    • store final result only: boolean [true|false] (store the images of the final iteration only)

Results

Input

The_Persistence_of_Memory
https://en.wikipedia.org/wiki/File:The_Persistence_of_Memory.jpg

1st iteration

Luminance:
luminance_1
Gradient:
gradient_1
Path with lowest energy:
cut_path_1
Output:
output_1

64th iteration

Output: notice that the relevant objects in the image were left almost unchanged
output_64

About

Seam Carving algorithm in Java.

License:MIT License


Languages

Language:Java 100.0%