MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _make_image

Method _make_image

lib/matplotlib/image.py:350–579  ·  view source on GitHub ↗

Normalize, rescale, and colormap the image *A* from the given *in_bbox* (in data space), to the given *out_bbox* (in pixel space) clipped to the given *clip_bbox* (also in pixel space), and magnified by the *magnification* factor. Parameters --------

(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
                    unsampled=False, round_to_pixel_border=True)

Source from the content-addressed store, hash-verified

348 super().changed()
349
350 def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
351 unsampled=False, round_to_pixel_border=True):
352 """
353 Normalize, rescale, and colormap the image *A* from the given *in_bbox*
354 (in data space), to the given *out_bbox* (in pixel space) clipped to
355 the given *clip_bbox* (also in pixel space), and magnified by the
356 *magnification* factor.
357
358 Parameters
359 ----------
360 A : ndarray
361
362 - a (M, N) array interpreted as scalar (greyscale) image,
363 with one of the dtypes `~numpy.float32`, `~numpy.float64`,
364 `~numpy.float128`, `~numpy.uint16` or `~numpy.uint8`.
365 - (M, N, 4) RGBA image with a dtype of `~numpy.float32`,
366 `~numpy.float64`, `~numpy.float128`, or `~numpy.uint8`.
367
368 in_bbox : `~matplotlib.transforms.Bbox`
369
370 out_bbox : `~matplotlib.transforms.Bbox`
371
372 clip_bbox : `~matplotlib.transforms.Bbox`
373
374 magnification : float, default: 1
375
376 unsampled : bool, default: False
377 If True, the image will not be scaled, but an appropriate
378 affine transformation will be returned instead.
379
380 round_to_pixel_border : bool, default: True
381 If True, the output image size will be rounded to the nearest pixel
382 boundary. This makes the images align correctly with the Axes.
383 It should not be used if exact scaling is needed, such as for
384 `.FigureImage`.
385
386 Returns
387 -------
388 image : (M, N, 4) `numpy.uint8` array
389 The RGBA image, resampled unless *unsampled* is True.
390 x, y : float
391 The upper left corner where the image should be drawn, in pixel
392 space.
393 trans : `~matplotlib.transforms.Affine2D`
394 The affine transformation from image to pixel space.
395 """
396 if A is None:
397 raise RuntimeError('You must first set the image '
398 'array or the image attribute')
399 if A.size == 0:
400 raise RuntimeError("_make_image must get a non-empty image. "
401 "Your Artist's draw method must filter before "
402 "this method is called.")
403
404 clipped_bbox = Bbox.intersection(out_bbox, clip_bbox)
405
406 if clipped_bbox is None:
407 return None, 0, 0, None

Callers 3

make_imageMethod · 0.80
make_imageMethod · 0.80
make_imageMethod · 0.80

Calls 15

_get_scalar_alphaMethod · 0.95
invertedMethod · 0.95
Affine2DClass · 0.90
IdentityTransformClass · 0.90
TransformedBboxClass · 0.90
_resampleFunction · 0.85
intersectionMethod · 0.80
from_extentsMethod · 0.80
translateMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
scaleMethod · 0.45

Tested by

no test coverage detected