remove mitchell filter. Has no advantages over bicubic

This commit is contained in:
homm 2016-06-16 23:23:03 +03:00
parent a67e5453d5
commit 66715246c1
4 changed files with 2 additions and 56 deletions

View File

@ -172,7 +172,6 @@ BOX = 4
BILINEAR = LINEAR = 2
HAMMING = 5
BICUBIC = CUBIC = 3
MITCHELL = 6
LANCZOS = ANTIALIAS = 1
# dithers
@ -1522,8 +1521,7 @@ class Image(object):
:param resample: An optional resampling filter. This can be
one of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BOX`,
:py:attr:`PIL.Image.BILINEAR`, :py:attr:`PIL.Image.HAMMING`,
:py:attr:`PIL.Image.BICUBIC`, :py:attr:`PIL.Image.MITCHELL` or
:py:attr:`PIL.Image.LANCZOS`.
:py:attr:`PIL.Image.BICUBIC` or :py:attr:`PIL.Image.LANCZOS`.
If omitted, or if the image has mode "1" or "P", it is
set :py:attr:`PIL.Image.NEAREST`.
See: :ref:`concept-filters`.
@ -1531,8 +1529,7 @@ class Image(object):
"""
if resample not in (
NEAREST, BILINEAR, BICUBIC, LANCZOS,
BOX, HAMMING, MITCHELL,
NEAREST, BILINEAR, BICUBIC, LANCZOS, BOX, HAMMING,
):
raise ValueError("unknown resampling filter")

View File

@ -126,16 +126,6 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
for channel in case.split():
self.check_case(channel, self.make_sample(data, (6, 6)))
def test_reduce_mitchell(self):
for mode in ['RGBX', 'RGB', 'La', 'L']:
case = self.make_case(mode, (12, 12), 0xe1)
case = case.resize((6, 6), Image.MITCHELL)
data = ('e1 e2 cc'
'e2 e3 cd'
'cc cd bb')
for channel in case.split():
self.check_case(channel, self.make_sample(data, (6, 6)))
def test_reduce_lanczos(self):
for mode in ['RGBX', 'RGB', 'La', 'L']:
case = self.make_case(mode, (16, 16), 0xe1)
@ -187,17 +177,6 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
for channel in case.split():
self.check_case(channel, self.make_sample(data, (8, 8)))
def test_enlarge_mitchell(self):
for mode in ['RGBX', 'RGB', 'La', 'L']:
case = self.make_case(mode, (4, 4), 0xe1)
case = case.resize((8, 8), Image.MITCHELL)
data = ('e1 e4 e6 b2'
'e4 e7 e9 b3'
'e6 e9 eb b4'
'b2 b3 b5 9a')
for channel in case.split():
self.check_case(channel, self.make_sample(data, (8, 8)))
def test_enlarge_lanczos(self):
for mode in ['RGBX', 'RGB', 'La', 'L']:
case = self.make_case(mode, (6, 6), 0xe1)
@ -274,7 +253,6 @@ class CoreResampleAlphaCorrectTest(PillowTestCase):
self.run_levels_case(case.resize((512, 32), Image.BILINEAR))
self.run_levels_case(case.resize((512, 32), Image.HAMMING))
self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
self.run_levels_case(case.resize((512, 32), Image.MITCHELL))
self.run_levels_case(case.resize((512, 32), Image.LANCZOS))
@unittest.skip("current implementation isn't precise enough")
@ -284,7 +262,6 @@ class CoreResampleAlphaCorrectTest(PillowTestCase):
self.run_levels_case(case.resize((512, 32), Image.BILINEAR))
self.run_levels_case(case.resize((512, 32), Image.HAMMING))
self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
self.run_levels_case(case.resize((512, 32), Image.MITCHELL))
self.run_levels_case(case.resize((512, 32), Image.LANCZOS))
def make_dity_case(self, mode, clean_pixel, dirty_pixel):
@ -312,7 +289,6 @@ class CoreResampleAlphaCorrectTest(PillowTestCase):
self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255, 255, 0))
self.run_dity_case(case.resize((20, 20), Image.HAMMING), (255, 255, 0))
self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255, 255, 0))
self.run_dity_case(case.resize((20, 20), Image.MITCHELL), (255, 255, 0))
self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255, 255, 0))
def test_dirty_pixels_la(self):
@ -321,7 +297,6 @@ class CoreResampleAlphaCorrectTest(PillowTestCase):
self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255,))
self.run_dity_case(case.resize((20, 20), Image.HAMMING), (255,))
self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255,))
self.run_dity_case(case.resize((20, 20), Image.MITCHELL), (255,))
self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255,))

View File

@ -233,7 +233,6 @@ extern void ImagingError_Clear(void);
#define IMAGING_TRANSFORM_BILINEAR 2
#define IMAGING_TRANSFORM_HAMMING 5
#define IMAGING_TRANSFORM_BICUBIC 3
#define IMAGING_TRANSFORM_MITCHELL 6
#define IMAGING_TRANSFORM_LANCZOS 1
typedef int (*ImagingTransformMap)(double* X, double* Y,

View File

@ -50,27 +50,6 @@ static inline double bicubic_filter(double x)
#undef a
}
static inline double mitchell_filter(double x)
{
double fB = 1.f / 3.f;
double fC = 1.f / 3.f;
double fA1 = -fB - 6*fC;
double fB1 = 6*fB + 30*fC;
double fC1 = -12*fB - 48*fC;
double fD1 = 8*fB + 24*fC;
double fA2 = 12 - 9*fB - 6*fC;
double fB2 = -18 + 12*fB + 6*fC;
double fD2 = 6 - 2*fB;
if (x < 0.0)
x = -x;
if (x < 1.0)
return ((fA2 * x + fB2) * x*x + fD2) * (1.f/6.f);
if (x < 2.0)
return (((fA1 * x + fB1) * x + fC1) * x + fD1) * (1.f/6.f);
return 0.0;
}
static inline double sinc_filter(double x)
{
if (x == 0.0)
@ -91,7 +70,6 @@ static struct filter BOX = { box_filter, 0.5 };
static struct filter BILINEAR = { bilinear_filter, 1.0 };
static struct filter HAMMING = { hamming_filter, 1.0 };
static struct filter BICUBIC = { bicubic_filter, 2.0 };
static struct filter MITCHELL = { mitchell_filter, 2.0 };
static struct filter LANCZOS = { lanczos_filter, 3.0 };
@ -575,9 +553,6 @@ ImagingResample(Imaging imIn, int xsize, int ysize, int filter)
case IMAGING_TRANSFORM_BICUBIC:
filterp = &BICUBIC;
break;
case IMAGING_TRANSFORM_MITCHELL:
filterp = &MITCHELL;
break;
case IMAGING_TRANSFORM_LANCZOS:
filterp = &LANCZOS;
break;