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
1494da33
Commit
1494da33
authored
Mar 05, 2012
by
Alexander Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed #1507
parent
ec5bdc7d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
31 deletions
+31
-31
histogram_calculation.rst
...istograms/histogram_calculation/histogram_calculation.rst
+0
-0
Histogram_Calculation_Result.jpg
...ogram_calculation/images/Histogram_Calculation_Result.jpg
+0
-0
calcHist_Demo.cpp
...s/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp
+31
-31
No files found.
doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.rst
View file @
1494da33
This diff is collapsed.
Click to expand it.
doc/tutorials/imgproc/histograms/histogram_calculation/images/Histogram_Calculation_Result.jpg
View replaced file @
ec5bdc7d
View file @
1494da33
9.93 KB
|
W:
|
H:
30.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp
View file @
1494da33
...
...
@@ -25,57 +25,57 @@ int main( int argc, char** argv )
if
(
!
src
.
data
)
{
return
-
1
;
}
/// Separate the image in 3 places (
R, G and B
)
vector
<
Mat
>
rgb
_planes
;
split
(
src
,
rgb_planes
);
/// Separate the image in 3 places (
B, G and R
)
vector
<
Mat
>
bgr
_planes
;
split
(
src
,
bgr_planes
);
/// Establish the number of bins
int
histSize
=
25
5
;
/// Establish the number of bins
int
histSize
=
25
6
;
/// Set the ranges ( for
R,G,B
) )
float
range
[]
=
{
0
,
25
5
}
;
/// Set the ranges ( for
B,G,R
) )
float
range
[]
=
{
0
,
25
6
}
;
const
float
*
histRange
=
{
range
};
bool
uniform
=
true
;
bool
accumulate
=
false
;
Mat
r_hist
,
g_hist
,
b
_hist
;
Mat
b_hist
,
g_hist
,
r
_hist
;
/// Compute the histograms:
calcHist
(
&
rgb_planes
[
0
],
1
,
0
,
Mat
(),
r
_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
calcHist
(
&
rgb
_planes
[
1
],
1
,
0
,
Mat
(),
g_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
calcHist
(
&
rgb_planes
[
2
],
1
,
0
,
Mat
(),
b
_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
calcHist
(
&
bgr_planes
[
0
],
1
,
0
,
Mat
(),
b
_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
calcHist
(
&
bgr
_planes
[
1
],
1
,
0
,
Mat
(),
g_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
calcHist
(
&
bgr_planes
[
2
],
1
,
0
,
Mat
(),
r
_hist
,
1
,
&
histSize
,
&
histRange
,
uniform
,
accumulate
);
// Draw the histograms for
R, G and B
int
hist_w
=
400
;
int
hist_h
=
400
;
// Draw the histograms for
B, G and R
int
hist_w
=
512
;
int
hist_h
=
400
;
int
bin_w
=
cvRound
(
(
double
)
hist_w
/
histSize
);
Mat
histImage
(
hist_
w
,
hist_h
,
CV_8UC3
,
Scalar
(
0
,
0
,
0
)
);
Mat
histImage
(
hist_
h
,
hist_w
,
CV_8UC3
,
Scalar
(
0
,
0
,
0
)
);
/// Normalize the result to [ 0, histImage.rows ]
normalize
(
r_hist
,
r_hist
,
0
,
histImage
.
rows
,
NORM_MINMAX
,
-
1
,
Mat
()
);
normalize
(
g_hist
,
g_hist
,
0
,
histImage
.
rows
,
NORM_MINMAX
,
-
1
,
Mat
()
);
normalize
(
b_hist
,
b_hist
,
0
,
histImage
.
rows
,
NORM_MINMAX
,
-
1
,
Mat
()
);
normalize
(
g_hist
,
g_hist
,
0
,
histImage
.
rows
,
NORM_MINMAX
,
-
1
,
Mat
()
);
normalize
(
r_hist
,
r_hist
,
0
,
histImage
.
rows
,
NORM_MINMAX
,
-
1
,
Mat
()
);
/// Draw for each channel
/// Draw for each channel
for
(
int
i
=
1
;
i
<
histSize
;
i
++
)
{
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
r_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
r_hist
.
at
<
float
>
(
i
))
),
Scalar
(
0
,
0
,
255
),
2
,
8
,
0
);
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
g_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
g_hist
.
at
<
float
>
(
i
))
),
Scalar
(
0
,
255
,
0
),
2
,
8
,
0
);
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
b_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
b_hist
.
at
<
float
>
(
i
))
),
Scalar
(
255
,
0
,
0
),
2
,
8
,
0
);
}
/// Display
{
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
b_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
b_hist
.
at
<
float
>
(
i
))
),
Scalar
(
255
,
0
,
0
),
2
,
8
,
0
);
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
g_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
g_hist
.
at
<
float
>
(
i
))
),
Scalar
(
0
,
255
,
0
),
2
,
8
,
0
);
line
(
histImage
,
Point
(
bin_w
*
(
i
-
1
),
hist_h
-
cvRound
(
r_hist
.
at
<
float
>
(
i
-
1
))
)
,
Point
(
bin_w
*
(
i
),
hist_h
-
cvRound
(
r_hist
.
at
<
float
>
(
i
))
),
Scalar
(
0
,
0
,
255
),
2
,
8
,
0
);
}
/// Display
namedWindow
(
"calcHist Demo"
,
CV_WINDOW_AUTOSIZE
);
imshow
(
"calcHist Demo"
,
histImage
);
waitKey
(
0
);
return
0
;
}
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