pyvips
pyvips copied to clipboard
sharpen doesn't work with vips8.8.1
After scaled an image with resize, I used sharpen(sigma=0.5, x1=1, y2=10, y3=20, m1=0, m2=3 ),
but nothing changed.
python: 3.6.8
libvips: 8.8.1
resized_image = pyvips.Image.resize(new_image, 0.2718, kernel="VIPS_KERNEL_LANCZOS3")
sharpen_img = resized_image.sharpen(sigma=0.5, x1=1, y2=10, y3=20, m1=0, m2=3)
sharpen_img.write_to_file("sharpen.jpg", Q=100)
Hello @2h4dl,
Your sigma is too small -- try 1.
#!/usr/bin/python3
import sys
import pyvips
x = pyvips.Image.new_from_file(sys.argv[1])
x = x.resize(0.2718)
y = x.sharpen(sigma=1, x1=1, y2=10, y3=20, m1=0, m2=3).colourspace("srgb")
x.join(y, "horizontal").write_to_file(sys.argv[2])
Oh, I see what you mean, yes, it should work with 0.5. I think this is because of a change in the way the int convolution path works.
I'll see if I can fix it.
I increased the precision of int convolution for sharpen and with sigma 0.5 I now see:
Thanks very much for pointing this out! This change will be in 8.8.2.
I made it restore the input colourspace too, so you can now write:
#!/usr/bin/python3
import sys
import pyvips
x = pyvips.Image.new_from_file(sys.argv[1])
x = x.resize(0.2718)
y = x.sharpen(sigma=0.5, x1=1, y2=10, y3=20, m1=0, m2=3)
x.join(y, "horizontal").write_to_file(sys.argv[2])
@jcupitt Thank you for you help, this helps me a lot.