Skip to content

Commit 1a7ed31

Browse files
committed
removed whitespaces
1 parent 0f85769 commit 1a7ed31

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

modules/alphamat/src/cm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ void lle(my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samples, float ep
8484

8585
my_vector_of_vectors_t wcm;
8686
wcm.resize(n);
87-
87+
8888
Mat C(20, 20, DataType<float>::type), rhs(20, 1, DataType<float>::type), Z(3, 20, DataType<float>::type), weights(20, 1, DataType<float>::type), pt(3, 1, DataType<float>::type);
8989
Mat ptDotN(20, 1, DataType<float>::type), imd(20, 1, DataType<float>::type);
9090
Mat Cones(20, 1, DataType<float>::type), Cinv(20, 1, DataType<float>::type);
9191
float alpha, beta, lagrangeMult;
9292
Cones += 1;
93-
93+
9494
C = 0;
9595
rhs = 1;
96-
96+
9797
int i, ind = 0;
9898
for(std::unordered_set<int>::iterator it = unk.begin(); it != unk.end(); it++){
9999
// filling values in Z
100100
i = *it;
101-
101+
102102
int index_nbr;
103103
for(int j = 0; j < k; j++){
104104
index_nbr = indm[ind][j];
@@ -109,7 +109,7 @@ void lle(my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samples, float ep
109109
pt.at<float>(0,0) = samples[i][0];
110110
pt.at<float>(1,0) = samples[i][1];
111111
pt.at<float>(2,0) = samples[i][2];
112-
112+
113113
C = Z.t()*Z;
114114
for(int p=0; p<k; p++)
115115
C.at<float>(p,p) += eps;
@@ -126,7 +126,7 @@ void lle(my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samples, float ep
126126
weights = weights / sum;
127127

128128
int cMaj_i = findColMajorInd(i, img.rows, img.cols);
129-
129+
130130
for(int j = 0; j < k; j++){
131131
int cMaj_ind_j = findColMajorInd(indm[ind][j], img.rows, img.cols);
132132
triplets.push_back(T(cMaj_i, cMaj_ind_j, weights.at<float>(j,0)));

modules/alphamat/src/intraU.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ int findColMajorInd(int rowMajorInd, int nRows, int nCols) {
1616
return (jInd*nRows+iInd);
1717
}
1818

19-
2019
void generateFVectorIntraU(my_vector_of_vectors_t &samples, Mat &img, Mat& tmap)
2120
{
2221
int nRows = img.rows;
@@ -55,7 +54,7 @@ void kdtree_intraU(Mat &img, Mat& tmap, my_vector_of_vectors_t& indm, my_vector_
5554
{
5655
// Generate feature vectors for intra U:
5756
generateFVectorIntraU(samples, img, tmap);
58-
57+
5958
typedef KDTreeVectorOfVectorsAdaptor< my_vector_of_vectors_t, double > my_kd_tree_t;
6059
my_kd_tree_t mat_index(dim /*dim*/, samples, 10 /* max leaf */ );
6160
mat_index.index->buildIndex();
@@ -111,7 +110,7 @@ void intraU(Mat& img, my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samp
111110
nbr_ind = indm[i][j];
112111
int cMaj_nbr_j = findColMajorInd(orig_ind[nbr_ind], img.rows, img.cols);
113112
weight = max(1-l1norm(samples[i], samples[j]), 0.0);
114-
113+
115114
triplets.push_back(T(cMaj_i, cMaj_nbr_j, weight/2));
116115
td.push_back(T(cMaj_i, cMaj_i, weight/2));
117116

modules/alphamat/src/local_info.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ void local_info(Mat& img, Mat& tmap, SparseMatrix<double>& Wl, SparseMatrix<doub
3636
int num_win = (win_size*2 + 1)*(win_size*2 + 1); // number of pixels in window
3737
typedef Triplet<double> T;
3838
std::vector<T> triplets, td, tl;
39-
4039
int neighInd[9];
4140
int i, j;
4241
for (j = win_size; j < nCols-win_size; j++){
@@ -78,35 +77,33 @@ void local_info(Mat& img, Mat& tmap, SparseMatrix<double>& Wl, SparseMatrix<doub
7877
win_mean.at<double>(0, 0) = sum1/num_win;
7978
win_mean.at<double>(0, 1) = sum2/num_win;
8079
win_mean.at<double>(0, 2) = sum3/num_win;
81-
80+
8281
// calculate the covariance matrix
8382
Mat covariance = (win.t() * win / num_win) - (win_mean.t() * win_mean);
84-
83+
8584
Mat I = Mat::eye(img.channels(), img.channels(), CV_64F);
8685
Mat I1 = (covariance + (eps/num_win)*I);
8786
Mat I1_inv = I1.inv();
8887

8988
Mat X = win - repeat(win_mean, num_win, 1);
9089
Mat vals = (1 + X * I1_inv * X.t()) / num_win;
91-
90+
9291
for (int q = 0; q < num_win; q++){
9392
for (int p = 0; p < num_win; p++){
9493
triplets.push_back(T(neighInd[p], neighInd[q], vals.at<double>(p, q)));
9594
}
9695
}
9796
}
9897
}
99-
98+
10099
std::vector<T> tsp;
101100
SparseMatrix<double> W(N, N), Wsp(N,N);
102101
W.setFromTriplets(triplets.begin(), triplets.end());
103102

104-
int cntNZ = 0;
105103
SparseMatrix<double> Wt = W.transpose();
106104
SparseMatrix<double> Ws = Wt + W;
107105
W = Ws;
108106

109-
cntNZ = 0;
110107
for (int k=0; k<W.outerSize(); ++k) {
111108
double sumCol = 0;
112109
for (SparseMatrix<double>::InnerIterator it(W,k); it; ++it)
@@ -117,7 +114,7 @@ void local_info(Mat& img, Mat& tmap, SparseMatrix<double>& Wl, SparseMatrix<doub
117114
tsp.push_back(T(k, k, 1/sumCol));
118115
}
119116
Wsp.setFromTriplets(tsp.begin(), tsp.end());
120-
117+
121118
Wl = Wsp * W; // For normalization
122119
//Wl = W; // No normalization
123120

modules/alphamat/tutorials/alphamat_tutorial.markdown

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ cmake -DOPENCV_EXTRA_MODULES_PATH=<path to opencv_contrib modules> -Dopencv_alph
2727
2828
make
2929
```
30-
Please refer to OpenCV building tutorials for further details, if needed. The following target needs to be build for testing the sample code below: example_alphamat_information_flow_matting
30+
Please refer to OpenCV building tutorials for further details, if needed. The following target needs to be build for testing the sample code below: example_alphamat_information_flow_matting
3131

3232
# Testing
3333

3434
The built target can be tested as follows:
3535
```
36-
example_alphamat_information_flow_matting -img=<path to input image file> -tri=<path to the corresponding trimap> -out=<path to save output matte file>
36+
example_alphamat_information_flow_matting -img=<path to input image file> -tri=<path to the corresponding trimap> -out=<path to save output matte file>
3737
```
3838
# Source Code of the sample
3939

@@ -51,4 +51,3 @@ example_alphamat_information_flow_matting -img=<path to input image file> -tri=<
5151
[4] Qifeng Chen, Dingzeyu Li, Chi-Keung Tang, "[KNN Matting](http://dingzeyu.li/files/knn-matting-tpami.pdf)", IEEE TPAMI, 2013.
5252

5353
[5] Yagiz Aksoy, "[Affinity Based Matting Toolbox](https://github.com/yaksoy/AffinityBasedMattingToolbox)".
54-

0 commit comments

Comments
 (0)