Skip to content

Commit

Permalink
Remove openmp in spectrum because windows is not happy...
Browse files Browse the repository at this point in the history
  • Loading branch information
BDoignies committed Aug 7, 2023
1 parent 7f941f3 commit c4fd3d3
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/metrics/Spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,32 @@ int main(int argc, char** argv)
return 0;
}

// Compute max value for normalization purposes
unsigned char* data = new unsigned char[res * res];
double maxval = rslts[0];

// PLS WINDOWS & CMake !!! ADD SUPPORT FOR REAL OPENMP CODE !!!
#ifdef _WIN32
// Compute max value for normalization purposes
for (auto rslt : rslts)
maxval = (rslt > maxval) ? rslt : maxval;

// Copy data to unsigned char buffer
for (uint32_t y = 0; y < res; y++)
{
for (uint32_t x = 0; x < res; x++)
{
const uint32_t idx = x + y * res;

double value = rslts[idx] / maxval;
data[idx] = static_cast<unsigned char>(255 * value);
}
}
#else
// Compute max value for normalization purposes
#pragma omp parallel for reduction(max: maxval)
for (auto rslt : rslts)
maxval = (rslt > maxval) ? rslt : maxval;

unsigned char* data = new unsigned char[res * res];


// Copy data to unsigned char buffer
#pragma omp parallel for
for (uint32_t y = 0; y < res; y++)
Expand All @@ -96,7 +114,7 @@ int main(int argc, char** argv)
data[idx] = static_cast<unsigned char>(255 * value);
}
}

#endif
// Write image
stbi_write_png(imgFile.c_str(), res, res, 1, data, res * sizeof(unsigned char));

Expand Down

0 comments on commit c4fd3d3

Please sign in to comment.