Ask Your Question
2

histogram smoothing

asked 2016-04-06 10:12:13 -0600

ahmad_asadi gravatar image

I have an image in RGB, along with its planes' histograms. How I can smooth these histograms?

(histograms are generated using opencv calcHist function)

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
4

answered 2016-04-07 10:51:33 -0600

pklab gravatar image

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);
edit flag offensive delete link more
2

answered 2016-04-06 11:52:37 -0600

kbarni gravatar image

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.

edit flag offensive delete link more

Comments

There are some reason to smooth histogram... for example when you are searching for peaks

pklab gravatar imagepklab ( 2016-04-07 10:52:54 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-06 10:12:13 -0600

Seen: 3,124 times

Last updated: Apr 07 '16