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.
- 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.
Before and after images showcasing the seam carving effect.
The input image is on the left and the result is on the right.
|
|
|
|
- C++17 or higher
- OpenCV
- CMake
git clone https://github.com/Archit-10/content-aware-image-resizing.git
cd content-aware-image-resizing
mkdir build
cd build
cmake ..
makeRun the executable:
./seam_carverWhen 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
- 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.
- 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.
- Verified energy computation on sample images
- Tested seam removal across multiple resizing iterations
- Visually inspected output quality after resizing
- Programming Language: C++
- Libraries: OpenCV
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.



