How to calculate histogram using every nth pixel opencv

asked 2015-04-22 01:40:12 -0600

asanka gravatar image

I'm using this opencv function for calculate the histogram(For blue color).

calcHist( &bgr_planes[0], 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

Here we use all pixels in the image for calculate the histogram. Assume that I need to calculate the histogram using every 10th pixel or 100th pixel. Is there an efficient way to do this? I need to do this because I think it may increase the performances in histogram calculation even though some details are lossed.

edit retag flag offensive close merge delete

Comments

I dont think you can choose pixels from images to be used to calculate Histogram. You can select every nth pixel as per your requirement and save it to seperate image. Its histogram is what you are looking for. Hope this helps!

tomnjerry gravatar imagetomnjerry ( 2015-04-22 01:44:54 -0600 )edit
1

" I need to do this because I think it may increase the performances" - i very much doubt so.

also, this "every n'th pixel" sampling has problem of its own, since wou will miss peaks/valleys.

berak gravatar imageberak ( 2015-04-22 02:01:37 -0600 )edit
2

Maybe you can resize your image and compute the histogram on the resized image ?

Eduardo gravatar imageEduardo ( 2015-04-22 07:09:36 -0600 )edit

^^ much better idea.

berak gravatar imageberak ( 2015-04-22 07:11:23 -0600 )edit