A high-performance implementation of content-aware image resizing using CUDA. This project implements the seam carving algorithm to intelligently resize images while preserving important content.
- CUDA Acceleration: Leverages GPU parallelism for fast energy map computation and seam carving.
- Seam Removal and Insertion: Supports both removing and inserting seams for image resizing.
- Multiple Resizing Modes:
- Vertical and horizontal seam removal/insertion.
- Target resizing to specific dimensions.
- Seam Visualization: Option to save and visualize seam paths on the image.
- Experimentation Script: Automated script to run predefined experiments and generate outputs.
- NVIDIA GPU with CUDA support
- CUDA Toolkit
- C++ compiler
- Make build system
- Clone the repository:
git clone https://github.com/FILALIHicham/seam-carving-cuda.git
cd seam-carving-cuda
- Build the project:
make
./build/seam_carving -i <input_image> -o <output_image> [options]
-n <number>
: Number of seams to remove/insert--horizontal
: Operate on horizontal seams instead of vertical--insert
: Insert seams instead of removing them--save-seams
: Save visualization of seam paths--target <width>x<height>
: Resize to specific dimensions--optimized
: Use optimized computation methods
- Remove 50 vertical seams:
./build/seam_carving -i data/tower.jpg -o output.png -n 50
- Insert 30 horizontal seams:
./build/seam_carving -i data/tower.jpg -o output.png -n 30 --horizontal --insert
- Resize to specific dimensions:
./build/seam_carving -i data/tower.jpg -o output.png --target 800x600
The project includes an automated experiment script (exp.sh
) that runs various seam carving operations and saves the results:
- Make the script executable:
chmod +x exp.sh
- Run experiments:
./exp.sh
The script will:
- Clean and rebuild the project
- Create an
outputs
directory - Run multiple seam carving operations with different parameters
- Save results and visualizations
Results will be saved in the outputs
directory with the following naming convention:
output_remove_vertical_n{number}.png
: Vertical seam removaloutput_remove_horizontal_n{number}.png
: Horizontal seam removaloutput_insert_vertical_n{number}.png
: Vertical seam insertionoutput_insert_horizontal_n{number}.png
: Horizontal seam insertionoutput_target_resize_{number}.png
: Target size resizing
└── seam-carving-cuda/
├── README.md
├── LICENSE
├── Makefile
├── exp.sh
├── data/ # Input images
├── include/ # External libraries
├── build/ # Compiled binaries
└── src/ # Source code
The project uses several optimization techniques:
- Parallel computation of energy maps
- Efficient cumulative energy calculation
- GPU memory management
- Shared memory utilization for faster access
- Seam Carving for Content-Aware Image Resizing (Avidan and Shamir)
- STB Image library for image I/O operations