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

Appearance settings

Rewrite of image infrastructure #5718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 65 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
cf11aea
Remove Image class. Replace with resample func
mdboom Dec 22, 2015
3b7d1bb
Agg backend shouldn't do its own image interp
mdboom Dec 22, 2015
c9cae50
Update interpolation_methods.py to use viridis
mdboom Dec 22, 2015
4a05302
Remove svg.image_noscale rcParam
mdboom Dec 22, 2015
0aa222a
Rewrite image classes
mdboom Dec 22, 2015
0793aa2
Update backends for new API
mdboom Dec 22, 2015
1384c7c
Use transforms to rotate image, not hack
mdboom Dec 22, 2015
9148c7f
Update tests
mdboom Dec 22, 2015
820479e
Decrease generated code size
mdboom Dec 22, 2015
fad84c8
Remove explicit LICENSE.
mdboom Dec 22, 2015
64e84ea
Numpy 1.6 compatibility
mdboom Dec 30, 2015
0be04c0
Add Agg filter test
mdboom Dec 30, 2015
a8643f1
Fix formatting
mdboom Dec 30, 2015
5df79f0
Mark test as known fail on Numpy 1.6
mdboom Dec 30, 2015
b436f1a
Update draw_image API doc
mdboom Dec 30, 2015
dfbc39d
Fix reference counting
mdboom Dec 30, 2015
9d3b468
[skip-ci] PEP8
mdboom Dec 30, 2015
f9d8534
Update what's new
mdboom Dec 30, 2015
7b32cd8
Fix demo_annotation_box.py
mdboom Dec 30, 2015
6e60ebf
Fix #3057: Don't composite when interpolation == 'none'
mdboom Dec 30, 2015
dc66ed0
Remove broken example
mdboom Dec 30, 2015
7cccfb3
Support 16-bit grayscale
mdboom Dec 30, 2015
5073f6e
Fix permissions on demo_image_affine.py
mdboom Dec 31, 2015
625e80a
Fix alpha handling for interpolation == 'none'
mdboom Dec 31, 2015
c778cfc
Use `kind` instead of `issubclass`
mdboom Dec 31, 2015
9fe6658
Update docstring
mdboom Dec 31, 2015
d61ac2a
Revert change
mdboom Dec 31, 2015
b3318fd
Make demo_text_path.py work again
mdboom Dec 31, 2015
ffbbf05
Remove extraneous space
mdboom Dec 31, 2015
fbb55c8
Privatize self._images
mdboom Dec 31, 2015
34d6cc8
Simplify expression
mdboom Jan 1, 2016
4c5a3bf
Update docstring
mdboom Jan 1, 2016
9448208
Fix #5520: Don't round up if already rounded
mdboom Jan 5, 2016
83f4bc9
Merge pull request #17 from tacaswell/image-interpolation
mdboom Jan 4, 2016
d5030a4
Use abs() for NEAREST check
mdboom Jan 5, 2016
55c1abb
Image composite respecting z-order
mdboom Jan 5, 2016
fe376c4
Fix #4280: Preserve size when saving images
mdboom Jan 5, 2016
5266fde
Python 2.x fix
mdboom Jan 5, 2016
9285c3a
Update composite_images docstring
mdboom Jan 7, 2016
e2b2bbe
Refine can_composite
mdboom Jan 7, 2016
b894683
Improve make_image docstring
mdboom Jan 7, 2016
4e43c8b
Use X.ndim over len(X.shape)
mdboom Jan 7, 2016
8665697
Use float32 when applying alpha
mdboom Jan 7, 2016
d21a6ed
Use output.shape
mdboom Jan 7, 2016
2d2a126
Add unsampled kwarg everywhere
mdboom Jan 7, 2016
6d3518a
PEP8
mdboom Jan 7, 2016
0b8d693
Use super()
mdboom Jan 7, 2016
0f43f68
Put shape in exception
mdboom Jan 7, 2016
cd0e7e0
Case insensitive check for PNG extension
mdboom Jan 7, 2016
e62832f
Fix Numpy version check
mdboom Jan 7, 2016
e7d54d5
@cleanup unnecessary here
mdboom Jan 7, 2016
3e532e1
Make BboxImage work
mdboom Jan 7, 2016
cfad8d9
Reinstate strictness of test_imsave_color_alpha
mdboom Jan 7, 2016
e52c26f
PEP8
mdboom Jan 7, 2016
0469ab7
Fix has image test in Axes
mdboom Jan 7, 2016
b391f08
Refactor image compositing logic into a single function
mdboom Jan 7, 2016
89365c1
Properly handle NULL composite image
mdboom Jan 11, 2016
7f2f375
PEP8
mdboom Jan 11, 2016
9827d1f
Consistent handling of empty composite images
mdboom Jan 11, 2016
5be66de
Rename lena variable
mdboom Jan 29, 2016
bd521cd
Update docstring to reflect reality
mdboom Jan 29, 2016
d6b22a5
Address more minor comments in the PR
mdboom Feb 2, 2016
fff1d66
Increase tolerance on Windows
mdboom Feb 17, 2016
da6c00b
Increase tolerance of png_suite test
mdboom Feb 17, 2016
c9b2425
PEP8
mdboom Feb 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge pull request #17 from tacaswell/image-interpolation
Image interpolation
  • Loading branch information
mdboom committed Feb 17, 2016
commit 83f4bc9db0dc130f85649ccc328b21b5f3415749
7 changes: 4 additions & 3 deletions 7 lib/matplotlib/backends/backend_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
# A reference to the figure is needed as we need to change
# the figure dpi before and after the rasterization. Although
# this looks ugly, I couldn't find a better solution. -JJL
self.figure=figure
self.figure = figure
self._figdpi = figure.get_dpi()

