Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. int* calculvector(unsigned char* img, int w, int h, int hh)
  2. {
  3.     int *hist = new int[256];
  4.     for (int i = 0;i < 256;++i)
  5.     {
  6.         hist[i] = 0;
  7.     }
  8.     for (int y = 0; y < h; y++)
  9.         for (int x = 0; x < w; x++)
  10.         {
  11.             hist[(int)img[y*w + x]]++;
  12.         }
  13.     int max = *max_element(hist, hist + 255);
  14.     for (int i = 0;i < 256;++i)
  15.     {
  16.         hist[i] = (int)hist[i] / (double)max * hh;
  17.         cout << hist[i] << " ";
  18.     }
  19.     return hist;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement