Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
95db69f6
Commit
95db69f6
authored
11 years ago
by
siddharth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new files
parent
0736ede7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
0 deletions
+109
-0
photo.hpp
modules/photo/include/opencv2/photo.hpp
+2
-0
contrast_preserve.cpp
modules/photo/src/contrast_preserve.cpp
+76
-0
contrast_preserve.hpp
modules/photo/src/contrast_preserve.hpp
+31
-0
No files found.
modules/photo/include/opencv2/photo.hpp
View file @
95db69f6
...
...
@@ -288,6 +288,8 @@ public:
CV_EXPORTS_W
Ptr
<
MergeRobertson
>
createMergeRobertson
();
CV_EXPORTS_W
void
decolor
(
InputArray
src
,
OutputArray
grayscale
,
OutputArray
color_boost
);
}
// cv
#endif
This diff is collapsed.
Click to expand it.
modules/photo/src/contrast_preserve.cpp
0 → 100644
View file @
95db69f6
#include "precomp.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
#include "math.h"
#include <vector>
#include <limits>
#include <iostream>
#include "contrast_preserve.hpp"
using
namespace
std
;
using
namespace
cv
;
int
rounding
(
double
);
int
rounding
(
double
a
)
{
return
int
(
a
+
0.5
);
}
void
cv
::
decolor
(
InputArray
_src
,
OutputArray
_gray
,
OutputArray
_boost
)
{
Mat
I
=
_src
.
getMat
();
_gray
.
create
(
I
.
size
(),
CV_8UC1
);
Mat
dst
=
_gray
.
getMat
();
_boost
.
create
(
I
.
size
(),
CV_8UC3
);
Mat
color_boost
=
_boost
.
getMat
();
if
(
!
I
.
data
)
{
cout
<<
"Could not open or find the image"
<<
endl
;
return
;
}
if
(
I
.
channels
()
!=
3
)
{
cout
<<
"Input Color Image"
<<
endl
;
return
;
}
float
sigma
=
.02
;
int
maxIter
=
8
;
int
iterCount
=
0
;
int
h
=
I
.
size
().
height
;
int
w
=
I
.
size
().
width
;
Mat
img
;
Decolor
obj
;
double
sizefactor
;
if
((
h
+
w
)
>
900
)
{
sizefactor
=
(
double
)
900
/
(
h
+
w
);
resize
(
I
,
I
,
Size
(
rounding
(
h
*
sizefactor
),
rounding
(
w
*
sizefactor
)));
img
=
Mat
(
I
.
size
(),
CV_32FC3
);
I
.
convertTo
(
img
,
CV_32FC3
,
1.0
/
255.0
);
}
else
{
img
=
Mat
(
I
.
size
(),
CV_32FC3
);
I
.
convertTo
(
img
,
CV_32FC3
,
1.0
/
255.0
);
}
obj
.
init
();
vector
<
double
>
Cg
;
vector
<
vector
<
double
>
>
polyGrad
;
vector
<
vector
<
double
>
>
bc
;
vector
<
vector
<
int
>
>
comb
;
vector
<
double
>
alf
;
}
This diff is collapsed.
Click to expand it.
modules/photo/src/contrast_preserve.hpp
0 → 100644
View file @
95db69f6
#include "precomp.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
#include "math.h"
#include <vector>
#include <limits>
using
namespace
std
;
using
namespace
cv
;
class
Decolor
{
public
:
Mat
kernel
;
Mat
kernel1
;
int
order
;
void
init
();
void
grad_system
(
Mat
img
,
vector
<
vector
<
double
>
>
&
polyGrad
,
vector
<
double
>
&
Cg
,
vector
<
vector
<
int
>
>&
comb
);
};
void
Decolor
::
init
()
{
kernel
=
Mat
(
1
,
2
,
CV_32FC1
);
kernel1
=
Mat
(
2
,
1
,
CV_32FC1
);
kernel
.
at
<
float
>
(
0
,
0
)
=
1.0
;
kernel
.
at
<
float
>
(
0
,
1
)
=-
1.0
;
kernel1
.
at
<
float
>
(
0
,
0
)
=
1.0
;
kernel1
.
at
<
float
>
(
1
,
0
)
=-
1.0
;
order
=
2
;
}
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