histogram smoothing
I have an image in RGB, along with its planes' histograms. How I can smooth these histograms?
(histograms are generated using opencv calcHist function)
I have an image in RGB, along with its planes' histograms. How I can smooth these histograms?
(histograms are generated using opencv calcHist function)
Histograms contain useful information about your image, smoothing it will degrade the information, making the histogram mostly useless.
If you still want to use it, here you are: just replace each value by the mean of its neighbors. e.g. smooth_hist[i]=(hist[i-2]+hist[i-1]+hist[i]+hist[i+1]+hist[i+2])/5
. You can use a gaussian weighting, too.
In general you can use OpenCV filters also on vectors. In this case GaussianBlur
works fine:
cv::Mat hist,hist_smoothed;
...
calcHist(&grayImg, 1, 0, cv::Mat(), hist, 1, &histSize, &histRange, uniform, accumulate);
GaussianBlur(hist, hist_smoothed, Size(smooth_size, smooth_size), 0, 0, BORDER_CONSTANT);
Asked: 2016-04-06 10:12:13 -0600
Seen: 2,626 times
Last updated: Apr 07 '16
OpenCV DescriptorMatcher matches
Conversion between IplImage and MxArray
Percentage of color in a frame of video
Video On Label OpenCV Qt :: hide cvNamedWindows
Problems using the math.h class with OpenCV (c++, VS2012)
How to reduce false positives for face detection
Area of a single pixel object in OpenCV
build problems for android_binary_package - Eclipse Indigo, Ubuntu 12.04
Can't compile .cu file when including opencv.hpp
Using OpenCV's stitching module, strange error when compositing images