#include "GlobalValues.h" #include struct HistogramStruct{ unsigned int* hist2D; int nBins; float bounds[4]; HistogramStruct(float minX, float minY, float maxX, float maxY, int bins){ //allocate memory for the histogram hist2D = (unsigned int*)malloc(sizeof(unsigned int)*bins*bins); memset(hist2D, 0, sizeof(unsigned int)*bins*bins); bounds[0] = minX; bounds[1] = maxX; bounds[2] = minY; bounds[3] = maxY; nBins = bins; } bool checkBounds(float x, float y){ if(x < bounds[0] || x > bounds[1] || y < bounds[2] || y > bounds[3]) return false; else return true; } void increment(float x, float y){ //increment the counter at the appropriate histogram location //is the location within the bounds of the histogram if(checkBounds(x, y)){ int binX = (x - bounds[0])/(bounds[1] - bounds[0]) * nBins; int binY = (y - bounds[2])/(bounds[3] - bounds[2]) * nBins; hist2D[binY * nBins + binX]++; } } void saveImage(string fileName){ //create an output image QImage outImage(nBins, nBins, QImage::Format_RGB888); //find the maximum value in the histogram unsigned int histMax = 0; for(int i=0; i histMax) histMax = hist2D[i]; cout<<"HistMax: "< maxV) maxV = v; if(u < minU) minU = u; if(u > maxU) maxU = u; } free(cpuVolume); cout<<"Data Value: "<