pyvips icon indicating copy to clipboard operation
pyvips copied to clipboard

sharpen doesn't work with vips8.8.1

Open 2h4dl opened this issue 5 years ago • 4 comments

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)

2h4dl avatar Aug 28 '19 06:08 2h4dl

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])

x

jcupitt avatar Aug 28 '19 07:08 jcupitt

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.

jcupitt avatar Aug 28 '19 07:08 jcupitt

I increased the precision of int convolution for sharpen and with sigma 0.5 I now see:

x

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 avatar Aug 28 '19 08:08 jcupitt

@jcupitt Thank you for you help, this helps me a lot.

2h4dl avatar Aug 28 '19 09:08 2h4dl