How can I calculate the histogram of an image using parallel Computing? Histogram of an image in serial is easy, but I don’t have any idea about calculating it in Parallel.
Any idea, algorithm, source code or a helpful link would be appreciated.
I am using MPI.
Here is the idea:
First you scatter the image rowwise (if you program in C) or columnwise (if you program in Fortran) using
MPI_Scatter()orMPI_Scatterv()(with scatterv you can distribute the image to a number of processes that is not an integer divisor of the number of rows/columns).Then every process computes the histogram of its part of the image. Let the histogram be stored in an integer array
local_histogramof 256 elements (I assume the images are grayscale).At the last step a global reduction with summation is performed with
MPI_Reduce():Afterwards the full global histogram would be in the
histogramarray at process with rank 0.