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
ec8b2a23
Commit
ec8b2a23
authored
Sep 10, 2014
by
Bellaktris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
high resolution images support
parent
eeca8669
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
25 deletions
+110
-25
inpainting.cpp
modules/xphoto/src/inpainting.cpp
+110
-21
photomontage.hpp
modules/xphoto/src/photomontage.hpp
+0
-4
No files found.
modules/xphoto/src/inpainting.cpp
View file @
ec8b2a23
...
...
@@ -161,27 +161,116 @@ namespace xphoto
/** Upscaling **/
if
(
ls
!=
1
)
{
// _src.convertTo( img, CV_32F );
//
// for (size_t k = 0; k < pPath.size(); ++k)
// {
// int clabel = labelSeq[k];
// int nearSeam = 0;
//
// for (size_t i = 0; i < linkIdx[k].size(); ++i)
// nearSeam |= linkIdx[k] == -1
// || clabel != labelSeq[linkIdx[k][i]];
//
// if (nearSeam == 0)
// ...
// else
// {
// ...
// }
// }
//
// xphotoInternal::Photomontage < cv::Vec <float, cn> > ( /*...*/
// pointSeq, maskSeq, linkIdx, labelSeq );
_src
.
convertTo
(
img
,
CV_32F
);
std
::
vector
<
Point2i
>
__pPath
=
pPath
;
pPath
.
clear
();
cv
::
Mat_
<
int
>
__backref
(
img
.
size
(),
-
1
);
std
::
vector
<
std
::
vector
<
cv
::
Vec
<
float
,
cn
>
>
>
__pointSeq
=
pointSeq
;
pointSeq
.
clear
();
std
::
vector
<
int
>
__labelSeq
=
labelSeq
;
labelSeq
.
clear
();
std
::
vector
<
std
::
vector
<
int
>
>
__linkIdx
=
linkIdx
;
linkIdx
.
clear
();
std
::
vector
<
std
::
vector
<
unsigned
char
>
>
__maskSeq
=
maskSeq
;
maskSeq
.
clear
();
for
(
size_t
i
=
0
;
i
<
__pPath
.
size
();
++
i
)
{
cv
::
Point2i
p
[]
=
{
__pPath
[
i
]
+
cv
::
Point2i
(
0
,
-
1
),
__pPath
[
i
]
+
cv
::
Point2i
(
-
1
,
0
)
};
for
(
int
j
=
0
;
j
<
sizeof
(
p
)
/
sizeof
(
cv
::
Point2i
);
++
j
)
if
(
p
[
j
].
y
<
src
.
rows
&&
p
[
j
].
y
>=
0
&&
p
[
j
].
x
<
src
.
cols
&&
p
[
j
].
x
>=
0
)
__linkIdx
[
i
].
push_back
(
backref
(
p
[
j
])
);
else
__linkIdx
[
i
].
push_back
(
-
1
);
}
for
(
size_t
k
=
0
;
k
<
__pPath
.
size
();
++
k
)
{
int
clabel
=
__labelSeq
[
k
];
int
nearSeam
=
0
;
for
(
size_t
i
=
0
;
i
<
__linkIdx
[
k
].
size
();
++
i
)
nearSeam
|=
(
__linkIdx
[
k
][
i
]
==
-
1
||
clabel
!=
__labelSeq
[
__linkIdx
[
k
][
i
]]
);
if
(
nearSeam
!=
0
)
for
(
int
i
=
0
;
i
<
ls
;
++
i
)
for
(
int
j
=
0
;
j
<
ls
;
++
j
)
{
cv
::
Point2i
u
=
ls
*
(
__pPath
[
k
]
+
transforms
[
__labelSeq
[
k
]])
+
cv
::
Point2i
(
j
,
i
);
pPath
.
push_back
(
ls
*
__pPath
[
k
]
+
cv
::
Point2i
(
j
,
i
)
);
labelSeq
.
push_back
(
0
);
__backref
(
i
,
j
)
=
int
(
pPath
.
size
()
);
cv
::
Point2i
dv
[]
=
{
cv
::
Point2i
(
0
,
0
),
cv
::
Point2i
(
-
1
,
0
),
cv
::
Point2i
(
+
1
,
0
),
cv
::
Point2i
(
0
,
-
1
),
cv
::
Point2i
(
0
,
+
1
)
};
std
::
vector
<
cv
::
Vec
<
float
,
cn
>
>
pointVec
;
std
::
vector
<
uchar
>
maskVec
;
for
(
int
q
=
0
;
q
<
sizeof
(
dv
)
/
sizeof
(
cv
::
Point2i
);
++
q
)
if
(
u
.
x
+
dv
[
q
].
x
>=
0
&&
u
.
x
+
dv
[
q
].
x
<
img
.
cols
&&
u
.
y
+
dv
[
q
].
y
>=
0
&&
u
.
y
+
dv
[
q
].
y
<
img
.
rows
)
{
pointVec
.
push_back
(
img
.
template
at
<
cv
::
Vec
<
float
,
cn
>
>
(
u
+
dv
[
q
]));
maskVec
.
push_back
(
_mask
.
template
at
<
uchar
>
(
u
+
dv
[
q
]));
}
else
{
pointVec
.
push_back
(
cv
::
Vec
<
float
,
cn
>::
all
(
0
)
);
maskVec
.
push_back
(
0
);
}
pointSeq
.
push_back
(
pointVec
);
maskSeq
.
push_back
(
maskVec
);
}
else
{
cv
::
Point2i
fromIdx
=
ls
*
(
__pPath
[
k
]
+
transforms
[
__labelSeq
[
k
]]),
toIdx
=
ls
*
__pPath
[
k
];
for
(
int
i
=
0
;
i
<
ls
;
++
i
)
{
cv
::
Vec
<
float
,
cn
>
*
from
=
img
.
template
ptr
<
cv
::
Vec
<
float
,
cn
>
>
(
fromIdx
.
y
+
i
)
+
fromIdx
.
x
;
cv
::
Vec
<
float
,
cn
>
*
to
=
img
.
template
ptr
<
cv
::
Vec
<
float
,
cn
>
>
(
toIdx
.
y
+
i
)
+
toIdx
.
x
;
for
(
int
j
=
0
;
j
<
ls
;
++
j
)
to
[
j
]
=
from
[
j
];
}
}
}
for
(
int
i
=
0
;
i
<
pPath
.
size
();
++
i
)
{
cv
::
Point2i
p
[]
=
{
pPath
[
i
]
+
cv
::
Point2i
(
0
,
+
1
),
pPath
[
i
]
+
cv
::
Point2i
(
+
1
,
0
)
};
std
::
vector
<
int
>
linkVec
;
for
(
int
j
=
0
;
j
<
sizeof
(
p
)
/
sizeof
(
cv
::
Point2i
);
++
j
)
if
(
p
[
j
].
y
<
src
.
rows
&&
p
[
j
].
y
>=
0
&&
p
[
j
].
x
<
src
.
cols
&&
p
[
j
].
x
>=
0
)
linkVec
.
push_back
(
__backref
(
p
[
j
])
);
else
linkVec
.
push_back
(
-
1
);
linkIdx
.
push_back
(
linkVec
);
}
photomontage
(
pointSeq
,
maskSeq
,
linkIdx
,
labelSeq
);
}
/** Writing result **/
...
...
modules/xphoto/src/photomontage.hpp
View file @
ec8b2a23
...
...
@@ -200,10 +200,6 @@ gradientDescent()
int
minIndex
=
min_idx
(
distances
);
TWeight
minValue
=
distances
[
minIndex
];
std
::
cerr
<<
optValue
<<
" "
<<
*
max_element
(
distances
.
begin
(),
distances
.
end
())
<<
std
::
endl
;
if
(
minValue
<
(
1.00
-
eps
)
*
optValue
)
optValue
=
distances
[
num
=
minIndex
];
...
...
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