Showing posts with label histogram stretch. Show all posts
Showing posts with label histogram stretch. Show all posts

1/14/2018

Histogram Equalization, Stretching, origin histo compare and example source code

Example source code for histogram equalization
and compare with origin histogram and stretching histogram.

result is like that:

origin image & histogram




stretching image and histogram






Equalization image and histogram
 

<gist>

</gist>


tags:
equalizeHist, cvtColor, normalize, calcHist

12/30/2017

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>