Hi programmers, I am a c# programmer but I have a very big project in C++ (Which I am not familiar with) and I am facing a big problem.
As part of the project, I need to convert the image (any image of any type bmp,jpeg,png...etc) to grayscale using openMP.
After doing some research, I got the main method which allows me to do the conversion using openMP, it's as follows:
// pDest is an unsigned char array of size width * height
// pSrc is an unsigned char array of size width * height * 4 (32-bit)
// To avoid floating point operation, all floating point weights
// in the original grayscale formula
// has been changed to integer approximation
// Use pragma for to make a parallel for loop
omp_set_num_threads(threads);
#pragma omp parallel for
for(int z = 0; z < height*width; z++)
{
pDest[z] = (pSrc[z*4+0]*3735 + pSrc[z*4 + 1]*19234+ pSrc[z*4+ 2]*9797)>>15;
}
But the problem is that I couldn't find any complete code to do that! So I am facing hard times reading the image first before processing it and later save it somewhere on the hard disk.
I would appreciate any help, even if the code is in serial (not parallel) I am sure it will help me a lot.