| 226 | } |
| 227 | |
| 228 | void populateBins(Bitmap& bmp, int *hist_array, const unsigned nbins, float *hist_cols) |
| 229 | { |
| 230 | for (unsigned y=0; y<bmp.height; ++y) { |
| 231 | for (unsigned x=0; x<bmp.width; ++x) { |
| 232 | int offset = x + y * bmp.width; |
| 233 | unsigned char noiseVal = bmp.ptr[offset*4]; |
| 234 | unsigned idx = (int)((float)noiseVal/255.f * nbins); |
| 235 | hist_array[idx]++; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | for (unsigned b=0; b<nbins; ++b) { |
| 240 | hist_cols[3*b+0] = std::rand()/(float)RAND_MAX; |
| 241 | hist_cols[3*b+1] = std::rand()/(float)RAND_MAX; |
| 242 | hist_cols[3*b+2] = std::rand()/(float)RAND_MAX; |
| 243 | } |
| 244 | } |