Git Product home page Git Product logo

image-retargeting's Introduction

Image-Retargeting

Patch Based Image Warping for Content Aware Retargeting

A C++ implementation of Patch Based Image Warping for Content Aware Retargeting (2013), including the segmentation algorithm (Efficient Graph-Based Image Segmentation(2004)) and saliency map detection algorithm (Context-aware saliency detection(2010)) described in paper.

Instead of relying on third-party image libraries such as openCV, you only need to install this tensor library -- Eigen3. I wrote the operations required to implement these papers myself,the goal is to keep it less third-party library dependency and clean.

I wrote a cuda kernel for computing saliency to speed up the computation (from 2 min to 2 seconds), this is one of the improvements I made compared to the original implementation.

How to RUN

cd Image-Retargeting
# ----- Default compile setting -----
make
# ----- Or compile with CUDA support -----
make CUDA=1
# ----- Execute with defualt parameters-----
./build/default/default/patch_based_resizing

(see below for detail execution arguments)

Argument specification for execution

In order to easily adjust the relevant parameters of the program, the user can adjust the parameters according to the following format through the argument list.

All parameters have default values, once a parameter is ignored, the default value is used, see src/retargeting.cpp to learn more about parameter usage and its default values.

./build/default/default/patch_based_resizing \
  --InputImage ./datasets/butterfly.png \
  --Sigma 0.5 \
  --SegmentK 500.0 \
  --MinSize 100 \
  --MergePercent 0.0001 \
  --MergeColorDist 20.0 \
  --SaveSegment true \
  --DistC 3 \
  --SimilarK 64 \
  --NumScale 3 \
  --PatchSize 7 \
  --SaveSaliency true \
  --SaveScaledSaliency true \
  --newH 300 \
  --newW 200 \
  --Alpha 0.8 \
  --QuadSize 10 \
  --WeightDST 3.0 \
  --WeightDLT 1.2 \
  --WeightDOR 3.0

Requirements

  • CMake

  • GTest (optional ! only needed when you wish to run test suite)

  • Eigen3

  • Compliant C++17 compiler

    • The library is sytematically tested on following compilers

      Compiler Version
      GCC 9.3.0
      clang 13.0.0
  • CUDA toolkit (optional but highly recommend, otherwise it will take ~2min to generate saliance map using solely multithread)

For image processing we only requires Eigen3 to be installed on your system.

git clone -b '3.4' --single-branch --depth 1 https://gitlab.com/libeigen/eigen.git
cd eigen
mkdir build  
cd build 
cmake .. 
make install

Make sure Eigen3 can be found by your build system.

Install CUDA Toolkit

Download and install the CUDA Toolkit (11.4 on my computer) for your corresponding platform. For system requirements and installation instructions of cuda toolkit, please refer to the Linux Installation Guide, and the Windows Installation Guide.

Make sure the environment variable CUDA_PATH is set to the CUDA Toolkit install directory.

Also Make sure NVCC and cuda-toolkit can be found by your build system.

Run test suite

You need to additionally install GTest to run test-suite.

apt-get install libgtest-dev -y

Make sure GTest can be found by your build system.

Use the following commands from the project's top-most directory to run the test suite.

cd Image-Retargeting
make test
make run-test

Result

original-grid segmentation significance saliency 200 x 500 300 x 200

Acknowledgement

Thank zyu-tien for helping me debugging and giving me helpful advices while developing this project.

All the images used in the project could be downloaded from https://people.csail.mit.edu/mrub/retargetme/download.html.

image-retargeting's People

Contributors

murumura avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.