Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wthrajat/seamcarving

C++ implementation of the Seam Carving Algorithm using Dynamic Programming. Available to use as a C++ binary
https://github.com/wthrajat/seamcarving

cpp dynamic-programming glew image opencv seamcarving

Last synced: about 2 hours ago
JSON representation

C++ implementation of the Seam Carving Algorithm using Dynamic Programming. Available to use as a C++ binary

Awesome Lists containing this project

README

        

# Seam Carving ![OpenCV](https://img.shields.io/static/v1?style=for-the-badge&message=OpenCV&color=5C3EE8&logo=OpenCV&logoColor=FFFFFF&label=) ![C++](https://img.shields.io/static/v1?style=for-the-badge&message=C%2B%2B&color=00599C&logo=C%2B%2B&logoColor=FFFFFF&label=) ![CMake](https://img.shields.io/static/v1?style=for-the-badge&message=CMake&color=064F8C&logo=CMake&logoColor=FFFFFF&label=) [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE)

[Seam carving](https://en.wikipedia.org/wiki/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:
- [Original paper](https://perso.crans.org/frenoy/matlab2012/seamcarving.pdf)
- [ACM Digital Library](https://dl.acm.org/doi/10.1145/1275808.1276390)

## Dependencies

Make sure to install the following dependencies to avoid build errors:
- [Glew](https://archlinux.org/packages/extra/x86_64/glew/)
- [lib32-glew](https://archlinux.org/packages/multilib/x86_64/lib32-glew/)
- [CMake](https://cmake.org/download/)
- [OpenCV](https://opencv.org/releases/)

## Build

```sh
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/`:
```py
./build/app/seam_carving # Executable file
```

## Usage

```console
./build/app/seam_carving

# OR

./build/app/seam_carving

```

## Arguments
```rust
: image_name.extension [required]

: 'h' OR 'v' [required]
'h' for horizontal seam removal
'w' for vertical seam removal

: integer [required]

: 'r' OR 'p' [optional]
'r' for removal
'p' for protection

: Specifies the Region of Interest [optional]
'x' X-coordinate
'y' Y-coordinatew
'w' Width of the ROI
'h' Height of the ROI
```

## Examples

```rust
./build/app/seam_carving assets/ronaldo.jpeg v 300
```
Resized | Original
--- | ---
|

```rust
./build/app/seam_carving assets/tower.jpg v 300
```
Resized | Original
--- | ---
|

## Video demo

![video](./assets/seam-gif.gif)