mirror of
https://github.com/lovell/sharp.git
synced 2026-02-11 00:56:14 +01:00
Add greyscale option to threshold operation (#480)
This commit is contained in:
committed by
Lovell Fuller
parent
4b98dbb454
commit
85f20c6e1b
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user