Skip to content

Archit-10/content-aware-image-resizing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seam-Carving

Introduction

Seam carving is a smart image resizing technique that changes the size of an image without simply stretching or cropping it. Instead, it removes the least important pixels while keeping important objects and edges intact.

Features

  • Energy Calculation: Computes the energy of each pixel in the image, enabling effective seam identification.
  • Seam Identification: Identifies the seam (path of pixels) with the lowest energy to minimize distortion.
  • Seam Removal: Removes the identified seam from the image to achieve the desired dimensions.
  • Resizing: Continuously removes seams until the image reaches the specified size.
  • User Input: Allows users to specify the desired width or height for resizing.
  • Multiple Energy Functions: Supports different methods for calculating energy, such as gradient magnitude and color histograms.

Demonstration

Before and after images showcasing the seam carving effect.

The input image is on the left and the result is on the right.

Build Instructions

Requirements

  • C++17 or higher
  • OpenCV
  • CMake

Build Steps

git clone https://github.com/Archit-10/content-aware-image-resizing.git
cd content-aware-image-resizing

mkdir build
cd build

cmake ..
make

Run the Program

Run the executable:

./seam_carver

When prompted, enter the target image dimensions in the following format:

width height

Example:

400 300

The resized image will be saved to:

assets/output/resized.png

Performance Metrics

  • Time Complexity: O(NM) for finding the optimal seam, where N is the height and M is the width of the image.
  • Memory Usage: Memory usage is proportional to the size of the image, as additional space is required for energy and cost matrices.

Challenges & Solutions

  • Challenge: Preserving important edges and objects during seam removal in complex images.
  • Solution: Used a gradient-based energy function to prioritize significant visual regions and minimize distortion.

QA

  • Verified energy computation on sample images
  • Tested seam removal across multiple resizing iterations
  • Visually inspected output quality after resizing

Tech Stack

  • Programming Language: C++
  • Libraries: OpenCV

Contributions

Contributions are welcome! If you would like to contribute to this project, please follow these guidelines:

  • Fork the repository.

  • Create a new branch for your feature or bug fix.

  • Submit a PR detailing your changes.

About

Content-aware image resizing using seam carving, OpenCV, and dynamic programming.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages