How to calculate histogram using every nth pixel opencv
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.
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!
" 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.
Maybe you can resize your image and compute the histogram on the resized image ?
^^ much better idea.