self._bbox_inches_restore = bbox_inches_restore
Expand All @@ -69,6 +69,7 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
draw_gouraud_triangles option_scale_image
_text2path _get_text_path_transform height width
""".split()

def _set_current_renderer(self, renderer):
self._renderer = renderer

Expand All @@ -91,7 +92,7 @@ def start_rasterizing(self):
# change the dpi of the figure temporarily.
self.figure.set_dpi(self.dpi)

if self._bbox_inches_restore: # when tight bbox is used
if self._bbox_inches_restore: # when tight bbox is used
r = process_figure_for_rasterizing(self.figure,
self._bbox_inches_restore)
self._bbox_inches_restore = r
Expand All @@ -115,7 +116,7 @@ def stop_rasterizing(self):
if self._rasterizing == 0:
self._set_current_renderer(self._vector_renderer)

width, height = self._width * self.dpi, self._height * self.dpi
height = self._height * self.dpi
buffer, bounds = self._raster_renderer.tostring_rgba_minimized()
l, b, w, h = bounds
if w > 0 and h > 0:
Expand Down
6 changes: 4 additions & 2 deletions 6 lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,10 @@ def writeTrailer(self):
class RendererPdf(RendererBase):
afm_font_cache = maxdict(50)

def __init__(self, file, image_dpi):
def __init__(self, file, image_dpi, height, width):
RendererBase.__init__(self)
self.height = height
self.width = width
self.file = file
self.gc = self.new_gc()
self.mathtext_parser = MathTextParser("Pdf")
Expand Down Expand Up @@ -2517,7 +2519,7 @@ def print_pdf(self, filename, **kwargs):
_bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
renderer = MixedModeRenderer(
self.figure, width, height, image_dpi,
RendererPdf(file, image_dpi),
RendererPdf(file, image_dpi, height, width),
bbox_inches_restore=_bbox_inches_restore)
self.figure.draw(renderer)
renderer.finalize()
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions 4 lib/matplotlib/tests/test_backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def test_composite_image():
plt.rcParams['image.composite_image'] = True
with PdfPages(io.BytesIO()) as pdf:
fig.savefig(pdf, format="pdf")
assert len(pdf._file.images.keys()) == 1
assert len(pdf._file._images.keys()) == 1
plt.rcParams['image.composite_image'] = False
with PdfPages(io.BytesIO()) as pdf:
fig.savefig(pdf, format="pdf")
assert len(pdf._file.images.keys()) == 2
assert len(pdf._file._images.keys()) == 2


@image_comparison(baseline_images=['hatching_legend'],
Expand Down
1 change: 0 additions & 1 deletion 1 lib/matplotlib/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def test_pep8_conformance_installed_files():
'backends/backend_gtkagg.py',
'backends/backend_gtkcairo.py',
'backends/backend_macosx.py',
'backends/backend_mixed.py',
'backends/backend_pgf.py',
'backends/backend_ps.py',
'backends/backend_svg.py',
Expand Down
10 changes: 8 additions & 2 deletions 10 lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from nose.tools import assert_raises
from numpy.testing import (
assert_array_equal, assert_array_almost_equal, assert_allclose)
from matplotlib.testing.noseclasses import KnownFailureTest


try:
Expand Down Expand Up @@ -97,6 +98,8 @@ def test_image_python_io():
buffer.seek(0)
plt.imread(buffer)


@cleanup
@knownfailureif(not HAS_PIL)
def test_imread_pil_uint16():
img = plt.imread(os.path.join(os.path.dirname(__file__),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would plt.imread need a cleanup decorator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't. Good point.

Expand All @@ -113,6 +116,8 @@ def test_imread_pil_uint16():
# plt.imread(fname)
# os.remove(fname)


@cleanup
def test_imsave():
# The goal here is that the user can specify an output logical DPI
# for the image, but this will not actually add any extra pixels
Expand Down Expand Up @@ -401,8 +406,7 @@ def test_rasterize_dpi():
rcParams['savefig.dpi'] = 10


@image_comparison(baseline_images=['bbox_image_inverted'],
extensions=['png', 'pdf'])
@cleanup
def test_bbox_image_inverted():
# This is just used to produce an image to feed to BboxImage
fig = plt.figure()
Expand All @@ -416,6 +420,7 @@ def test_bbox_image_inverted():

bbox_im = BboxImage(Bbox([[100, 100], [0, 0]]))
bbox_im.set_data(image)
bbox_im.set_clip_on(False)
axes.add_artist(bbox_im)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why drop the image_comparison here? This test is now just a smoketest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is because the original test images were never correct, then got
regenerated wrong.

This is testing that a seg fault is fixed and bboximage should get a better
image test.

On Wed, Jan 6, 2016, 15:52 Benjamin Root notifications@github.com wrote:

In lib/matplotlib/tests/test_image.py
#5718 (comment):

@@ -402,6 +415,7 @@ def test_bbox_image_inverted():

 bbox_im = BboxImage(Bbox([[100, 100], [0, 0]]))
 bbox_im.set_data(image)
  • bbox_im.set_clip_on(False)
    axes.add_artist(bbox_im)

Why drop the image_comparison here? This test is now just a smoketest.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/5718/files#r49007890.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I plan to replace this with a proper BboxImage test. The fun of this is that BboxImage isn't even terribly clearly defined as to what it's supposed to do in the first place... I'll probably use some of the related examples as a starting point.



Expand Down Expand Up @@ -552,6 +557,7 @@ def test_log_scale_image():
ax.set_yscale('log')



@image_comparison(baseline_images=['rotate_image'],
remove_text=True)
def test_rotate_image():
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.