bilinear interp. supports complex types
in line with cubic etc.
This commit is contained in:
parent
fba2ac2f85
commit
82cecf3d9f
14
TODO
14
TODO
@ -1,17 +1,3 @@
|
||||
- try:
|
||||
|
||||
$ ./test_resample.py TestResample.test_reduce
|
||||
File "./test_resample.py", line 129, in test_reduce
|
||||
self.assertLess(d, 5)
|
||||
AssertionError: 147.0 not less than 5
|
||||
|
||||
affine bicubic != reduce cubic
|
||||
|
||||
displacement error, I guess?
|
||||
|
||||
yes, reduceh output should move one to the right
|
||||
|
||||
- need more tests for reduce, test every kernel plus every numeric type
|
||||
|
||||
- try orc version of reducev? and shrinkv? maybe shrinkh?
|
||||
|
||||
|
@ -508,6 +508,8 @@ G_DEFINE_TYPE( VipsInterpolateBilinear, vips_interpolate_bilinear,
|
||||
case VIPS_FORMAT_INT: FLOAT( int ); break; \
|
||||
case VIPS_FORMAT_FLOAT: FLOAT( float ); break; \
|
||||
case VIPS_FORMAT_DOUBLE:FLOAT( double ); break; \
|
||||
case VIPS_FORMAT_COMPLEX: FLOAT( float ); break; \
|
||||
case VIPS_FORMAT_DPCOMPLEX:FLOAT( double ); break; \
|
||||
default: \
|
||||
g_assert( FALSE ); \
|
||||
} \
|
||||
@ -521,7 +523,8 @@ vips_interpolate_bilinear_interpolate( VipsInterpolate *interpolate,
|
||||
*/
|
||||
const int ps = VIPS_IMAGE_SIZEOF_PEL( in->im );
|
||||
const int ls = VIPS_REGION_LSKIP( in );
|
||||
const int b = in->im->Bands;
|
||||
const int b = in->im->Bands *
|
||||
(vips_band_format_iscomplex( in->im->BandFmt ) ? 2 : 1);
|
||||
|
||||
const int ix = (int) x;
|
||||
const int iy = (int) y;
|
||||
|
@ -116,7 +116,12 @@ class TestResample(unittest.TestCase):
|
||||
|
||||
def test_reduce(self):
|
||||
im = Vips.Image.new_from_file("images/IMG_4618.jpg")
|
||||
# cast down to 0-127, the smallest range, so we aren't messed up by
|
||||
# clipping
|
||||
im = im.cast(Vips.BandFormat.CHAR)
|
||||
bicubic = Vips.Interpolate.new("bicubic")
|
||||
bilinear = Vips.Interpolate.new("bilinear")
|
||||
nearest = Vips.Interpolate.new("nearest")
|
||||
|
||||
for fac in [1, 1.1, 1.5, 1.999]:
|
||||
for fmt in all_formats:
|
||||
@ -126,7 +131,26 @@ class TestResample(unittest.TestCase):
|
||||
interpolate = bicubic,
|
||||
oarea = [0, 0, x.width / fac, x.height / fac])
|
||||
d = (r - a).abs().max()
|
||||
self.assertLess(d, 5)
|
||||
self.assertLess(d, 10)
|
||||
|
||||
for fac in [1, 1.1, 1.5, 1.999]:
|
||||
for fmt in all_formats:
|
||||
x = im.cast(fmt)
|
||||
r = x.reduce(fac, fac, kernel = "linear")
|
||||
a = x.affine([1.0 / fac, 0, 0, 1.0 / fac],
|
||||
interpolate = bilinear,
|
||||
oarea = [0, 0, x.width / fac, x.height / fac])
|
||||
d = (r - a).abs().max()
|
||||
self.assertLess(d, 10)
|
||||
|
||||
# for other kernels, just see if avg looks about right
|
||||
for fac in [1, 1.1, 1.5, 1.999]:
|
||||
for fmt in all_formats:
|
||||
for kernel in ["nearest", "lanczos2", "lanczos3"]:
|
||||
x = im.cast(fmt)
|
||||
r = x.reduce(fac, fac, kernel = kernel)
|
||||
d = abs(r.avg() - im.avg())
|
||||
self.assertLess(d, 2)
|
||||
|
||||
def test_resize(self):
|
||||
im = Vips.Image.new_from_file("images/IMG_4618.jpg")
|
||||
|
Loading…
Reference in New Issue
Block a user