ray-cast / lut

color lookup tables (LUTs) for color grading
Other
103 stars 4 forks source link

Example? #1

Closed melMass closed 3 years ago

melMass commented 3 years ago

Hi,

Thanks for the library. I'm trying the samples without luck.

Here is my reproducible sample:

#include <iostream>
#include "lut.hpp"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"

int main()
{

  std::string lut_name = "default";
  std::string image_path = "image";
  std::string out_path = "image";

  int width, height, channels;
  auto *img = stbi_load(image_path.c_str(), &width, &height, &channels, 3);

  if (img == nullptr)
  {
    printf("Error in loading the image\n");
    return 1;
  }

  auto lut = octoon::image::lut::parse(lut_name);

  for (std::size_t i = 0; i < width; i++)
  {
    for (std::size_t j = 0; j < height; j++)
    {
      auto *px = img + (i * j) * 3;

      auto data = lut.lookup(px[0], px[1], px[2]); // The (r,g,b) can be extended to support these types of std::uint8_t, std::uint16_t, std::uint32_t, float, double

      px[0] = data[0];
      px[1] = data[1];
      px[2] = data[2];
    }
  }

  stbi_write_png(out_path.c_str(), width, height, 3, img, width * 3);

  stbi_image_free(img);

  return 0;
}

But this is my output,

image

Can you point me in the right direction? Thanks

205418367 commented 4 months ago

问题解决了吗?