Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "gmic.h"
- #include <cmath>
- int main() {
- // Load CLUT data.
- gmic_list<float> clut;
- gmic_list<char> names;
- gmic("-input_cube my_file.cube",clut,names);
- // Apply CLUT on one image
- // (this section can be duplicated and parallelized).
- gmic_list<float> list;
- list.assign(2);
- list[0]._width = clut[0]._width;
- list[0]._height = clut[0]._height;
- list[0]._depth = clut[0]._depth;
- list[0]._spectrum = clut[0]._spectrum;
- list[0]._data = clut[0]._data;
- list[0]._is_shared = true; // <- here's the trick : we add the CLUT data as a shared image !
- gmic_image<float> &img = list[1];
- img.assign(256,256,1,3); // we will fill list[1] with some image data to process.
- float *ptr = img;
- for (unsigned int c = 0; c<img._spectrum; ++c)
- for (unsigned int y = 0; y<img._height; ++y)
- for (unsigned int x = 0; x<img._width; ++x)
- *(ptr++) = 127 + 120*std::cos(x/3.)*std::sin(y/5);
- gmic("-map_clut[1] [0] -rm[0] -o foo.png",list,names); // Let's go my friend !
- // End of the parallelized section.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement