Giter Site home page Giter Site logo

seam-carving-algorithm-for-content-aware-image-resizing's Introduction

Image_Resizing

Image Resizing using Seam Carving Algorithm

Problem Statement:

Apply seam carving content aware image-resizing algorithm on a given image. Take the height and width (in pixels) of the output image as inputs from the user.

What is Seam Carving?

  • Seam-carving is a content-aware image resizing technique where the image is reduced in size by one pixel of height (or width) at a time.
  • A vertical seam in an image is a path of pixels connected from the top to the bottom with one pixel in each row.
  • A horizontal seam is a path of pixels connected from the left to the right with one pixel in each column.
  • Steps:
    • Energy Calculation: Each pixel has some RGB values. Calculate energy for each pixel. For ex.- You can use dual-gradient energy function but you are free to use any energy function of your choice. Also, you can refer to this link for details.
    • Seam Identification: Identify the lowest energy seam.
    • Seam Removal: Remove the lowest energy seam.

Program Flow:

  • Extract individual pixel’s RGB values from the sample image ./data/input/sample.jpeg and write them into ./data/input/rgb_in.txt
  • Load the RGB values from ./data/input/rgb_in.txt in a 3D matrix.
  • Apply seam carving algorithm.
  • Write the individual pixel’s RGB values for resized image into the ./data/output/rgb_out.txt
  • Generate sample image output ./data/output/sample_out.jpeg using the ./data/output/rgb_out.txt.

Dependencies:

  • You’ll need to install the python image library Pillow to extract RGB values of each pixel and to generate images back from RGB values of each pixel.
  • To install Pillow: pip install Pillow

The python script is only compatible with Linux/Mac operating systems.

How to Run::

  • python3 driver.py <input_mage_name>
  • Ex: python3 driver.py sample1.jpeg

Output Example

  • Sample Image1

    Original Image

    Image 1

    Resized Image

    Image 2

  • Sample Image2

    Original Image

    Image 3

    Resized Image

    Image 4

  • Sample Image3

    Original Image

    Image 5

    Resized Image

    Image 6

seam-carving-algorithm-for-content-aware-image-resizing's People

Contributors

udrasht avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.