Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MNT]: change image resampling to Pillow #21231

Open
@jklymak

Description

@jklymak

Summary

We currently use a relatively complicated image resampling algorithm because we want to preserve data values above vmin and vmax but theagg resample routines only allow values between 0 and 1. Agg also does not preserve NaN, so we need to remask at the end. This makesimage._make_image quite long and convoluted.

Proposed fix

Pillow allows 32-bit one-channel images, with no apparent restrictions on the values, and has aresize method that seems to do resampling as we would like.

The only issue that I can see is that Pillow has fewerresampling kernels than we do

  • nearest
  • box
  • bilinear
  • bicubic
  • hamming
  • lanczos

Whereas we allow quite a few more currently (inherited fromagg):

methods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16',           'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',           'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos']

I frankly think very few people are using the more exotic filters, or need to. If we want to change to pillow we could

  • keep the old resampling around for the other filters (perhaps deprecating them)
  • add the other filters to Pillow

The patch for the giant resampling code is:

+                im = Image.fromarray(A)+                output = np.asarray(im.resize(out_shape, Image.BICUBIC))+                output = self.norm(output)+                out_alpha = np.ones_like(output)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp