Expose linear transform feature of libvips (#1024)

This commit is contained in:
Marcel
2018-02-04 11:36:04 +01:00
committed by Lovell Fuller
parent 73edfb3d2c
commit d599d1f29e
15 changed files with 156 additions and 1 deletions

View File

@@ -341,4 +341,18 @@ namespace sharp {
return image.extract_area(left, top, width, height);
}
/*
* Calculate (a * in + b)
*/
VImage Linear(VImage image, double const a, double const b) {
if (HasAlpha(image)) {
// Separate alpha channel
VImage imageWithoutAlpha = image.extract_band(0,
VImage::option()->set("n", image.bands() - 1));
VImage alpha = image[image.bands() - 1];
return imageWithoutAlpha.linear(a, b).bandjoin(alpha);
} else {
return image.linear(a, b);
}
}
} // namespace sharp