mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose optional minAmplitude parameter of blur operation (#4172)
This commit is contained in:
committed by
GitHub
parent
67a5854b89
commit
735fee74db
@@ -144,7 +144,7 @@ namespace sharp {
|
||||
/*
|
||||
* Gaussian blur. Use sigma of -1.0 for fast blur.
|
||||
*/
|
||||
VImage Blur(VImage image, double const sigma, VipsPrecision precision) {
|
||||
VImage Blur(VImage image, double const sigma, VipsPrecision precision, double const minAmpl) {
|
||||
if (sigma == -1.0) {
|
||||
// Fast, mild blur - averages neighbouring pixels
|
||||
VImage blur = VImage::new_matrixv(3, 3,
|
||||
@@ -156,7 +156,8 @@ namespace sharp {
|
||||
} else {
|
||||
// Slower, accurate Gaussian blur
|
||||
return StaySequential(image).gaussblur(sigma, VImage::option()
|
||||
->set("precision", precision));
|
||||
->set("precision", precision)
|
||||
->set("min_ampl", minAmpl));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace sharp {
|
||||
/*
|
||||
* Gaussian blur. Use sigma of -1.0 for fast blur.
|
||||
*/
|
||||
VImage Blur(VImage image, double const sigma, VipsPrecision precision);
|
||||
VImage Blur(VImage image, double const sigma, VipsPrecision precision, double const minAmpl);
|
||||
|
||||
/*
|
||||
* Convolution with a kernel.
|
||||
|
||||
@@ -592,7 +592,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
|
||||
// Blur
|
||||
if (shouldBlur) {
|
||||
image = sharp::Blur(image, baton->blurSigma, baton->precision);
|
||||
image = sharp::Blur(image, baton->blurSigma, baton->precision, baton->minAmpl);
|
||||
}
|
||||
|
||||
// Unflatten the image
|
||||
@@ -1542,6 +1542,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
||||
baton->negateAlpha = sharp::AttrAsBool(options, "negateAlpha");
|
||||
baton->blurSigma = sharp::AttrAsDouble(options, "blurSigma");
|
||||
baton->precision = sharp::AttrAsEnum<VipsPrecision>(options, "precision", VIPS_TYPE_PRECISION);
|
||||
baton->minAmpl = sharp::AttrAsDouble(options, "minAmpl");
|
||||
baton->brightness = sharp::AttrAsDouble(options, "brightness");
|
||||
baton->saturation = sharp::AttrAsDouble(options, "saturation");
|
||||
baton->hue = sharp::AttrAsInt32(options, "hue");
|
||||
|
||||
@@ -79,6 +79,7 @@ struct PipelineBaton {
|
||||
bool negateAlpha;
|
||||
double blurSigma;
|
||||
VipsPrecision precision;
|
||||
double minAmpl;
|
||||
double brightness;
|
||||
double saturation;
|
||||
int hue;
|
||||
|
||||
Reference in New Issue
Block a user