Advertisement
Guest User

Untitled

a guest
Jun 13th, 2016
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include "gmic.h"
  2. #include <cmath>
  3.  
  4. int main() {
  5.  
  6.   // Load CLUT data.
  7.   gmic_list<float> clut;
  8.   gmic_list<char> names;
  9.   gmic("-input_cube my_file.cube",clut,names);
  10.  
  11.   // Apply CLUT on one image
  12.   // (this section can be duplicated and parallelized).
  13.   gmic_list<float> list;
  14.   list.assign(2);
  15.   list[0]._width = clut[0]._width;
  16.   list[0]._height = clut[0]._height;
  17.   list[0]._depth = clut[0]._depth;
  18.   list[0]._spectrum = clut[0]._spectrum;
  19.   list[0]._data = clut[0]._data;
  20.   list[0]._is_shared = true;   // <- here's the trick : we add the CLUT data as a shared image !
  21.  
  22.   gmic_image<float> &img = list[1];
  23.   img.assign(256,256,1,3); // we will fill list[1] with some image data to process.
  24.   float *ptr = img;
  25.   for (unsigned int c = 0; c<img._spectrum; ++c)
  26.     for (unsigned int y = 0; y<img._height; ++y)
  27.       for (unsigned int x = 0; x<img._width; ++x)
  28.         *(ptr++) = 127 + 120*std::cos(x/3.)*std::sin(y/5);
  29.  
  30.   gmic("-map_clut[1] [0] -rm[0] -o foo.png",list,names); // Let's go my friend !
  31.  
  32.   // End of the parallelized section.
  33.  
  34.   return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement