Seam carving (or liquid rescaling) is an algorithm for content-aware image resizing, developed by Mitsubishi Electric Research Laboratories (MERL). It functions by establishing a number of seams (paths of least importance) in an image and automatically removes seams to reduce image size or inserts seams to extend it. Read the paper at:
Make sure to install the following dependencies to avoid build errors:
git clone https://github.com/wthrajat/seamcarving.git
cd seamcarving && mkdir build && cd build && cmake .. && make
After compilation, this will build an executable "seam_carving"
at ./build/app/
:
./build/app/seam_carving # Executable file
./build/app/seam_carving <input_image> <direction> <number of seams> <mode> <x> <y> <w> <h>
# OR
./build/app/seam_carving <input_image> <direction> <number of seams>
<input_image> : image_name.extension [required]
<direction> : 'h' OR 'v' [required]
'h' for horizontal seam removal
'w' for vertical seam removal
<number of seams> : integer [required]
<mode> : 'r' OR 'p' [optional]
'r' for removal
'p' for protection
<x> <y> <w> <h> : Specifies the Region of Interest [optional]
'x' X-coordinate
'y' Y-coordinatew
'w' Width of the ROI
'h' Height of the ROI
./build/app/seam_carving assets/ronaldo.jpeg v 300
Resized | Original |
---|---|
./build/app/seam_carving assets/tower.jpg v 300
Resized | Original |
---|---|