Skip to content

A native C++ implementation of content-aware image resizing (seam carving).

License

Notifications You must be signed in to change notification settings

andymina/seam-carving

Repository files navigation

Seam Carving

A native C++ implementation of seam carving as described by Avidan et al. in Seam carving for content-aware image resizing. Learn more about seam carving from this YouTube video.

Seam Carving Demo GIF

Credit to George Wang for the GIF

Getting Started

The seam carving library can be built using CMake. The available targets are:

  • seam_carving - builds the dylib
  • demo - runs the demo at ./demo.cpp
  • carver_unit/energy_unit - runs the unit tests at tests/unit/[carver/energy].test.cpp respectively

Running the demo

  1. Configure the CMake project. The code sample below uses Ninja as the generator. There are presets in CMakePresets.json available to use.
  2. Build the demo target.
  3. Run the demo target with a path to an image (sample images are provided in samples/), and the target size
# step 1 - from the root folder of the repo
cmake -B {PATH_TO_BUILD_DIR} -S {PATH_TO_REPO_ROOT} -G Ninja --preset default

# step 2
cmake --build {PATH_TO_BUILD_DIR} --target demo

# step 3
./demo {PATH_TO_IMG} {TARGET COLS} {TARGET ROWS}

Seam Carving Shell (SCS)

The Seam Carving Shell (SCS) is undergoing major reconstruction and is not supported in v2.0.0.