opencv histogram stretching, example source code.
Histogram stretching
It's just adjusting the range with the same ratio.
For example, there is a range of numbers.
60, 61, 62, 63, 64, 65
Stretching is to extent other range, such as 0~255.
So, if we stitching 60~65 to 0~255, numbers will be like that.
60 -> 0
61 -> 51
62 -> 102
63 -> 153
64 -> 204
65 -> 255
so, in case of histogram, origin histogram will be stretched like that

image source : https://stackoverflow.com/questions/41118808/difference-between-contrast-stretching-and-histogram-equalization
then, let's look at code and result with real image.
origin input image

histogram

stretched image

histogram of stretched image

source code
<gist start>
<gist end>
It's just adjusting the range with the same ratio.
For example, there is a range of numbers.
60, 61, 62, 63, 64, 65
Stretching is to extent other range, such as 0~255.
So, if we stitching 60~65 to 0~255, numbers will be like that.
60 -> 0
61 -> 51
62 -> 102
63 -> 153
64 -> 204
65 -> 255
so, in case of histogram, origin histogram will be stretched like that

image source : https://stackoverflow.com/questions/41118808/difference-between-contrast-stretching-and-histogram-equalization
then, let's look at code and result with real image.
origin input image
histogram
stretched image
histogram of stretched image
source code
<gist start>
<gist end>
calcHist for RGB image, opencv histogram example
A Example source code for rgb histogram, the source code uses calcHist function in opencv.
Important things in the source code are the part of split rgb mat to vector[3] and drawing part.
Read the code carefully, so then you can understand easliy. ^^
input

the result of rgb histogram

<gist code start>
<gist code end>
reference : https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html
Important things in the source code are the part of split rgb mat to vector[3] and drawing part.
Read the code carefully, so then you can understand easliy. ^^
input

the result of rgb histogram

<gist code start>
<gist code end>
reference : https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html
WebCam Histogram Test, OpenCV
Histogram Test on webcam stream
Refer to below source code..😀
test video
< gist >
< /gitst >
tags : normalize, calcHist, MatND
Refer to below source code..😀
test video
< gist >
< /gitst >
tags : normalize, calcHist, MatND
Subscribe to:
Posts (Atom)


