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
97d602ff
Commit
97d602ff
authored
Aug 05, 2014
by
Bellaktris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some warnings and compmilation error fixed
parent
cdba517e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
63 deletions
+50
-63
CMakeLists.txt
modules/ximpgroc/CMakeLists.txt
+0
-1
CMakeLists.txt
modules/xphoto/CMakeLists.txt
+0
-2
whitebalance.rst
modules/xphoto/doc/colorbalance/whitebalance.rst
+2
-1
denoising.rst
modules/xphoto/doc/denoising/denoising.rst
+1
-1
algo.hpp
modules/xphoto/src/algo.hpp
+2
-1
dct_image_denoising.cpp
modules/xphoto/src/dct_image_denoising.cpp
+7
-22
inpainting.cpp
modules/xphoto/src/inpainting.cpp
+9
-6
photomontage.hpp
modules/xphoto/src/photomontage.hpp
+29
-29
No files found.
modules/ximpgroc/CMakeLists.txt
View file @
97d602ff
set
(
the_description
"Advanced edge-detection algorithms"
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wundef -Wshadow
)
ocv_define_module
(
ximpgroc opencv_core opencv_imgproc OPTIONAL opencv_highgui
)
modules/xphoto/CMakeLists.txt
View file @
97d602ff
set
(
the_description
"Addon to basic photo module"
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wundef
)
ocv_define_module
(
xphoto opencv_core opencv_imgproc opencv_stitching OPTIONAL opencv_photo opencv_highgui
)
\ No newline at end of file
modules/xphoto/doc/colorbalance/whitebalance.rst
View file @
97d602ff
...
...
@@ -7,7 +7,7 @@ balanceWhite
------------
.. ocv:function:: (const Mat &src, Mat &dst, const int algorithmType,
const float inputMin = 0.0f, const float inputMax = 255.0f,
const float outputMin = 0.0f, const float outputMax = 255.0f)
;
const float outputMin = 0.0f, const float outputMax = 255.0f)
The function implements different algorithm of automatic white balance, i.e.
it tries to map image's white color to perceptual white (this can be violated
...
...
@@ -20,6 +20,7 @@ due to specific illumination or camera settings).
smart histogram adjustments
(ignoring 4% pixels with minimal
and maximal values) for each channel.
:param inputMin : minimum value in the input image
:param inputMax : maximum value in the input image
:param outputMin : minimum value in the output image
...
...
modules/xphoto/doc/denoising/denoising.rst
View file @
97d602ff
...
...
@@ -5,7 +5,7 @@ Image denoising techniques
dctDenoising
------------
.. ocv:function:: (const Mat &src, Mat &dst, const float sigma)
;
.. ocv:function:: (const Mat &src, Mat &dst, const float sigma)
The function implements simple dct-based denoising,
link: http://www.ipol.im/pub/art/2011/ys-dct/.
...
...
modules/xphoto/src/algo.hpp
View file @
97d602ff
...
...
@@ -43,10 +43,11 @@
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
template
<
typename
Tp
>
static
inline
int
min_idx
(
std
::
vector
<
Tp
>
vec
)
{
return
std
::
min_element
(
vec
.
begin
(),
vec
.
end
())
-
vec
.
begin
(
);
return
int
(
std
::
min_element
(
vec
.
begin
(),
vec
.
end
())
-
vec
.
begin
()
);
}
static
inline
int
hamming_length
(
int
x
)
...
...
modules/xphoto/src/dct_image_denoising.cpp
View file @
97d602ff
...
...
@@ -128,21 +128,12 @@ namespace cv
{
CV_Assert
(
src
.
type
()
==
CV_MAKE_TYPE
(
CV_32F
,
3
)
);
float
M
[]
=
{
cvInvSqrt
(
3
),
cvInvSqrt
(
3
),
cvInvSqrt
(
3
),
cvInvSqrt
(
2
),
0.0
f
,
-
cvInvSqrt
(
2
),
cvInvSqrt
(
6
),
-
2.0
f
*
cvInvSqrt
(
6
),
cvInvSqrt
(
6
)}
;
Mat
m
=
Mat_
<
float
>
(
3
,
3
)
<<
(
cvInvSqrt
(
3
),
cvInvSqrt
(
3
),
cvInvSqrt
(
3
),
cvInvSqrt
(
2
),
0.0
f
,
-
cvInvSqrt
(
2
),
cvInvSqrt
(
6
),
-
2.0
f
*
cvInvSqrt
(
6
),
cvInvSqrt
(
6
))
;
Mat_
<
Vec3f
>::
iterator
outIt
=
dst
.
begin
<
Vec3f
>
(
);
cv
::
transform
(
src
,
dst
,
m
);
for
(
Mat_
<
Vec3f
>::
const_iterator
it
=
src
.
begin
<
Vec3f
>
();
it
!=
src
.
end
<
Vec3f
>
();
++
it
,
++
outIt
)
{
Vec3f
rgb
=
*
it
;
*
outIt
=
Vec3f
(
M
[
0
]
*
rgb
[
0
]
+
M
[
1
]
*
rgb
[
1
]
+
M
[
2
]
*
rgb
[
2
],
M
[
3
]
*
rgb
[
0
]
+
M
[
4
]
*
rgb
[
1
]
+
M
[
5
]
*
rgb
[
2
],
M
[
6
]
*
rgb
[
0
]
+
M
[
7
]
*
rgb
[
1
]
+
M
[
8
]
*
rgb
[
2
]);
}
/*************************************/
std
::
vector
<
Mat
>
mv
;
split
(
dst
,
mv
);
...
...
@@ -150,15 +141,8 @@ namespace cv
grayDctDenoising
(
mv
[
i
],
mv
[
i
],
sigma
,
psize
);
merge
(
mv
,
dst
);
/*************************************/
for
(
Mat_
<
Vec3f
>::
iterator
it
=
dst
.
begin
<
Vec3f
>
();
it
!=
dst
.
end
<
Vec3f
>
();
++
it
)
{
Vec3f
rgb
=
*
it
;
*
it
=
Vec3f
(
M
[
0
]
*
rgb
[
0
]
+
M
[
3
]
*
rgb
[
1
]
+
M
[
6
]
*
rgb
[
2
],
M
[
1
]
*
rgb
[
0
]
+
M
[
4
]
*
rgb
[
1
]
+
M
[
7
]
*
rgb
[
2
],
M
[
2
]
*
rgb
[
0
]
+
M
[
5
]
*
rgb
[
1
]
+
M
[
8
]
*
rgb
[
2
]);
}
cv
::
transform
(
dst
,
dst
,
m
.
inv
()
);
}
/*! This function implements simple dct-based image denoising,
...
...
@@ -182,7 +166,8 @@ namespace cv
else
if
(
img
.
type
()
==
CV_32FC1
)
grayDctDenoising
(
img
,
img
,
sigma
,
psize
);
else
CV_Assert
(
false
);
CV_Error_
(
CV_StsNotImplemented
,
(
"Unsupported source image format (=%d)"
,
img
.
type
())
);
img
.
convertTo
(
dst
,
src
.
type
()
);
}
...
...
modules/xphoto/src/inpainting.cpp
View file @
97d602ff
...
...
@@ -64,16 +64,16 @@ namespace cv
static
void
shiftMapInpaint
(
const
Mat
&
src
,
const
Mat
&
mask
,
Mat
&
dst
)
{
const
int
nTransform
=
60
;
// number of dominant transforms for stitching
const
int
psize
=
8
;
// single ANNF patch size
//
const int psize = 8; // single ANNF patch size
/** ANNF computation **/
srand
(
time
(
NULL
)
);
srand
(
unsigned
int
(
time
(
NULL
)
)
);
std
::
vector
<
Matx33f
>
transforms
;
// dominant transforms
for
(
int
i
=
0
;
i
<
nTransform
;
++
i
)
{
float
dx
=
rand
()
%
src
.
cols
-
src
.
cols
/
2
;
float
dy
=
rand
()
%
src
.
rows
-
src
.
rows
/
2
;
float
dx
=
float
(
rand
()
%
src
.
cols
-
src
.
cols
/
2
)
;
float
dy
=
float
(
rand
()
%
src
.
rows
-
src
.
rows
/
2
)
;
transforms
.
push_back
(
Matx33f
(
1
,
0
,
dx
,
0
,
1
,
dy
,
0
,
0
,
1
)
);
...
...
@@ -117,7 +117,8 @@ namespace cv
shiftMapInpaint
<
Tp
,
cn
>
(
src
,
mask
,
dst
);
break
;
default
:
CV_Assert
(
false
);
CV_Error_
(
CV_StsNotImplemented
,
(
"Unsupported algorithm type (=%d)"
,
algorithmType
)
);
break
;
}
}
...
...
@@ -196,7 +197,9 @@ namespace cv
inpaint
<
double
,
4
>
(
src
,
mask
,
dst
,
algorithmType
);
break
;
default
:
CV_Assert
(
false
);
CV_Error_
(
CV_StsNotImplemented
,
(
"Unsupported source image format (=%d)"
,
src
.
type
())
);
break
;
}
}
...
...
modules/xphoto/src/photomontage.hpp
View file @
97d602ff
...
...
@@ -90,7 +90,7 @@ protected:
virtual
void
setWeights
(
GCGraph
<
double
>
&
graph
,
const
cv
::
Point
&
pA
,
const
cv
::
Point
&
pB
,
const
int
lA
,
const
int
lB
,
const
int
lX
);
public
:
Photomontage
(
const
std
::
vector
<
cv
::
Mat
>
&
images
,
const
std
::
vector
<
cv
::
Mat
>
&
masks
,
bool
multiscale
=
true
);
Photomontage
(
const
std
::
vector
<
cv
::
Mat
>
&
images
,
const
std
::
vector
<
cv
::
Mat
>
&
masks
);
virtual
~
Photomontage
(){};
void
assignLabeling
(
cv
::
Mat
&
img
);
...
...
@@ -109,36 +109,36 @@ setWeights(GCGraph <double> &graph, const cv::Point &pA, const cv::Point &pB, co
if
(
lA
==
lB
)
{
/** Link from A to B **/
double
weightAB
=
dist
(
images
[
lA
].
at
<
Tp
>
(
pA
),
images
[
lA
].
at
<
Tp
>
(
pB
),
images
[
lX
].
at
<
Tp
>
(
pA
),
images
[
lX
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
pA
.
y
*
width
+
pA
.
x
,
pB
.
y
*
width
+
pB
.
x
,
weightAB
,
weightAB
);
double
weightAB
=
dist
(
typename
images
[
lA
].
at
<
Tp
>
(
pA
),
typename
images
[
lA
].
at
<
Tp
>
(
pB
),
typename
images
[
lX
].
at
<
Tp
>
(
pA
),
typename
images
[
lX
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
int
(
pA
.
y
*
width
+
pA
.
x
),
int
(
pB
.
y
*
width
+
pB
.
x
)
,
weightAB
,
weightAB
);
}
else
{
int
X
=
graph
.
addVtx
();
/** Link from X to sink **/
double
weightXS
=
dist
(
images
[
lA
].
at
<
Tp
>
(
pA
),
images
[
lA
].
at
<
Tp
>
(
pB
),
images
[
lB
].
at
<
Tp
>
(
pA
),
images
[
lB
].
at
<
Tp
>
(
pB
)
);
double
weightXS
=
dist
(
typename
images
[
lA
].
at
<
Tp
>
(
pA
),
typename
images
[
lA
].
at
<
Tp
>
(
pB
),
typename
images
[
lB
].
at
<
Tp
>
(
pA
),
typename
images
[
lB
].
at
<
Tp
>
(
pB
)
);
graph
.
addTermWeights
(
X
,
0
,
weightXS
);
/** Link from A to X **/
double
weightAX
=
dist
(
images
[
lA
].
at
<
Tp
>
(
pA
),
images
[
lA
].
at
<
Tp
>
(
pB
),
images
[
lX
].
at
<
Tp
>
(
pA
),
images
[
lX
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
pA
.
y
*
width
+
pA
.
x
,
X
,
weightAX
,
weightAX
);
double
weightAX
=
dist
(
typename
images
[
lA
].
at
<
Tp
>
(
pA
),
typename
images
[
lA
].
at
<
Tp
>
(
pB
),
typename
images
[
lX
].
at
<
Tp
>
(
pA
),
typename
images
[
lX
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
int
(
pA
.
y
*
width
+
pA
.
x
)
,
X
,
weightAX
,
weightAX
);
/** Link from X to B **/
double
weightXB
=
dist
(
images
[
lX
].
at
<
Tp
>
(
pA
),
images
[
lX
].
at
<
Tp
>
(
pB
),
images
[
lB
].
at
<
Tp
>
(
pA
),
images
[
lB
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
X
,
pB
.
y
*
width
+
pB
.
x
,
weightXB
,
weightXB
);
double
weightXB
=
dist
(
typename
images
[
lX
].
at
<
Tp
>
(
pA
),
typename
images
[
lX
].
at
<
Tp
>
(
pB
),
typename
images
[
lB
].
at
<
Tp
>
(
pA
),
typename
images
[
lB
].
at
<
Tp
>
(
pB
)
);
graph
.
addEdges
(
X
,
int
(
pB
.
y
*
width
+
pB
.
x
)
,
weightXB
,
weightXB
);
}
}
...
...
@@ -151,8 +151,8 @@ singleExpansion(const int alpha)
/** Terminal links **/
for
(
int
i
=
0
;
i
<
height
;
++
i
)
{
const
uchar
*
maskAlphaRow
=
masks
[
alpha
].
ptr
<
uchar
>
(
i
);
const
int
*
labelRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
typename
const
uchar
*
maskAlphaRow
=
masks
[
alpha
].
ptr
<
uchar
>
(
i
);
typename
const
int
*
labelRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
for
(
int
j
=
0
;
j
<
width
;
++
j
)
graph
.
addTermWeights
(
graph
.
addVtx
(),
...
...
@@ -163,8 +163,8 @@ singleExpansion(const int alpha)
/** Neighbor links **/
for
(
int
i
=
0
;
i
<
height
-
1
;
++
i
)
{
const
int
*
currentRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
const
int
*
nextRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
+
1
);
typename
const
int
*
currentRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
typename
const
int
*
nextRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
+
1
);
for
(
int
j
=
0
;
j
<
width
-
1
;
++
j
)
{
...
...
@@ -188,8 +188,8 @@ singleExpansion(const int alpha)
labelings
[
alpha
].
create
(
height
,
width
,
CV_32SC1
);
for
(
int
i
=
0
;
i
<
height
;
++
i
)
{
const
int
*
inRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
int
*
outRow
=
(
int
*
)
labelings
[
alpha
].
ptr
<
int
>
(
i
);
typename
const
int
*
inRow
=
(
const
int
*
)
x_i
.
ptr
<
int
>
(
i
);
typename
int
*
outRow
=
(
int
*
)
labelings
[
alpha
].
ptr
<
int
>
(
i
);
for
(
int
j
=
0
;
j
<
width
;
++
j
)
outRow
[
j
]
=
graph
.
inSourceSegment
(
i
*
width
+
j
)
?
inRow
[
j
]
:
alpha
;
...
...
@@ -242,11 +242,11 @@ assignResImage(cv::Mat &img)
}
template
<
typename
Tp
>
Photomontage
<
Tp
>::
Photomontage
(
const
std
::
vector
<
cv
::
Mat
>
&
images
,
const
std
::
vector
<
cv
::
Mat
>
&
masks
,
const
bool
multiscale
)
Photomontage
(
const
std
::
vector
<
cv
::
Mat
>
&
images
,
const
std
::
vector
<
cv
::
Mat
>
&
masks
)
:
images
(
images
),
masks
(
masks
),
height
(
i
mages
[
0
].
rows
),
width
(
images
[
0
].
cols
),
images
(
images
),
masks
(
masks
),
height
(
i
nt
(
images
[
0
].
rows
)),
width
(
int
(
images
[
0
].
cols
)
),
type
(
images
[
0
].
type
()),
x_i
(
height
,
width
,
CV_32SC1
),
channels
(
images
[
0
].
channels
()),
lsize
(
i
mages
.
size
(
)),
labelings
(
images
.
size
()),
distances
(
images
.
size
())
lsize
(
i
nt
(
images
.
size
()
)),
labelings
(
images
.
size
()),
distances
(
images
.
size
())
{
CV_Assert
(
images
[
0
].
depth
()
!=
CV_8U
&&
masks
[
0
].
depth
()
==
CV_8U
);
}
...
...
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