4. Curves#
A curve defines a lookup table, with values normalized to 1.0 (and then scaled to 65535 for 16-bit color inside the pipeline). It is defined by a series of points that increase in order along the x-axis and should encompass the full range from 0 to 1; otherwise, it will be extrapolated. ImageSDK interpolates the curve using a second-order spline. Below is an example of a curve defined by 4 red points. Note the right side, where ImageSdk extrapolates the missing data.

ImageSDK supports curve for red, green, blue, RGB (both channels), and luma (applied to luminosity and then scaled back to RGB). Below code show an example to set luma curve shown in the above graphics
#include "P1Image.hpp"
#include <iostream>
using namespace P1::ImageSdk;
int main()
{
try
{
// 1. Load IIQ image
RawImage im("Sample.IIQ");
// 2. Load convert config
ConvertConfig config;
config.SetLumaCurve({
{0.0, 0.0},
{0.3, 0.5},
{0.5, 0.4},
{0.9, 0.8}
});
// Optional test
// Get the interpolated curve
{
Curve discretized_curve = config.GetDiscretizedLumaCurve(128);
std::vector<double> X = discretized_curve.X();
std::vector<double> Y = discretized_curve.Y();
for (int i = 0; i < X.size(); i++)
{
printf("%.5f: %.5f \n", X[i], Y[i]);
}
}
// 3. Convert
BitmapImage bmp = im.Convert(config);
// 4. Export to Tiff
TiffWriter("out.tiff", bmp, im, TiffConfig());
return 0;
}
catch (const std::exception& e)
{
std::cerr << e.what();
return -1;
}
}
using P1.ImageSdk;
// 1. Load IIQ image
RawImage im = new("Sample.IIQ");
// 2. Load convert configuration
ConvertConfig config = new();
config.SetLumaCurve(new Point2D[]{
new Point2D(0.0, 0.0),
new Point2D(0.3, 0.5),
new Point2D(0.5, 0.4),
new Point2D(0.9, 0.8)
});
// Optional test
{
Curve distcretized_curve = config.GetDiscretizedLumaCurve(128);
double[] X = distcretized_curve.X();
double[] Y = distcretized_curve.Y();
for(int i = 0; i < X.Length; i++)
{
Console.WriteLine($"{X[i]}: {Y[i]}");
}
}
// 3. Convert
IBitmapImage bmp = im.Convert(config);
// 4. Export to Tiff
im.WriteAsTiff("out.tiff", bmp, new TiffConfig());