Unverified Commit 88c4ed01 authored by sunitanyk's avatar sunitanyk Committed by GitHub
Browse files

Computer Vision based Alpha Matting (#2306)

* Computer Vision based Alpha Matting Code

alpha matting code

This is a combination of 3 commits.

removed whitespaces

addressed issues raised in the PR

removed whitespaces

* removed global variable

* incorporated changes suggested by second round of review

* updated build instructions

* changed to OutputArray

* removed whitespaces

* alphamat: fix bugs triggered by assertions of Debug builds

* alphamat: fix documentation

* alphamat: coding style fixes

- get rid of std::cout
- remove clock_t
- drop unnecessary cast: float pix = tmap.at<uchar>(i, j);
- global 'dim' => 'ALPHAMAT_DIM'
- fix sample command line handling

* alphamat: apply clang-format

* clang-format fixups
parent bf0075a5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r

- **aruco**: ArUco and ChArUco Markers -- Augmented reality ArUco marker and "ChARUco" markers where ArUco markers embedded inside the white areas of the checker board.

- **alphamat**: Computer Vision based Alpha Matting -- Given an input image and a trimap, generate an alpha matte.

- **bgsegm**: Background segmentation algorithm combining statistical background image estimation and per-pixel Bayesian segmentation.

- **bioinspired**: Biological Vision -- Biologically inspired vision model: minimize noise and luminance variance, transient event segmentation, high dynamic range tone mapping methods.
+9 −0
Original line number Diff line number Diff line
if(NOT HAVE_EIGEN)
  message(STATUS "Module opencv_alphamat disabled because the following dependencies are not found: Eigen")
  ocv_module_disable(alphamat)
endif()

ocv_define_module(alphamat
    opencv_core
    opencv_imgproc
)
+23 −0
Original line number Diff line number Diff line
# Computer Vision based Alpha Matting

This project was part of the Google Summer of Code 2019.

####Student: Muskaan Kularia
####Mentor: Sunita Nayak
***
Alphamatting is the problem of extracting the foreground from an image. Given the input of an image and its corresponding trimap, we try to extract the foreground from the background.

This project is implementation of "[[Designing Effective Inter-Pixel Information Flow for Natural Image Matting](http://people.inf.ethz.ch/aksoyy/ifm/)]" by Yağız Aksoy, Tunç Ozan Aydın and Marc Pollefeys[1]. It required implementation of parts of other papers [2,3,4].


## References

[1] Yagiz Aksoy, Tunc Ozan Aydin, Marc Pollefeys, "[Designing Effective Inter-Pixel Information Flow for Natural Image Matting](http://people.inf.ethz.ch/aksoyy/ifm/)", CVPR, 2017.

[2] Roweis, Sam T., and Lawrence K. Saul. "[Nonlinear dimensionality reduction by locally linear embedding](https://science.sciencemag.org/content/290/5500/2323)" Science 290.5500 (2000): 2323-2326.

[3] Anat Levin, Dani Lischinski, Yair Weiss, "[A Closed Form Solution to Natural Image Matting](https://www.researchgate.net/publication/5764820_A_Closed-Form_Solution_to_Natural_Image_Matting)", IEEE TPAMI, 2008.

[4] Qifeng Chen, Dingzeyu Li, Chi-Keung Tang, "[KNN Matting](http://dingzeyu.li/files/knn-matting-tpami.pdf)", IEEE TPAMI, 2013.

[5] Yagiz Aksoy, "[Affinity Based Matting Toolbox](https://github.com/yaksoy/AffinityBasedMattingToolbox)".
+26 −0
Original line number Diff line number Diff line
@inproceedings{aksoy2017designing,
  title={Designing effective inter-pixel information flow for natural image matting},
  author={Aksoy, Yagiz and Ozan Aydin, Tunc and Pollefeys, Marc},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={29--37},
  year={2017}
}

@article{roweis2000nonlinear,
  title={Nonlinear dimensionality reduction by locally linear embedding},
  author={Roweis, Sam T and Saul, Lawrence K},
  journal={science},
  volume={290},
  number={5500},
  pages={2323--2326},
  year={2000},
  publisher={American Association for the Advancement of Science}
}

@inproceedings{shahrian2013improving,
  title={Improving image matting using comprehensive sampling sets},
  author={Shahrian, Ehsan and Rajan, Deepu and Price, Brian and Cohen, Scott},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={636--643},
  year={2013}
}
+32 −0
Original line number Diff line number Diff line
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

/** Information Flow algorithm implementaton for alphamatting */

#ifndef _OPENCV_ALPHAMAT_HPP_
#define _OPENCV_ALPHAMAT_HPP_

/**
 * @defgroup alphamat Alpha Matting
 * This module is dedicated to compute alpha matting of images, given the input image and an input trimap.
 * The samples directory includes easy examples of how to use the module.
 */

namespace cv { namespace alphamat {
//! @addtogroup alphamat
//! @{

/**
 * The implementation is based on Designing Effective Inter-Pixel Information Flow for Natural Image Matting by Yağız Aksoy, Tunç Ozan Aydın and Marc Pollefeys, CVPR 2019.
 *
 * This module has been originally developed by Muskaan Kularia and Sunita Nayak as a project
 * for Google Summer of Code 2019 (GSoC 19).
 *
 */
CV_EXPORTS_W void infoFlow(InputArray image, InputArray tmap, OutputArray result);

//! @}
}}  // namespace

#endif
Loading