Add greyscale option to threshold operation (#480)

This commit is contained in:
Matt Hirsch
2016-07-03 14:32:07 -04:00
committed by Lovell Fuller
parent 4b98dbb454
commit 85f20c6e1b
8 changed files with 55 additions and 3 deletions

View File

@@ -52,6 +52,7 @@ using sharp::Blur;
using sharp::Sharpen;
using sharp::EntropyCrop;
using sharp::TileCache;
using sharp::Threshold;
using sharp::ImageType;
using sharp::ImageTypeId;
@@ -625,7 +626,7 @@ class PipelineWorker : public AsyncWorker {
// Threshold - must happen before blurring, due to the utility of blurring after thresholding
if (shouldThreshold) {
image = image.colourspace(VIPS_INTERPRETATION_B_W) >= baton->threshold;
image = Threshold(image, baton->threshold, baton->thresholdGrayscale);
}
// Blur
@@ -1107,6 +1108,7 @@ NAN_METHOD(pipeline) {
baton->sharpenFlat = attrAs<double>(options, "sharpenFlat");
baton->sharpenJagged = attrAs<double>(options, "sharpenJagged");
baton->threshold = attrAs<int32_t>(options, "threshold");
baton->thresholdGrayscale = attrAs<bool>(options, "thresholdGrayscale");
baton->gamma = attrAs<double>(options, "gamma");
baton->greyscale = attrAs<bool>(options, "greyscale");
baton->normalize = attrAs<bool>(options, "normalize");