Skip to content

Commit

Permalink
edited markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
sunitanyk committed Sep 6, 2019
1 parent db50a05 commit 2c0b495
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
14 changes: 7 additions & 7 deletions modules/alphamat/samples/alphamat_information_flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ int main(int argc, char *argv[])
bool show_help = (argc == 1);
show_help = show_help || (argc == 2 && string(argv[1]) == "--help");
show_help = show_help || (argc == 2 && string(argv[1]) == "-h");

if (show_help)
{
printf("\nThis sample demonstrates Information Flow alpha matting\n"
"Call:\n"
" alphamat_information_flow -img=<string> -tri=<string> [-out=<string>]\n\n");
return 0;
}

CommandLineParser parser(argc, argv, keys);
if (!parser.check())
{
parser.printErrors();
return -1;
}

string img_path = parser.get<std::string>("img");
string trimap_path = parser.get<std::string>("tri");
string result_path = parser.get<std::string>("out");

Mat image, tmap;

image = imread(img_path, IMREAD_COLOR); // Read the input image file
if (image.empty())
{
Expand All @@ -63,7 +63,7 @@ int main(int argc, char *argv[])

Mat result;
infoFlow(image, tmap, result, false, true);

if (result_path.empty())
{
namedWindow("result alpha matte", WINDOW_NORMAL);
Expand All @@ -77,5 +77,5 @@ int main(int argc, char *argv[])

imshow("Result Matte", result);
return 0;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Goal

In this chapter,

- We will familiarize with the computer vision based alphamatting in OpenCV.
- We will familiarize with the computer vision based alphamatting in OpenCV.

Basics
------
Expand All @@ -20,20 +20,19 @@ Input Image | Input trimap | Ouput Alpha matte
This project is implementation of [[Information-Flow Matting](https://arxiv.org/pdf/1707.05055.pdf)] by Aksoy et al.[1]. It required implementation of some parts of other papers [2,3].

This is a pixel-affinity based alpha matting algorithm which solves a linear system of equations using preconditioned conjugate gradient method. Affinity-based methods operate by propagating opacity information from known opacity regions(K) into unknown opacity regions(U) using a variety of affinity definitions mentioned as -
* Color mixture information flow - Opacity transitions in a matte occur as a result of the original colors in the image getting mixed with each other due to transparency or intricate parts of an object. They make use of this fact by representing each pixel in U as a mixture of similarly-colored pixels and the difference is the energy term ECM, which is to be reduced.
* K-to-U information flow - Connections from every pixel in U to both F(foreground pixels) and B(background pixels) are made to facilitate direct information flow from known-opacity regions to even the most remote opacity-transition regions in the image.
* Intra U information flow - They distribute the information inside U effectively by encouraging pixels with similar colors inside U to have similar opacity.
* Local information flow - Spatial connectivity is one of the main cues for information flow which is achieved by connecting each pixel in U to its immediate neighbors to ensure spatially smooth mattes.
* Color mixture information flow - Opacity transitions in a matte occur as a result of the original colors in the image getting mixed with each other due to transparency or intricate parts of an object. They make use of this fact by representing each pixel in U as a mixture of similarly-colored pixels and the difference is the energy term ECM, which is to be reduced.
* K-to-U information flow - Connections from every pixel in U to both F(foreground pixels) and B(background pixels) are made to facilitate direct information flow from known-opacity regions to even the most remote opacity-transition regions in the image.
* Intra U information flow - They distribute the information inside U effectively by encouraging pixels with similar colors inside U to have similar opacity.
* Local information flow - Spatial connectivity is one of the main cues for information flow which is achieved by connecting each pixel in U to its immediate neighbors to ensure spatially smooth mattes.

Using these information flow, energy/error(E) is obtained as a weighted local composite of E<sub>CM</sub>, E<sub>KU</sub>(K-to-U information flow), E<sub>UU</sub>(Intra U information flow), E<sub>L</sub>(Local information flow).
E represents the deviation of unknown pixels opacity or colour from what we predict it to be using other pixels. So, the algorithm aims at minimizing this error.
E represents the deviation of unknown pixels opacity or colour from what we predict it to be using other pixels. So, the algorithm aims at minimizing this error.

Results
-------
Input Image | Ouput Alpha matte
:-------------------------:|:-------------------------:
<img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/img/net.png" alt="alt text" width="200" height="155"> | <img
src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/Result/result_net.png" alt="alt text" width="200" height="155">
<img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/img/net.png" alt="alt text" width="200" height="155"> | <img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/Result/result_net.png" alt="alt text" width="200" height="155">
<img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/img/elephant.png" alt="alt text" width="200" height="155"> | <img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/Result/result_elephant.png" alt="alt text" width="200" height="155">
<img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/img/pineapple.png" alt="alt text" width="200" height="155"> | <img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/Result/result_pineapple.png" alt="alt text" width="200" height="155">
<img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/img/plasticbag.png" alt="alt text" width="200" height="155"> | <img src="https://github.com/muskaankularia/opencv_contrib/blob/alphamatting/modules/alphamat/Result/result_plasticbag.png" alt="alt text" width="200" height="155">
Expand Down

0 comments on commit 2c0b495

Please sign in to comment.