Skip to content

assamite/sdrs_cimg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salient Region Detection and Segmentation for Python Using CImg

This is an UNIX platform oriented version of Salient Region Detection and Segmentation technique represented in:

R. Achanta, S. Hemami, F. Estrada and S. Süsstrunk, Frequency-tuned Salient Region Detection, IEEE International Conference on Computer Vision and Pattern Recognition (CVPR 2009), pp. 1597 - 1604, 2009.

Check also the webpage for the paper. Most of the code is unaltered from the C++ sources given on the webpage.

The differences are:

  • Use of CImg to handle picture loading and saving for platform independence
  • Changed the code to work as a command line tool
  • Added Python wrapper (with ctypes) for main functionality

Dependencies

  • CImg: For loading and saving pictures.
  • boost: Used for filepath manipulation. In case you don't want to use boost, you can alter the source of CImgHandler::SavePictures
  • Image libraries: Defaults are libpng and libjpeg. Check CImg documentation for full list of supported formats.

The conversion has been done with minimum amount of work so any input and/or change suggestions are welcome.

Usage

  1. As Command line tool:

    1.1 Compile program with make

    1.2 Call the program created:

    $>./saliency [-s] [-o=path/to/outfolder/] path/to/pic1 path/to/pic2 path/to/pic3 ...

    where optional '-s' argument tells the program to not only do saliency mapping, but also mean shift based processing and extracting the most salient objects from the pictures.

  2. From Python:

    2.1 Compile program as shared library with make shared_osx or make shared_linux

    2.2 Instantiate SDRWrapper object in Python and call it:

    from sdrWrapper import SDRWrapper
    sdrw = SDRWrapper()
    doSegmentation = True # Extract most salient objects
    sdrw.saliency("path/to/outfolder", "path/to/my/pic", doSegmentation)

Created pictures are saved with different suffixes. For example, running code for bird.jpg will create three different files to the output folder when most salient objects are extracted:

  • bird_sm.jpg - saliency map
  • bird_ms.jpg - mean shift based segmentation
  • bird_so.jpg - most salient object