Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
408559d6
Commit
408559d6
authored
10 years ago
by
Bellaktris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pre-merge
parent
286d6ffe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
15 deletions
+27
-15
xphoto.rst
modules/xphoto/doc/xphoto.rst
+3
-3
annf.hpp
modules/xphoto/src/annf.hpp
+18
-11
inpainting.cpp
modules/xphoto/src/inpainting.cpp
+2
-0
whs.hpp
modules/xphoto/src/whs.hpp
+4
-1
No files found.
modules/xphoto/doc/xphoto.rst
View file @
408559d6
*****************************
*****
xphoto.
Addon to basic photo modul
*****************************
*****
*****************************
xphoto.
Extended photo module
*****************************
.. toctree::
:maxdepth: 2
...
...
This diff is collapsed.
Click to expand it.
modules/xphoto/src/annf.hpp
View file @
408559d6
...
...
@@ -95,11 +95,12 @@ public:
};
template
<
typename
Tp
,
int
cn
>
int
KDTree
<
Tp
,
cn
>::
getMaxSpreadN
(
const
int
_left
,
const
int
_
right
)
const
getMaxSpreadN
(
const
int
left
,
const
int
right
)
const
{
cv
::
Vec
<
Tp
,
cn
>
maxValue
=
data
[
idx
[
_left
]
],
minValue
=
data
[
idx
[
_left
]
];
for
(
int
i
=
_left
+
1
;
i
<
_right
;
i
+=
cn
)
cv
::
Vec
<
Tp
,
cn
>
maxValue
=
data
[
idx
[
left
]
],
minValue
=
data
[
idx
[
left
]
];
for
(
int
i
=
left
+
1
;
i
<
right
;
++
i
)
for
(
int
j
=
0
;
j
<
cn
;
++
j
)
{
minValue
[
j
]
=
std
::
min
(
minValue
[
j
],
data
[
idx
[
i
]][
j
]
);
...
...
@@ -143,6 +144,7 @@ KDTree(const cv::Mat &img, const int _leafNumber, const int _zeroThresh)
}
int
nth
=
_left
+
(
_right
-
_left
)
/
2
;
int
dimIdx
=
getMaxSpreadN
(
_left
,
_right
);
KDTreeComparator
comp
(
this
,
dimIdx
);
...
...
@@ -169,7 +171,7 @@ updateDist(const int leaf, const int &idx0, int &bestIdx, double &dist)
abs
(
nx
-
x
)
<
zeroThresh
)
continue
;
if
(
nx
>
width
-
1
||
nx
<
1
||
ny
>
height
-
1
||
ny
>
1
)
ny
>
height
-
1
||
ny
<
1
)
continue
;
double
ndist
=
norm2
(
data
[
idx0
],
data
[
idx
[
k
]]);
...
...
@@ -187,6 +189,9 @@ updateDist(const int leaf, const int &idx0, int &bestIdx, double &dist)
static
void
dominantTransforms
(
const
cv
::
Mat
&
img
,
std
::
vector
<
cv
::
Matx33f
>
&
transforms
,
const
int
nTransform
,
const
int
psize
)
{
const
int
zeroThresh
=
2
*
psize
;
const
int
leafNum
=
63
;
/** Walsh-Hadamard Transformation **/
std
::
vector
<
cv
::
Mat
>
channels
;
...
...
@@ -204,7 +209,7 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Matx33f> &tr
cv
::
Mat
whs
;
// Walsh-Hadamard series
cv
::
merge
(
channels
,
whs
);
KDTree
<
float
,
24
>
kdTree
(
whs
,
16
,
32
);
KDTree
<
float
,
24
>
kdTree
(
whs
,
leafNum
,
zeroThresh
);
std
::
vector
<
int
>
annf
(
whs
.
total
(),
0
);
/** Propagation-assisted kd-tree search **/
...
...
@@ -220,8 +225,8 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Matx33f> &tr
if
(
i
-
dy
[
k
]
>=
0
&&
j
-
dx
[
k
]
>=
0
)
{
int
neighbor
=
(
i
-
dy
[
k
])
*
whs
.
cols
+
(
j
-
dx
[
k
]);
int
leafIdx
=
k
==
0
?
neighbor
:
annf
[
neighbor
]
+
dy
[
k
]
*
whs
.
cols
+
dx
[
k
];
int
leafIdx
=
(
dx
[
k
]
==
0
&&
dy
[
k
]
==
0
)
?
neighbor
:
annf
[
neighbor
]
+
dy
[
k
]
*
whs
.
cols
+
dx
[
k
];
kdTree
.
updateDist
(
leafIdx
,
current
,
annf
[
i
*
whs
.
cols
+
j
],
dist
);
}
...
...
@@ -232,8 +237,8 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Matx33f> &tr
cv
::
Mat_
<
double
>
annfHist
(
2
*
whs
.
rows
-
1
,
2
*
whs
.
cols
-
1
,
0.0
),
_annfHist
(
2
*
whs
.
rows
-
1
,
2
*
whs
.
cols
-
1
,
0.0
);
for
(
size_t
i
=
0
;
i
<
annf
.
size
();
++
i
)
++
annfHist
(
(
annf
[
i
]
-
int
(
i
)
)
/
whs
.
cols
+
whs
.
rows
-
1
,
(
annf
[
i
]
-
int
(
i
)
)
%
whs
.
cols
+
whs
.
cols
-
1
);
++
annfHist
(
annf
[
i
]
/
whs
.
cols
-
int
(
i
)
/
whs
.
cols
+
whs
.
rows
-
1
,
annf
[
i
]
%
whs
.
cols
-
int
(
i
)
%
whs
.
cols
+
whs
.
cols
-
1
);
cv
::
GaussianBlur
(
annfHist
,
annfHist
,
cv
::
Size
(
0
,
0
),
std
::
sqrt
(
2.0
),
0.0
,
cv
::
BORDER_CONSTANT
);
...
...
@@ -260,13 +265,15 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Matx33f> &tr
std
::
partial_sort
(
amount
.
begin
(),
amount
.
begin
()
+
nTransform
,
amount
.
end
(),
std
::
greater
<
std
::
pair
<
double
,
int
>
>
()
);
std
::
ofstream
out
(
"C:/Users/Yury/Projects/inpaint/output/log.log"
);
transforms
.
resize
(
nTransform
);
for
(
int
i
=
0
;
i
<
nTransform
;
++
i
)
{
int
idx
=
amount
[
i
].
second
;
transforms
[
i
]
=
cv
::
Matx33f
(
1
,
0
,
float
(
shiftM
[
idx
].
x
),
0
,
1
,
float
(
shiftM
[
idx
].
y
),
0
,
0
,
1
);
0
,
0
,
1
);
out
<<
int
(
shiftM
[
idx
].
x
)
<<
","
<<
int
(
shiftM
[
idx
].
y
)
<<
std
::
endl
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/xphoto/src/inpainting.cpp
View file @
408559d6
...
...
@@ -43,6 +43,7 @@
#include <algorithm>
#include <iterator>
#include <iostream>
#include <fstream>
#include <time.h>
#include <functional>
...
...
@@ -98,6 +99,7 @@ namespace cv
warpPerspective
(
masks
[
0
],
masks
[
i
+
1
],
transforms
[
i
],
masks
[
0
].
size
(),
INTER_NEAREST
);
cv
::
imwrite
(
cv
::
format
(
"C:/Users/Yury/Projects/inpaint/output/%d.png"
,
i
),
images
[
i
]);
masks
[
i
+
1
]
&=
invMask
;
}
...
...
This diff is collapsed.
Click to expand it.
modules/xphoto/src/whs.hpp
View file @
408559d6
...
...
@@ -137,8 +137,11 @@ static void rgb2whs(const cv::Mat &src, cv::Mat &dst, const int nProjections, co
nextProjection
(
projections
,
snake_idx
[
i
-
1
],
snake_idx
[
i
],
npsize
);
int
pad
=
0
;
cv
::
merge
(
projections
,
img
);
img
(
cv
::
Rect
(
npsize
,
npsize
,
src
.
cols
,
src
.
rows
)).
copyTo
(
dst
);
img
(
cv
::
Rect
(
npsize
+
pad
,
npsize
+
pad
,
src
.
cols
-
pad
,
src
.
rows
-
pad
)).
copyTo
(
dst
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment