
    h                       S r SSKrSSKrSSKrSSKJr  SSKrSSKrSSK	r
SSKr
SSKrSSKJrJr  SSKJr  SSK7  SSKJr  SSKJr  SSKJr  SSKJr  SSKJrJrJ r J!r!J"r"J#r#J$r$  \RJ                  " \&5      r'0 S	\RP                  _S
\RP                  _S\RP                  _S\RR                  _S\RT                  _S\RV                  _S\RX                  _S\RZ                  _S\R\                  _S\R^                  _S\R`                  _S\Rb                  _S\Rd                  _S\Rf                  _S\Rh                  _S\Rj                  _S\Rl                  _\Rn                  \Rp                  \RP                  S.Er9\:" \95      r;S3S jr< S4S jr=SSS.S jr>S  r? " S! S"\R                  5      rA " S# S$\A5      rB " S% S&\B5      rC " S' S(\B5      rD " S) S*\A5      rE " S+ S,\A5      rFS4S- jrG  S5SSS..S/ jjrHS0 rIS1 rJ  S6S2 jrKg)7zR
The image module supports basic image loading, rescaling and display
operations.
    N)Path)_apicbook)_image)*)FigureCanvasBase)Affine2DBboxBaseBboxBboxTransformBboxTransformToIdentityTransformTransformedBboxautononenearestbilinearbicubicspline16spline36hanninghamminghermitekaiserquadriccatromgaussianbesselmitchellsinc)lanczosblackmanantialiasedc           
         [        U 5      S:X  a&  [        R                  " S[        R                  S9SS4$ / n/ nU  H  nUR	                  X5      u  pgpUc  M  Xr-  nX-  nUR                  XgXR                  5       45        UR                  [        Xx/XvR                  S   -   XR                  S   -   //5      5        M     [        U5      S:X  a&  [        R                  " S[        R                  S9SS4$ [        R                  " U5      n
[        R                  " [        U
R                  5      [        U
R                  5      S4[        R                  S9nU H^  u  pgp[        5       R                  XzR                   -
  XR"                  -
  5      n	[$        R&                  " XkU	[$        R(                  SUS9  M`     XR                   U-  U
R"                  U-  4$ )a  
Composite a number of RGBA images into one.  The images are
composited in the order in which they appear in the *images* list.

Parameters
----------
images : list of Images
    Each must have a `make_image` method.  For each image,
    `can_composite` should return `True`, though this is not
    enforced by this function.  Each image must have a purely
    affine transformation with no shear.

renderer : `.RendererBase`

magnification : float, default: 1
    The additional magnification to apply for the renderer in use.

Returns
-------
image : (M, N, 4) `numpy.uint8` array
    The composited RGBA image.
offset_x, offset_y : float
    The (left, bottom) offset where the composited image should be placed
    in the output figure.
r   )r   r      dtype   r%   Fresamplealpha)lennpemptyuint8
make_imageappend_get_scalar_alphar   shapeunionzerosintheightwidthr	   	translatex0y0r   r*   NEAREST)imagesrenderermagnificationpartsbboxesimagedataxytransbboxoutputr+   s                B/var/www/html/env/lib/python3.13/site-packages/matplotlib/image.pycomposite_imagesrJ   <   s   4 6{axx	2Aq88EF!,,XEAALL$1&=&=&?@AMMqfq::a=0!jjm2CDEFH  5zQxx	2Aq88::fDXX	T[[	3tzz?A.bhh@F #
$$Q[!gg+>eV^^!&e	5 #
 77]*DGGm,CCC    c                    ^ ^^^	 [        S U 5       5      nUb  UOT R                  5       nU(       d  U(       d  U H  nUR                  T 5        M     g/ mT R                  5       m	UU	UU 4S jnU H  n[	        U[
        5      (       aR  UR                  5       (       a=  UR                  5       (       a(  UR                  5       (       d  TR                  U5        Mj  U" 5         UR                  T 5        M     U" 5         g)z
Draw a sorted list of artists, compositing images into a single
image where possible.

For internal Matplotlib use only: It is here to reduce duplication
between `Figure.draw` and `Axes.draw`, but otherwise should not be
generally useful.
c              3   B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstance
_ImageBase.0rD   s     rI   	<genexpr>0_draw_list_compositing_images.<locals>.<genexpr>~   s     @1Z:..s   Nc                    > [        T5      S:X  a  TS   R                  T5        O[        T5      S:  a  [        TTT5      u  pnU R                  S:w  a  TR	                  5       nUR                  TR                  5        UR                  TR                  5       5        TR                  U[        U5      [        U5      U 5        UR                  5         TS S 2	 g )Nr(   r   )r,   drawrJ   sizenew_gcset_clip_rectanglerG   set_clip_pathget_clip_path
draw_imageroundrestore)rC   lbgcimage_groupmagparentr>   s       rI   flush_images3_draw_list_compositing_images.<locals>.flush_images   s    ;1$A##H-[!A%-k8SI
99>!*B))&++6$$V%9%9%;<''E!HeAhEJJLArK   )
anyoption_image_nocompositerV   get_image_magnificationrO   rP   can_compositeget_clip_onr[   r1   )
r>   rd   artistssuppress_composite
has_imagesnot_compositeare   rb   rc   s
   ``      @@rI   _draw_list_compositing_imagesrq   t   s     @@@J ,>+I'";;=  JAFF8  ..0	 	 A1j))aoo.?.?MMOOAOO,=,=""1%x   	rK   r(   r)   c                   SnUR                   S   S:  a{  [        R                  " UR                  SS95        [	        [
        R                  " UR                   S   S-  5      5      nUSS2SSU24   n[        5       R                  US5      U-   nUR                   S   S:  a{  [        R                  " UR                  S	S95        [	        [
        R                  " UR                   S   S-  5      5      nUSSU2SS24   n[        5       R                  SU5      U-   nU R                  5       nUS
;   Ga*  [
        R                  " SS/UR                   S   UR                   S   //5      n	UR                  U	5      n
[
        R                  " [
        R                  " U
SS2S4   5      5      n[
        R                  " [
        R                  " U
SS2S4   5      5      nUSUR                   S   -  :  d(  XR                   S   :X  d  USUR                   S   -  :X  aA  USUR                   S   -  :  d(  XR                   S   :X  d  USUR                   S   -  :X  a  SnOSn[
        R                  " X!R                   SS -   UR                  5      nUc  U R!                  5       n["        R$                  " XU[&        U   UUU R)                  5       U R+                  5       5        U$ )z
Convenience wrapper around `._image.resample` to resample *data* to
*out_shape* (with a third dimension if *data* is RGBA) that takes care of
allocating the output array and fetching the relevant properties from the
Image object *image_obj*.
zData with more than {n} cannot be accurately displayed. Downsampling to less than {n} before displaying. To remove this warning, manually downsample your data.r(   i   z2**23 columns)nNr   i   z
2**24 rowsr#   r         r   r   )r3   warningswarnformatr6   r-   ceilr	   scaleget_interpolationarray	transformabsdiffr5   r'   get_resampler   r*   	_interpd_get_filternormget_filterrad)	image_objrC   	out_shaper~   r*   r+   msgstepinterpolationposdispdispxdispyouts                 rI   	_resampler      so   DC zz!}ucjj?j342774::a=5012AvvIJ$$T1-	9	zz!}ucjj<j012774::a=5012FdFAIJ$$Q-	9	 //1M// hhAA

1 >?@""3'rwwtAqDz*+rwwtAqDz*+QA&&A&TZZ]**QA&&A&TZZ]**%M%M
((9zz!"~-tzz
:C))+
OODym,,,.++-/ JrK   c                    [         R                  " U R                  S   U R                  S   S4U R                  S9nXSS2SS2SS24'   UR                  [         R                  :X  a  SUSS2SS2S4'   U$ SUSS2SS2S4'   U$ )	zP
Convert an RGB image to RGBA, as required by the image resample C++
extension.
r   r(   r%   r&   Nru            ?)r-   r5   r3   r'   r/   )Argbas     rI   _rgb_to_rgbar      s|    
 88QWWQZQ/qww?DArrNzzRXXQ1W K Q1WKrK   c                   .  ^  \ rS rSrSrSr        S#SS.U 4S jjjrS rU 4S jrS	 r	S
 r
S rS rU 4S jr  S$S jrS%S jrS r\R$                  S 5       rS rS r\S 5       rS rS rS rS rS rS rS rS rS r S r!S r"S  r#S! r$S"r%U =r&$ )&rP      a  
Base class for images.

interpolation and cmap default to their rc settings

cmap is a colors.Colormap instance
norm is a colors.Normalize instance to map luminance to 0-1

extent is data axes (left, right, bottom, top) for making image plots
registered with data plots.  Default is to label the pixel
centers with the zero-based row and column indices.

Additional kwargs are matplotlib.artist properties
r   N)interpolation_stagec
                  > [         TU ]  U R                  X#U5      5        Uc  [        R                  S   n[
        R                  " SS/US9  X`l        U R                  U5        U R                  U5        U R                  U5        U R                  U
5        U R                  U	5        Xl        S U l        U R                  U5        g )Nimage.originupperlowerorigin)super__init___get_colorizermplrcParamsr   check_in_listr   set_filternormset_filterradset_interpolationset_interpolation_stageset_resampleaxes_imcache_internal_update)selfaxcmapnorm	colorizerr   r   
filternorm	filterradr*   r   kwargs	__class__s               rI   r   _ImageBase.__init__   s     	,,TCD>\\.1FGW-f=J'9%}-$$%89(#	f%rK   c                      U R                  5       n[        U 5      R                   SU< S3$ ! [         a    [        U 5      R                  s $ f = f)Nz(shape=))	get_shapetype__name__RuntimeError)r   r3   s     rI   __str___ImageBase.__str__  sP    	'NN$E4j))*'%!<< 	':&&&	's   +. AAc                 ,   > 0 [         TU ]  5       ESS 0E$ )Nr   )r   __getstate__r   r   s    rI   r   _ImageBase.__getstate__  s    ;%'&(;*d;;rK   c                 (    U R                  5       SS $ )z9Return the size of the image as tuple (numrows, numcols).Nrv   )r   r   s    rI   get_size_ImageBase.get_size"  s    ~~##rK   c                 ^    U R                   c  [        S5      eU R                   R                  $ )zF
Return the shape of the image as tuple (numrows, numcols, channels).
"You must first set the image array)_Ar   r3   r   s    rI   r   _ImageBase.get_shape&  s'     77?CDDww}}rK   c                     [         R                  R                  X5        [        R                  " U5      S;  a  [        S5      eSU l        g)z
Set the alpha value used for blending - not supported on all backends.

Parameters
----------
alpha : float or 2D array-like or None
)r   rv   z5alpha must be a float, two-dimensional array, or NoneN)martistArtist_set_alpha_for_arrayr-   ndim	TypeErrorr   )r   r+   s     rI   	set_alpha_ImageBase.set_alpha/  s?     	++D8775>' - . .rK   c                     U R                   b$  [        R                  " U R                   5      S:  a  S$ U R                   $ )am  
Get a scalar alpha value to be applied to the artist as a whole.

If the alpha value is a matrix, the method returns 1.0 because pixels
have individual alpha values (see `~._ImageBase._make_image` for
details). If the alpha value is a scalar, the method returns said value
to be applied to the artist as a whole because pixels do not have
individual alpha values.
r   r   )_alphar-   r   r   s    rI   r2   _ImageBase._get_scalar_alpha=  s5     kk)RWWT[[-AA-Es 		rK   c                 0   > SU l         [        TU ]	  5         g)zE
Call this whenever the mappable is changed so observers can update.
N)r   r   changedr   s    rI   r   _ImageBase.changedJ  s     rK   c           
         Uc  [        S5      eUR                  S:X  a  [        S5      e[        R                  " X45      nUc  gUR                  U-  n	UR
                  U-  n
U	S:X  d  U
S:X  a  gU R                  S:X  a9  [        5       R                  SUR                  S   * 5      R                  SS5      nO
[        5       nU[        5       R                  UR                  UR                  S   -  UR
                  UR                  S   -  5      R                  UR                  UR                  5      U R                  5       -   -  nU[        5       R                  UR                  * UR                  * 5      R                  U5      -   nU(       d  UR                  (       aw  U(       ap  U	S	-  S
:w  d	  U
S	-  S
:w  a^  [         R"                  " U	5      n[         R"                  " U
5      nX-
  U	-  nX-
  U
-  nU[        5       R                  S	U-   S	U-   5      -  nO[%        U	5      n[%        U
5      nX4nU(       Gd  UR&                  S:X  d<  UR&                  S:X  a  UR                  S   S;   d  [)        SUR                   S35      eU R*                  nUS;   a  [,        R.                  " SS/UR                  S   UR                  S   //5      nUR1                  U5      n[,        R2                  " [,        R4                  " USS2S4   5      5      UR                  S   -  n[,        R2                  " [,        R4                  " USS2S4   5      5      UR                  S   -  nUS:  d  US:  a  SnOSnUR&                  S:X  Ga  US:X  Ga{  UR6                  R8                  S:X  a~  [,        R6                  " UR6                  R:                  S:  a  SOS5      nUR:                  UR6                  R:                  :  a'  [<        R>                  " SUR6                   SU S35        OIURA                  5       RC                  S5      URE                  5       RC                  S5      -
  nUS:  a  SOSn[G        XRC                  U5      UU5      n[I        U RJ                  [L        RN                  5      (       a  URC                  UR6                  5      nURP                  R                  UR                  :X  aX  [,        RR                  " URP                  [,        RT                  " [,        RV                  5      [,        RT                  " S5      5      O$[,        RX                  " U[,        RT                  5      n[G        U UUUSS9nA[,        RZ                  " U5      nSUU'   U R]                  5       nUb*  [,        R&                  " U5      S:  a  U[G        U UUUSS9-  n[,        R^                  Ra                  UU5      nU RK                  U5      nGOjUR&                  S:X  a,  U RJ                  Rc                  U5        U Re                  U5      nU R]                  5       nUce  UR                  S   S:X  a#  UR6                  [,        Rf                  :X  a  SOS	n O[G        XS   UU5      n [G        U [i        USSS24   5      UU5      nO[,        R&                  " U5      S:  a-  [G        U UUU5      n [G        U [i        USSS24   5      UU5      nOjUR                  S   S:X  a&  UR6                  [,        Rf                  :X  a  SU-  OUn O[G        XS   UU5      U-  n [G        U [i        USSS24   5      UU5      nU US'   U Re                  USS S!9nUR&                  S:X  aD  U Rk                  5       nUSS2SS2S4   n!U!RC                  [,        RT                  5      W-  U-  U!SS& GOYU Rl                  c#  U Re                  USUR&                  S:H  S!9U l6        U Rl                  n[o        XKRq                  5       5      Rs                  5       n"U[%        [A        U"Rt                  S5      5      [%        [E        U"Rv                  S-   UR                  S   5      5      2[%        [A        U"Rx                  S5      5      [%        [E        U"Rz                  S-   UR                  S   5      5      24   n[        5       R                  [%        [A        U"Rx                  S5      5      [%        [A        U"Rt                  S5      5      5      U-   nUUR                  UR                  U4$ )"a  
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
----------
A : ndarray

    - a (M, N) array interpreted as scalar (greyscale) image,
      with one of the dtypes `~numpy.float32`, `~numpy.float64`,
      `~numpy.float128`, `~numpy.uint16` or `~numpy.uint8`.
    - (M, N, 4) RGBA image with a dtype of `~numpy.float32`,
      `~numpy.float64`, `~numpy.float128`, or `~numpy.uint8`.

in_bbox : `~matplotlib.transforms.Bbox`

out_bbox : `~matplotlib.transforms.Bbox`

clip_bbox : `~matplotlib.transforms.Bbox`

magnification : float, default: 1

unsampled : bool, default: False
    If True, the image will not be scaled, but an appropriate
    affine transformation will be returned instead.

round_to_pixel_border : bool, default: True
    If True, the output image size will be rounded to the nearest pixel
    boundary.  This makes the images align correctly with the Axes.
    It should not be used if exact scaling is needed, such as for
    `.FigureImage`.

Returns
-------
image : (M, N, 4) `numpy.uint8` array
    The RGBA image, resampled unless *unsampled* is True.
x, y : float
    The upper left corner where the image should be drawn, in pixel
    space.
trans : `~matplotlib.transforms.Affine2D`
    The affine transformation from image to pixel space.
Nz9You must first set the image array or the image attributer   zk_make_image must get a non-empty image. Your Artist's draw method must filter before this method is called.)Nr   r   Nr   r(   r           rv   ru   ru   r%   Invalid shape  for image datart   r   rC   fr%   f8f4zCasting input data from z to z for imshow.g    חAT)r*   r   ).ru   .Fbytesr   )>r   rW   r   intersectionr8   r7   r   r	   r9   r3   r{   r   r:   r;   get_transform	is_affinemathrz   r6   r   
ValueError_interpolation_stager-   r}   r~   r   r   r'   kinditemsizer   warn_externalmaxastypeminr   rO   r   mcolorsNoNormmaskwherefloat32nan	ones_likeisnan	get_alphamamasked_arrayautoscale_Noneto_rgbar/   r   r2   r   r   invertedfrozenyminymaxxminxmax)#r   r   in_bboxout_bbox	clip_bboxr?   	unsampledround_to_pixel_borderclipped_bboxout_width_baseout_height_baset0t	out_width
out_heightextra_widthextra_heightr   r   r   r   r   r   scaled_dtypedaA_resampledr   	out_alphaout_maskr+   resampled_maskedrH   output_alphaalpha_channelsubsets#                                      rI   _make_image_ImageBase._make_imageQ  s   \ 9  > ? ?66Q;  8 9 9 ((=#%++m;&--=Q/Q"6#;;'! %%a!''!*5;;ArBB"$B
JU
*+- Ywzz7::.  "#	$ 
LOO+loo-=>}%' 0E#%,#0E0L		.1I?3J$5GK&8OKL!!#"3S<5GHHAN+I_-J+	FFaK166Q;1772;&3H >!''/!JKK #'";";"&==hhAQWWQZ(@AB{{3'rwwtAqDz23aggaj@rwwtAqDz23aggaj@AI519*0'*0'vv{2f< 77<<3&#%88AGG4D4Dq4HDd#SL#,,qww/?/??**-EaggY-1,|,M N -t0DDB+-84L (hh|.DiQRS dii88"-"4"4QWW"=K 66<<1772 BFF);RZZ]K\\!RZZ8 
 &dD)QN	88I.&'	(#($!);4	1t!TTI#%55#5#5k8#L #3466Q;II,,Q/QA(=wwqzQ./gg.Ass'0 F)Y(;&l1S"1"W:6	1FFWWU^a'#,T5)Q#GL&l1S"1"W:6	1FF wwqzQ892888KeQV'0y)Q'ORW'W&l1S"1"W:6	1FF!-v \\&5\AF vv{..0 &q!Qw!((4y@5H a  }}$ $Qd!&&A+ O]]F %Y>EEGFCQ'(Caa9:;CQ'(Caa9:;;<F 
$$CQ'(#c&++q.A*BDFGHA |::rK   c                     [        S5      e)a  
Normalize, rescale, and colormap this image's data for rendering using
*renderer*, with the given *magnification*.

If *unsampled* is True, the image will not be scaled, but an
appropriate affine transformation will be returned instead.

Returns
-------
image : (M, N, 4) `numpy.uint8` array
    The RGBA image, resampled unless *unsampled* is True.
x, y : float
    The upper left corner where the image should be drawn, in pixel
    space.
trans : `~matplotlib.transforms.Affine2D`
    The affine transformation from image to pixel space.
z(The make_image method must be overriddenNotImplementedError)r   r>   r?   r  s       rI   r0   _ImageBase.make_image-  s    $ ""LMMrK   c                     g)zd
Return whether the image is better to be drawn unsampled.

The derived class needs to override it.
F r   s    rI   _check_unsampled_image!_ImageBase._check_unsampled_imageA  s     rK   c                 v   U R                  5       (       d  SU l        g U R                  5       R                  S:X  a  SU l        g UR	                  5       nU R                  U5        UR                  U R                  5       5        UR                  U R                  5       5        UR                  U R                  5       5        UR                  5       (       a  U R                  5       (       a  U R                  5       R                  (       aa  U R!                  USS9u  p4pVUbJ  [#        5       R%                  UR&                  S   UR&                  S   5      U-   nUR)                  X$XSU5        O7U R!                  XR+                  5       5      u  p4pVUb  UR)                  X$XS5        UR-                  5         SU l        g )NFr   Tr  r(   )get_visiblestale	get_arrayrW   rX   _set_gc_clipr   r2   set_urlget_urlset_gidget_gidoption_scale_imager"  r   r   r0   r	   r{   r3   r\   ri   r^   )r   r>   ra   imr_   r`   rF   s          rI   rV   _ImageBase.drawI  sY    !!DJ>>  A%DJ__"
T++-.


4<<>"


4<<>"''))//11&&(22"ooh$oGOB1~ 
((!bhhqkBUJ##B1%8"oo::<>OB1~##B11



rK   c                    U R                  U5      (       d#  U R                  R                  U5      S   (       d  S0 4$ U R                  5       R	                  5       nUR                  UR                  UR                  /5      u  p4U R                  5       u  pVpxUSL=(       a*    X5-
  X6-
  -  S:*  =(       a    USL=(       a    XG-
  XH-
  -  S:*  n	U	0 4$ )7Test whether the mouse event occurred within the image.r   FN)	_different_canvasr   containsr   r   r~   rD   rE   
get_extent)
r   
mouseeventrF   rD   rE   r  r  r   r   insides
             rI   r4  _ImageBase.containsh  s    "":..yy))*5a8"9
 ""$--/
jll;<!%!2D4- EQX!($;q$@ EtmE)*ah(?1(D 	rzrK   c                     U R                  U R                  S:X  a  U R                  SSS2   OU R                  SSS9n[        R                  R                  U5      R                  USS9  g)z$Write the image to png file *fname*.r   Nr   Tr   png)ry   )r   r   r   PILImage	fromarraysave)r   fnamer/  s      rI   	write_png_ImageBase.write_pngz  s[    \\4;;'+A$''$B$-tww $4  1		B$$U5$9rK   c                 L   [         R                  " U SS9n U R                  [        R                  :w  aD  [        R
                  " U R                  [        S5      (       d  [        SU R                   S35      eU R                  S:X  a$  U R                  S   S:X  a  U R                  S5      n U R                  S	:X  d<  U R                  S:X  a  U R                  S   S
;   d  [        SU R                   S35      eU R                  S:X  Ga  [        R                  " U R                  [        R                  5      (       a  SOSnU R                  5       S:  d  XR                  5       :  aK  [        R!                  SU R                  5       U R                  5       5        [        R"                  " U SU5      n U R                  [        R                  :w  aS  [        R                  " U R                  [        R                  5      (       a  U R%                  [        R                  5      n U $ )zd
Check validity of image-like input *A* and normalize it to a format suitable for
Image subclasses.
T)copy	same_kindzImage data of dtype z cannot be converted to floatru   r   r(   rv   r   r   r   r   r   zClipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [%s..%s].)r   safe_masked_invalidr'   r-   r/   can_castfloatr   r   r3   squeeze
issubdtypeintegerr   r   _logwarningclipr   )r   highs     rI   _normalize_image_array!_ImageBase._normalize_image_array  s{    %%ad377bhhr{{177E;'O'O2177) <1 2 3 366Q;1772;!+		"A!qvv{qwwr{f/DnQWWI_EFF66Q;
 --<<3!Duuw{dUUWn* EEGQUUW	 GGAq$'ww"(("r}}QWWbjj'I'IHHRXX&rK   c                     [        U[        R                  R                  5      (       a  [        U5      nU R	                  U5      U l        SU l        SU l        g)z
Set the image array.

Note that this function does *not* update the normalization used.

Parameters
----------
A : array-like or `PIL.Image.Image`
NT)rO   r;  r<  pil_to_arrayrO  r   r   r'  r   r   s     rI   set_data_ImageBase.set_data  sB     a))QA--a0
rK   c                 &    U R                  U5        g)zd
Retained for backwards compatibility - use set_data instead.

Parameters
----------
A : array-like
N)rT  rS  s     rI   	set_array_ImageBase.set_array  s     	arK   c                     U R                   $ )a  
Return the interpolation method the image uses when resizing.

One of 'auto', 'antialiased', 'nearest', 'bilinear', 'bicubic',
'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser',
'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos',
or 'none'.
)_interpolationr   s    rI   r|   _ImageBase.get_interpolation  s     """rK   c                     [         R                  " US5      R                  5       n[        R                  " [
        US9  Xl        SU l        g)a  
Set the interpolation method the image uses when resizing.

If None, use :rc:`image.interpolation`. If 'none', the image is
shown as is without interpolating. 'none' is only supported in
agg, ps and pdf backends and will fall back to 'nearest' mode
for other backends.

Parameters
----------
s : {'auto', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
zimage.interpolationr   TN)r   
_val_or_rcr   r   r   interpolations_namesrZ  r'  r   ss     rI   r   _ImageBase.set_interpolation  s<     NN134::</qA
rK   c                     U R                   $ )za
Return when interpolation happens during the transform to RGBA.

One of 'data', 'rgba', 'auto'.
)r   r   s    rI   get_interpolation_stage"_ImageBase.get_interpolation_stage  s     (((rK   c                 z    [         R                  " US5      n[        R                  " / SQUS9  Xl        SU l        g)aa  
Set when interpolation happens during the transform to RGBA.

Parameters
----------
s : {'data', 'rgba', 'auto'} or None
    Whether to apply up/downsampling interpolation in data or RGBA
    space.  If None, use :rc:`image.interpolation_stage`.
    If 'auto' we will check upsampling rate and if less
    than 3 then use 'rgba', otherwise use 'data'.
zimage.interpolation_stage)rC   r   r   )ra  TN)r   r^  r   r   r   r'  r`  s     rI   r   "_ImageBase.set_interpolation_stage  s3     NN19:3q9$%!
rK   c                     U R                  5       nU R                  S:g  =(       a    UR                  =(       a    UR                  $ )z>Return whether the image can be composited with its neighbors.r   )r   rZ  r   is_separable)r   rF   s     rI   rj   _ImageBase.can_composite  s=    ""$6) OO	 rK   c                 L    [         R                  " US5      nXl        SU l        g)zv
Set whether image resampling is used.

Parameters
----------
v : bool or None
    If None, use :rc:`image.resample`.
zimage.resampleTN)r   r^  r   r'  )r   vs     rI   r   _ImageBase.set_resample  s!     NN1./
rK   c                     U R                   $ )z(Return whether image resampling is used.)r   r   s    rI   r   _ImageBase.get_resample
  s    ~~rK   c                 2    [        U5      U l        SU l        g)z
Set whether the resize filter normalizes the weights.

See help for `~.Axes.imshow`.

Parameters
----------
filternorm : bool
TN)bool_filternormr'  r   r   s     rI   r   _ImageBase.set_filternorm  s      
+
rK   c                     U R                   $ )z8Return whether the resize filter normalizes the weights.)rr  r   s    rI   r   _ImageBase.get_filternorm  s    rK   c                 V    [        U5      nUS::  a  [        S5      eX l        SU l        g)z
Set the resize filter radius only applicable to some
interpolation schemes -- see help for imshow

Parameters
----------
filterrad : positive float
r   z+The filter radius must be a positive numberTN)rG  r   
_filterradr'  )r   r   rs      rI   r   _ImageBase.set_filterrad  s-     )6JKK
rK   c                     U R                   $ )zReturn the filterrad setting.)rx  r   s    rI   r   _ImageBase.get_filterrad.  s    rK   )
r   rr  rx  r   rZ  r   r   r   r   r'  )NNNNNT      @F)r   FTr   F)'r   
__module____qualname____firstlineno____doc__zorderr   r   r   r   r   r   r2   r   r  r0   r"  r   allow_rasterizationrV   r4  r@  staticmethodrO  rT  rW  r|   r   rd  r   rj   r   r   r   r   r   r   __static_attributes____classcell__r   s   @rI   rP   rP      s     F # & &*& &:'<$ JM;?Z;xN(    !<$:  @ 
	#()"   rK   rP   c                   r   ^  \ rS rSrSrSSSSSSSSSSS.
U 4S jjrSS	 jrSS
 jrS rS r	S r
S rSrU =r$ )	AxesImagei3  a  
An image attached to an Axes.

Parameters
----------
ax : `~matplotlib.axes.Axes`
    The Axes the image will belong to.
cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    The Colormap instance or registered colormap name used to map scalar
    data to colors.
norm : str or `~matplotlib.colors.Normalize`
    Maps luminance to 0-1.
interpolation : str, default: :rc:`image.interpolation`
    Supported values are 'none', 'auto', 'nearest', 'bilinear',
    'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite',
    'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell',
    'sinc', 'lanczos', 'blackman'.
interpolation_stage : {'data', 'rgba'}, default: 'data'
    If 'data', interpolation
    is carried out on the data provided by the user.  If 'rgba', the
    interpolation is carried out after the colormapping has been
    applied (visual interpolation).
origin : {'upper', 'lower'}, default: :rc:`image.origin`
    Place the [0, 0] index of the array in the upper left or lower left
    corner of the Axes. The convention 'upper' is typically used for
    matrices and images.
extent : tuple, optional
    The data axes (left, right, bottom, top) for making image plots
    registered with data plots.  Default is to label the pixel
    centers with the zero-based row and column indices.
filternorm : bool, default: True
    A parameter for the antigrain image resize filter
    (see the antigrain documentation).
    If filternorm is set, the filter normalizes integer values and corrects
    the rounding errors. It doesn't do anything with the source floating
    point values, it corrects only integers according to the rule of 1.0
    which means that any sum of pixel weights must be equal to 1.0. So,
    the filter function must produce a graph of the proper shape.
filterrad : float > 0, default: 4
    The filter radius for filters that have a radius parameter, i.e. when
    interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
resample : bool, default: False
    When True, use a full resampling method. When False, only resample when
    the output image is larger than the input image.
**kwargs : `~matplotlib.artist.Artist` properties
NTr}  F)
r   r   r   r   r   extentr   r   r*   r   c       
         H   > Xpl         [        TU ]  " U4UUUUUUU	U
US.	UD6  g )N)	r   r   r   r   r   r   r   r*   r   )_extentr   r   )r   r   r   r   r   r   r   r  r   r   r*   r   r   r   s                rI   r   AxesImage.__init__c  sD     	
'! 3	
 	
rK   c                     U R                   u  p#pE[        R                  " X$X5/5      nUR                  U R	                  5       5      $ rN   )r  r   from_extentstransformedr   )r   r>   r:   x1r;   y1rG   s          rI   get_window_extentAxesImage.get_window_extent  s>      ""!12 2 2 455rK   c           	         U R                  5       nU R                  5       u  pVpx[        [        R                  " XW/Xh//5      5      n	[        X5      n
U R                  5       (       a-  U R                  5       =(       d    U R                  R                  OU R                  SS9R                  nU R                  U R                  XUX#S9$ )NTrootr%  )r   r5  r   r-   r}   r   rk   get_clip_boxr   rG   
get_figurer  r   )r   r>   r?   r  rF   r  x2r  y2rG   transformed_bboxrM  s               rI   r0   AxesImage.make_image  s    ""$*BHHrh123*47;?;K;K;M;M""$6		__$_/44 	 -   D 	DrK   c                 (    U R                  5       S:H  $ )z9Return whether the image would be better drawn unsampled.r   )r|   r   s    rI   r"   AxesImage._check_unsampled_image  s    %%'611rK   c                    U R                   R                  SUS   US   /4SUS   US   /4/U5      u  u  p4u  pVU(       a  [        R                  " SU5      eU R                   R	                  X0R
                  5      nU R                   R	                  X@R
                  5      nU R                   R	                  XPR                  5      nU R                   R	                  X`R                  5      nX4XV/nXl        X54XF44nU R                   R                  U5        X4/U R                  R                  SS& XV/U R                  R                  SS& U R                   R                  5       (       a  U R                   R                  X44SS	9  U R                   R                  5       (       a  U R                   R                  XV4SS	9  S
U l        g)a  
Set the image extent.

Parameters
----------
extent : 4-tuple of float
    The position and size of the image as tuple
    ``(left, right, bottom, top)`` in data coordinates.
**kwargs
    Other parameters from which unit info (i.e., the *xunits*,
    *yunits*, *zunits* (for 3D Axes), *runits* and *thetaunits* (for
    polar Axes) entries are applied, if present.

Notes
-----
This updates `.Axes.dataLim`, and, if autoscaling, sets `.Axes.viewLim`
to tightly fit the image, regardless of `~.Axes.dataLim`.  Autoscaling
state is not changed, so a subsequent call to `.Axes.autoscale_view`
will redo the autoscaling in accord with `~.Axes.dataLim`.
rD   r   r(   rE   rv   ru   
set_extentN)r   T)r   _process_unit_infor   kwarg_error_validate_converted_limitsconvert_xunitsconvert_yunitsr  update_datalimsticky_edgesrD   rE   get_autoscalex_onset_xlimget_autoscaley_onset_ylimr'  )r   r  r   r  r  r   r   cornerss           rI   r  AxesImage.set_extent  s   * &*YY%A%AF1Ivay)*F1Ivay)*,&"lt ""<88yy33%%'yy33%%'yy33%%'yy33%%'d),,		  )"&A"&A99&&((II|$799&&((II|$7
rK   c                     U R                   b  U R                   $ U R                  5       nUu  p#U R                  S:X  a  SUS-
  US-
  S4$ SUS-
  SUS-
  4$ )<Return the image extent as tuple (left, right, bottom, top).r               ?)r  r   r   )r   sznumrowsnumcolss       rI   r5  AxesImage.get_extent  sc    <<#<<B!G{{g%gck73;==gck4==rK   c                 |   U R                  5       u  p#pEU R                  S:X  a  XTpTU R                  5       n[        X$/X5//5      n[        SS/UR                  S   UR                  S   //5      nU R                  5       R                  5       n	U	[        XxS9-  n	U	R                  UR                  UR                  /5      n
[        [        R                  " U
5      5      (       a  gU
R                  [        5      u  pSUs=::  a  UR                  S   :  a   O  gSUs=::  a  UR                  S   :  d   g  gXlU4   $ )z
Return the image value at the event position or *None* if the event is
outside the image.

See Also
--------
matplotlib.artist.Artist.get_cursor_data
r   r   r(   )boxinboxoutN)r5  r   r(  r   r3   r   r   r   r~   rD   rE   rg   r-   r   r   r6   )r   eventr  r  r   r   arrdata_extentarray_extentrF   pointjis                rI   get_cursor_dataAxesImage.get_cursor_data  s    "&!2D;;'!$nnTL4,78aVciilCIIaL%ABC""$--/[FF%'' 23rxx||C Q%1% 01A/D		!/D 0E!t9rK   )r  r'  rN   r~  )r   r  r  r  r  r   r  r0   r"  r  r5  r  r  r  r  s   @rI   r  r  3  sX    -b # %)
 
>6

D2.`
> rK   r  c                      ^  \ rS rSrSS.U 4S jjrS rSS jrS rS rU 4S	 jr	S
 r
S rS rU 4S jrU 4S jrS rSrU =r$ )NonUniformImagei  r   r]  c                J   > [         TU ]  " U40 UD6  U R                  U5        g)a  
Parameters
----------
ax : `~matplotlib.axes.Axes`
    The Axes the image will belong to.
interpolation : {'nearest', 'bilinear'}, default: 'nearest'
    The interpolation scheme used in the resampling.
**kwargs
    All other keyword arguments are identical to those of `.AxesImage`.
N)r   r   r   )r   r   r   r   r   s       rI   r   NonUniformImage.__init__  s%     	&v&}-rK   c                     g)z)Return False. Do not use unsampled image.Fr!  r   s    rI   r"  &NonUniformImage._check_unsampled_image  s    rK   c                    U R                   c  [        S5      eU(       a  [        S5      eU R                   nUR                  S:X  al  UR                  [
        R                  :w  a  U R                  USS9nO[
        R                  " US S 2S S 2[
        R                  4   SS5      nSUS S 2S S 2S4'   OUR                  [
        R                  :w  a"  SU-  R                  [
        R                  5      nUR                  S   S:X  aZ  [
        R                  " [        / UR                  S	S QSP5      [
        R                  5      nXES S 2S S 2S	S24'   SUS S 2S S 2S4'   UnU R                  R                  R                   u  pgp[#        [%        U5      S
-   [%        U5      S
-
  -
  U-  5      n
[#        [%        U	5      S
-   [%        U5      S
-
  -
  U-  5      nU R                  R&                  R)                  5       nUR+                  [
        R,                  " XhU
5       Vs/ s H  oU4PM     sn5      S S 2S	4   nUR+                  [
        R,                  " XyU5       Vs/ s H  oU4PM     sn5      S S 2S4   nU R.                  S:X  Ga  U R0                  S S U R0                  SS  -   S-  nU R2                  S S U R2                  SS  -   S-  nUR5                  U5      nUR5                  U5      n[
        R6                  " U5      R9                  [
        R:                  5      R=                  5       [
        R>                  RA                  UUR                  S   -  U5         R9                  [
        R                  5      RC                  XS45      nGO[
        RD                  " U R0                  R5                  U5      S-
  S	[G        U R0                  5      S-
  5      n[
        RD                  " U R2                  R5                  U5      S-
  S	[G        U R2                  5      S-
  5      n[
        R>                  RA                  UUR                  S   -  U5      n[
        RD                  " [
        RH                  " XR0                  U   -
  [
        RJ                  " U R0                  5      U   [
        RL                  S9S	S5      n[
        RD                  " [
        RH                  " UU R2                  U   -
  [
        RJ                  " U R2                  5      U   [
        RL                  S9S	S5      n[
        R@                  " SU-
  SU-
  5      n[
        R@                  " USU-
  5      n[
        R@                  " SU-
  U5      n[
        R@                  " UU5      n[
        RN                  " XS4[
        R                  5      n[Q        S5       Hy  nUS S 2S S 2U4   RC                  S5      nUUU   -  nUUUUR                  S   S  U   -  -  nUUUSS  U   -  -  nUUUUR                  S   S-   S  U   -  -  nUUS S 2S S 2U4'   M{     UXg[S        5       4$ s  snf s  snf )Nr   z*unsampled not supported on NonUniformImagerv   Tr   r%   r   ru   r   r  r(   r   r   r&   )*r   r   r   r   r'   r-   r/   r   repeatnewaxisr   r3   r5   tupler   rG   extentsr6   r]   	transDatar   r~   linspacerZ  _Ax_Aysearchsortedascontiguousarrayviewuint32raveladdouterreshaperM  r,   divider   r   r.   ranger   ) r   r>   r?   r  r   Br_   r`   ry  r  r8   r7   invertedTransformrD   x_pixrE   y_pixx_midy_midx_inty_intr/  idx_intx_fracy_fracf00f10f01f11chanacbufs                                    rI   r0   NonUniformImage.make_image  s<   77?CDDIJJGG66Q;ww"(("LL$L/IIa1bjj 011a8 !Q'
ww"(("UNN288,wwqzQHHU#5QWWQq\#51#56A !Q!) !Q'
YY^^++
aeAhnqC8MIJuQx#~%(S.9]JK II//88:!++[[u565V568891>!++[[v676V6799:A? )+XXcr]TXXab\1Q6EXXcr]TXXab\1Q6E&&u-E&&u-E
 $$Q',,RYY7==?FFLL!3U;=bhh(: ;  GG%%e,q0!S]Q5FHEGG%%e,q0!S]Q5FHEffll51771:#5u=GWW		%((5/12774883DU3K "

,1F WW		%$((5/12774883DU3K "

,1F ((1v:q6z2C((61v:.C((1v:v.C((66*C6!,bhh7Baq!Tz]**2. BwK'sR
_W555sRVG_,,sR
Q0999!$1a: ! 1*,,,[ 77s   YYc                    U R                  U5      n[        R                  " U[        R                  5      n[        R                  " U[        R                  5      nUR                  UR                  s=:X  a  S:X  a-  O  O*UR
                  SS UR
                  UR
                  -   :X  d  [        S5      eX0l        Xl        X l	        SU l
        SU l        g)aN  
Set the grid for the pixel centers, and the pixel values.

Parameters
----------
x, y : 1D array-like
    Monotonic arrays of shapes (N,) and (M,), respectively, specifying
    pixel centers.
A : array-like
    (M, N) `~numpy.ndarray` or masked array of values to be
    colormapped, or (M, N, 3) RGB array, or (M, N, 4) RGBA array.
r(   Nrv   zAxes don't match array shapeT)rO  r-   r}   r   r   r3   r   r   r  r  r   r'  r   rD   rE   r   s       rI   rT  NonUniformImage.set_dataM  s     ''*HHQ

#HHQ

#!&&%A%!''"1+1779J*J:;;
rK   c                     [        S5      eNzMethod not supportedr  r   argss     rI   rW  NonUniformImage.set_arraye      !"899rK   c                 L   > Ub  US;  a  [        S5      e[        TU ]	  U5        g)zg
Parameters
----------
s : {'nearest', 'bilinear'} or None
    If None, use :rc:`image.interpolation`.
N)r   r   z?Only nearest neighbor and bilinear interpolations are supported)r  r   r   )r   ra  r   s     rI   r   !NonUniformImage.set_interpolationh  s4     =Q&==% 'N O O!!$rK   c                     U R                   c  [        S5      eU R                  S   U R                  S   U R                  S   U R                  S   4$ )NzMust set data firstr   r   )r   r   r  r  r   s    rI   r5  NonUniformImage.get_extentt  sF    77?455xx{DHHRL$((1+txx|CCrK   c                     g rN   r!  rs  s     rI   r   NonUniformImage.set_filternormy      rK   c                     g rN   r!  )r   r   s     rI   r   NonUniformImage.set_filterrad|  r   rK   c                 T   > U R                   b  [        S5      e[        TU ]  U5        g Nz'Cannot change colors after loading data)r   r   r   set_norm)r   r   r   s     rI   r  NonUniformImage.set_norm  &    77HIIrK   c                 T   > U R                   b  [        S5      e[        TU ]  U5        g r  )r   r   r   set_cmap)r   r   r   s     rI   r	  NonUniformImage.set_cmap  r  rK   c                 r   UR                   UR                  p2X R                  S   :  d6  X R                  S   :  d$  X0R                  S   :  d  X0R                  S   :  a  g [        R
                  " U R                  U5      S-
  n[        R
                  " U R                  U5      S-
  nU R                  XT4   $ Nr   r   r(   xdataydatar  r  r-   r  r   r   r  rD   rE   r  r  s         rI   r  NonUniformImage.get_cursor_data      {{EKK1Oq88B</HHQK1xx|#3OODHHa(1,OODHHa(1,wwqt}rK   r   r  r  r   r'  r~  )r   r  r  r  r   r"  r0   rT  rW  r   r5  r   r   r  r	  r  r  r  r  s   @rI   r  r    sO    ,5 . .H-T0:
%D


 rK   r  c                   d   ^  \ rS rSrSr   SSSSS.U 4S jjjrSS jrS rS rS	 r	S
 r
SrU =r$ )PcolorImagei  z
Make a pcolor-style plot with an irregular rectangular grid.

This uses a variation of the original irregular image code,
and it is used by pcolorfast for the corresponding grid type.
N)r   r   r   c                p   > [         T	U ]  XXWS9  U R                  U5        Ub  U R                  X#U5        gg)a,  
Parameters
----------
ax : `~matplotlib.axes.Axes`
    The Axes the image will belong to.
x, y : 1D array-like, optional
    Monotonic arrays of length N+1 and M+1, respectively, specifying
    rectangle boundaries.  If not given, will default to
    ``range(N + 1)`` and ``range(M + 1)``, respectively.
A : array-like
    The data to be color-coded. The interpretation depends on the
    shape:

    - (M, N) `~numpy.ndarray` or masked array: values to be colormapped
    - (M, N, 3): RGB array
    - (M, N, 4): RGBA array

cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    The Colormap instance or registered colormap name used to map
    scalar data to colors.
norm : str or `~matplotlib.colors.Normalize`
    Maps luminance to 0-1.
**kwargs : `~matplotlib.artist.Artist` properties
)r   r   r   N)r   r   r   rT  )
r   r   rD   rE   r   r   r   r   r   r   s
            rI   r   PcolorImage.__init__  s>    D 	TGf%=MM!" rK   c                    U R                   c  [        S5      eU(       a  [        S5      eU R                  c9  U R	                  U R                   SS9n[
        R                  " U/ SQS5      U l        U R                  n[        R                  " U R                  R                  R                  5       S5      n[
        R                  " U5      S-  R                  [
        R                  5      nUS	   U:g  R                  5       (       a  U=USS
/S S 24'   US S 2SS
/4'   U R                  R                  R                   u  pxp[#        U	5      S-   [#        U5      S-
  -
  n[#        U
5      S-   [#        U5      S-
  -
  n[#        X-  5      n[#        X-  5      nU R                  R$                  n[
        R&                  " UR(                  UR*                  U5      n[
        R&                  " UR,                  UR.                  U5      nU R0                  R3                  U5      nU R4                  R3                  U5      nUR7                  [
        R8                  5      R;                  5       [
        R<                  R?                  UUR@                  S   -  U5         R7                  [
        R                  5      RC                  XS45      nUXx[E        5       4$ )Nr   z&unsampled not supported on PColorImageTr  )r(   r(   r  r   r   constantr   r   r  r   r  r(   r%   )#r   r   r   r   r   r-   padr   r   patchget_facecolorr}   r   r/   allrG   r  r]   viewLimr  r:   r  r;   r  r  r  r  r  r  r  r  r  r3   r  r   )r   r>   r?   r  r   padded_Abgr_   r`   ry  r  r8   r7   vlr  r  r  r  r/  s                      rI   r0   PcolorImage.make_image  s$   77?CDDEFF== TWWD1AFF1&>
KDM==__TYY__::<a@hhrlS ((2TNb %%'':<<HaWaZ 8A2wJ#7YY^^++
aqCE!HsN3(S.U1X^4e+,v-.YYBEE255%0BEE255&1%%e,%%e,MM"))$**,UX^^A%66>@T"((^GGVA$67 	 1*,,,rK   c                     g)NFr!  r   s    rI   r"  "PcolorImage._check_unsampled_image  s    rK   c                    U R                  U5      nUc'  [        R                  " SUR                  S   S-   5      O([        R                  " U[
        5      R                  5       nUc'  [        R                  " SUR                  S   S-   5      O([        R                  " U[
        5      R                  5       nUR                  SS UR                  S-
  UR                  S-
  4:w  a=  [        SUR                  SS < SUR                  S-
  UR                  S-
  4< S35      eUS	   US   :  a  USSS	2   nUSS2SSS	24   nUS	   US   :  a  USSS	2   nUSSS	2   nX0l	        Xl
        X l        SU l        S
U l        g)a
  
Set the grid for the rectangle boundaries, and the data values.

Parameters
----------
x, y : 1D array-like, optional
    Monotonic arrays of length N+1 and M+1, respectively, specifying
    rectangle boundaries.  If not given, will default to
    ``range(N + 1)`` and ``range(M + 1)``, respectively.
A : array-like
    The data to be color-coded. The interpretation depends on the
    shape:

    - (M, N) `~numpy.ndarray` or masked array: values to be colormapped
    - (M, N, 3): RGB array
    - (M, N, 4): RGBA array
Nr   r(   r   rv   z"Axes don't match array shape. Got z, expected .r   T)rO  r-   aranger3   r}   rG  r  rW   r   r   r  r  r   r'  r  s       rI   rT  PcolorImage.set_data  sR   $ ''*-.YBIIb!''!*q.)BHHQ<N<T<T<V-.YBIIb!''!*q.)BHHQ<N<T<T<V772A;166A:qvvz22!qvvz166A:689 9 R51Q4<$B$A!TrT'
AR51Q4<$B$A$B$A
rK   c                     [        S5      er  r  r  s     rI   rW  PcolorImage.set_array  r  rK   c                 r   UR                   UR                  p2X R                  S   :  d6  X R                  S   :  d$  X0R                  S   :  d  X0R                  S   :  a  g [        R
                  " U R                  U5      S-
  n[        R
                  " U R                  U5      S-
  nU R                  XT4   $ r  r  r  s         rI   r  PcolorImage.get_cursor_data  r  rK   r  )NNNr~  )r   r  r  r  r  r   r0   r"  rT  rW  r  r  r  r  s   @rI   r  r    sN     %#
 %# %#N-B$L: rK   r  c                   b   ^  \ rS rSrSrSrSrSSSSSSS.U 4S jjrS rSS	 jr	U 4S
 jr
SrU =r$ )FigureImagei  zAn image attached to a figure.r   r   N)r   r   r   offsetxoffsetyr   c                   > [         T	U ]  SUUUUS9  U R                  U5        XPl        X`l        U R                  U5        SU l        g)
cmap is a colors.Colormap instance
norm is a colors.Normalize instance to map luminance to 0-1

kwargs are an optional list of Artist keyword args
N)r   r   r   r   r   )r   r   
set_figureoxoyr   r?   )
r   figr   r   r   r1  r2  r   r   r   s
            rI   r   FigureImage.__init__"  sT      	 	 	
 	f% rK   c                     U R                  5       u  pSU R                  -   US-
  U R                  -   SU R                  -   US-
  U R                  -   4$ )r  r  r  )r   r6  r7  )r   r  r  s      rI   r5  FigureImage.get_extent?  sN    ==?twwdgg 5twwdgg 57 	7rK   c           
          U R                  SS9nUR                  UR                  -  n[        U R                  U-  U R                  U-  /U R                  U-  U R
                  R                  S   -   U R                  U-  U R
                  R                  S   -   //5      nUR                  5       u  pxXqR                  -  nXR                  -  n[        SS/Xx//5      n	U R                  U R
                  XfXU-  USS9$ )NTr  r(   r   F)r?   r  r  )	r  dpir   r6  r7  r   r3   get_size_inchesr  )
r   r>   r?   r  r8  facrG   r8   r7   rM  s
             rI   r0   FigureImage.make_imageE  s    oo4o(ll377" dggck4773;/wws{TWW]]1%55ggckDGGMM!$4478 9 ++-,,aVe_-.GGTS5Hu   > 	>rK   c                 2   > [         TU ]  U5        SU l        g)zSet the image array.TN)r   rT  r'  )r   r   r   s     rI   rT  FigureImage.set_dataW  s    
rK   )r?   r6  r7  r'  r~  )r   r  r  r  r  r  rZ  r   r5  r0   rT  r  r  r  s   @rI   r0  r0    sB    (FN ! !:7>$ rK   r0  c            	       \   ^  \ rS rSrSrSSSSSSSSS.U 4S jjrSS	 jrS
 rSS jrSr	U =r
$ )	BboxImagei]  z;The Image class whose size is determined by the given bbox.NTr}  Fr   r   r   r   r   r   r   r*   c                F   > [         TU ]  "  SUUUUUUUU	S.U
D6  Xl        g)r4  NrE  rN   )r   r   rG   )r   rG   r   r   r   r   r   r   r   r*   r   r   s              rI   r   BboxImage.__init__`  sC    $ 		
'!	
 	
 	rK   c                    Uc  U R                  5       R                  5       n[        U R                  [        5      (       a  U R                  $ [        U R                  5      (       a  U R                  U5      $ [        S5      e)NzUnknown type of bbox)r  _get_rendererrO   rG   r
   callabler   )r   r>   s     rI   r  BboxImage.get_window_extent  sb    (668Hdii**99dii  99X&&344rK   c                     U R                  U5      (       d  U R                  5       (       d  S0 4$ UR                  UR                  p2U R	                  5       R                  X#5      nU0 4$ )r2  F)r3  r&  rD   rE   r  r4  )r   r6  rD   rE   r7  s        rI   r4  BboxImage.contains  s]    !!*--T5E5E5G5G"9||Z\\1'')2218rzrK   c           	      *   UR                  5       u  pEU R                  U5      R                  5       nU=R                  XE/-  sl        U R                  U5      n[	        SS/XE//5      n[        U5      U l        U R                  U R                  XgXUS9$ )Nr   r%  )	get_canvas_width_heightr  r   _pointsr   r   
_transformr  r   )	r   r>   r?   r  r8   r7   bbox_inbbox_outrM  s	            rI   r0   BboxImage.make_image  s     88:((299;E?*))(3aVe_-.)$/GGti   I 	IrK   )rQ  rG   rN   r~  )r   r  r  r  r  r   r  r4  r0   r  r  r  s   @rI   rD  rD  ]  sA    E #  @	5
I 
IrK   rD  c                 d   SSK Jn  Uc  [        U [        5      (       aT  UR	                  U 5      n[        UR                  5      S:  a  SnO[        U 5      R                  R                  5       SS nO[[        U S5      (       a  SnOG[        U S5      (       a1  [        U R                  5      R                  R                  5       SS nOSnOUnUS:X  a  [        R                  R                  O[        R                  R                   n[        U [        5      (       a3  [        UR	                  U 5      R                  5      S:  a  [#        S5      eU" U 5       n[        U[        R                  R                  5      (       a  [%        U5      O
['        U5      sSSS5        $ ! , (       d  f       g= f)	a  
Read an image from a file into an array.

.. note::

    This function exists for historical reasons.  It is recommended to
    use `PIL.Image.open` instead for loading images.

Parameters
----------
fname : str or file-like
    The image file to read: a filename, a URL or a file-like object opened
    in read-binary mode.

    Passing a URL is deprecated.  Please open the URL
    for reading and pass the result to Pillow, e.g. with
    ``np.array(PIL.Image.open(urllib.request.urlopen(url)))``.
format : str, optional
    The image file format assumed for reading the data.  The image is
    loaded as a PNG file if *format* is set to "png", if *fname* is a path
    or opened file with a ".png" extension, or if it is a URL.  In all
    other cases, *format* is ignored and the format is auto-detected by
    `PIL.Image.open`.

Returns
-------
`numpy.array`
    The image data. The returned array has shape

    - (M, N) for grayscale images.
    - (M, N, 3) for RGB images.
    - (M, N, 4) for RGBA images.

    PNG images are returned as float arrays (0-1).  All other formats are
    returned as int arrays, with a bit depth determined by the file's
    contents.
r   )parseNr(   r:  geturlnamezPlease open the URL for reading and pass the result to Pillow, e.g. with ``np.array(PIL.Image.open(urllib.request.urlopen(url)))``.)urllibrV  rO   strurlparser,   schemer   suffixr   hasattrrX  r;  PngImagePluginPngImageFiler<  openr   _pil_png_to_float_arrayrR  )r?  ry   rV  parsedextimg_openrB   s          rI   imreadrf    sM   N ~eS!!^^E*F 6==!A%5k((..04UH%% CUF##uzz"))//1!"5CC+.%<''SYY^^ %#ennU&;&B&B"Ca"GI 	
 
%EeS%7%7%D%DEE (.U# 
s   ?F!!
F/)metadata
pil_kwargsc          	         SSK Jn
  [        U [        R                  5      (       a  [        R
                  " U 5      n UcN  [        U [        5      (       a  [        U 5      R                  SS O[        R                  S   R                  5       nUS;   a=  U	b  [        SU 35      eU
" USS	9nUR                  XX#US
S9  UR                  XUS
US9  gUc  [        R                  S   nO[        R                   " SUS9  US:X  a  USSS2   n[        U["        5      (       a6  UR$                  S:X  a&  UR&                  S:X  a  UR(                  S   S:X  a  UnO5[*        R,                  " US9nUR/                  X#5        UR1                  US
S9nU	c  0 n	OU	R3                  5       n	UR(                  S   UR(                  S   4n[4        R6                  " USS9n[8        R:                  R=                  SXSSSS5      nUS:X  a  SU	;   a  U(       a  [        R>                  " S5        OSS[        R@                   S 30Ub  UO0 En[8        RB                  RE                  5       =U	S'   nURG                  5        H  u  nnUc  M  URI                  UU5        M     OUb  [        S!U< 35      eUS";   a  S#n[        R                  S$   n[J        RL                  " US%5      (       a  [        R                  S&   n[O        S' [P        RR                  " U5       5       5      n[8        R:                  RU                  S(UU5      nURW                  X5        UnU	RY                  S)U5        U	RY                  S*Xw45        URZ                  " U 40 U	D6  g)+ar  
Colormap and save an array as an image file.

RGB(A) images are passed through.  Single channel images will be
colormapped according to *cmap* and *norm*.

.. note::

   If you want to save a single channel image as gray scale please use an
   image I/O library (such as pillow, tifffile, or imageio) directly.

Parameters
----------
fname : str or path-like or file-like
    A path or a file-like object to store the image in.
    If *format* is not set, then the output format is inferred from the
    extension of *fname*, if any, and from :rc:`savefig.format` otherwise.
    If *format* is set, it determines the output format.
arr : array-like
    The image data. The shape can be one of
    MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA).
vmin, vmax : float, optional
    *vmin* and *vmax* set the color scaling for the image by fixing the
    values that map to the colormap color limits. If either *vmin*
    or *vmax* is None, that limit is determined from the *arr*
    min/max value.
cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    A Colormap instance or registered colormap name. The colormap
    maps scalar data to colors. It is ignored for RGB(A) data.
format : str, optional
    The file format, e.g. 'png', 'pdf', 'svg', ...  The behavior when this
    is unset is documented under *fname*.
origin : {'upper', 'lower'}, default: :rc:`image.origin`
    Indicates whether the ``(0, 0)`` index of the array is in the upper
    left or lower left corner of the Axes.
dpi : float
    The DPI to store in the metadata of the file.  This does not affect the
    resolution of the output image.  Depending on file format, this may be
    rounded to the nearest integer.
metadata : dict, optional
    Metadata in the image file.  The supported keys depend on the output
    format, see the documentation of the respective backends for more
    information.
    Currently only supported for "png", "pdf", "ps", "eps", and "svg".
pil_kwargs : dict, optional
    Keyword arguments passed to `PIL.Image.Image.save`.  If the 'pnginfo'
    key is present, it completely overrides *metadata*, including the
    default 'Software' key.
r   FigureNr(   zsavefig.format)pdfpsepssvgz'Cannot use 'pil_kwargs' when saving to F)r=  frameonT)r   vminvmaxr   resize)r=  ry   transparentrg  r   )r   r   r   r   r   r  ru   r%   )r   r  C)requirementsRGBArawr:  pnginfoz@'metadata' is overridden by the 'pnginfo' entry in 'pil_kwargs'.SoftwarezMatplotlib versionz, https://matplotlib.org/z"metadata not supported for format )jpgjpegr|  zsavefig.facecolorr   zfigure.facecolorc              3   >   #    U  H  n[        US -  5      v   M     g7f)r   N)r6   rQ   s     rI   rS   imsave.<locals>.<genexpr>f  s     J0I1#a#g,,0Is   RGBry   r=  ).matplotlib.figurerk  rO   osPathLikefspathrZ  r   r]  r   r   r   r   figimagesavefigr   r   
memoryviewry   r   r3   
mcolorizer	Colorizerset_climr   rC  r-   requirer;  r<  
frombufferr   __version__r_  PngInfoitemsadd_textr   
_str_equalr  r   to_rgbnewpaste
setdefaultr>  )r?  r  rq  rr  r   ry   r   r=  rg  rh  rk  r8  r   sm	pil_shaperB   ry  krl  	facecolorcolor
backgrounds                         rI   imsaver    sH   f )%%%		% ~,6uc,B,B$u+$$QR(||$45uuw 	,,!9&BD De,S$&  	 	"E6t% 	 	'
 >\\.1F1&AWdd)CsJ''CJJ#,=HHMciimq&8
 D%%40BKK#::c:.DJ $*JZZ]DJJqM2	zz$S1		$$IUFAq:U? J&&& (J K #5coo5F G; "< $,#7xR
 362D2D2L2L2NN
9%$NN,DAq}((A. - !A&LMM_$F%89I	622LL);<	Jy0IJJEui?JU*Eh/ecZ0

5'J'rK   c                 P   U R                   S;   a  [        R                  " U 5      $ U R                   R                  S5      (       a  U R	                  SU R                   5      nU R                   R                  S5      (       a  [        R                  " US5      nO[        R                  " US5      nUR                  U R                  SSS2   5      R                  S	5      $  U R                  S
5      n [        R                  " U 5      $ ! [         a  n[        S5      UeSnAff = f)a8  
Load a `PIL image`_ and return it as a numpy int array.

.. _PIL image: https://pillow.readthedocs.io/en/latest/reference/Image.html

Returns
-------
numpy.array

    The array shape depends on the image type:

    - (M, N) for grayscale images.
    - (M, N, 3) for RGB images.
    - (M, N, 4) for RGBA images.
)rw  RGBXr  LzI;16rx  r  z>u2z<u2Nr   z=u2rw  zUnknown image mode)moder-   asarray
startswithtobytesendswithr  r  rW   r   convertr   r   )pilImagerx  rD   errs       rI   rR  rR  o  s      }}44zz(##		!	!&	)	)uhmm4==!!#&&c5)Ac5)Ayytt,-44U;;	>''/H zz(##  	>34#=	>s   #D
 

D%D  D%c                    U R                   nU R                  R                  nUS:X  a%  [        R                  " U [        R
                  5      $ US:X  a$  [        R                  " U S[        R
                  S9$ US:X  a$  [        R                  " U S[        R
                  S9$ US:X  a$  [        R                  " U S[        R
                  S9$ US	:X  a$  [        R                  " U S
[        R
                  S9$ US:X  a$  [        R                  " U S[        R
                  S9$ US:X  a3  [        R                  " U R                  S5      S[        R
                  S9$ US:X  a3  [        R                  " U R                  S5      S[        R
                  S9$ US:X  a$  [        R                  " U S[        R
                  S9$ [        SU 35      e)z2Convert a PIL `PNGImageFile` to a 0-1 float array.1zL;2ru   r&   zL;4   r  r   zI;16Bi  r  Prw  LAzUnknown PIL rawmode: )	r  r:  
im_rawmoder-   r  r   r  r  r   )pil_pngr  rawmodes      rI   rb  rb    sP    <<Dkk$$G#~zz'2::..%yy("**==%yy("**==#~yy("**=='yy)2::>>u}yy("**==s{yy0("**MMt|yy0("**MMv~yy("**==
,WI6
77rK   c                 6   [        U 5      nUR                  u  pgnSn	Xi-  U-  n
Xy-  U-  nU(       a  SSKJn  UR	                  X4U	S9nOSSKJn  U" X4U	S9n[        U5        UR                  / SQSS/ / S	9nUR                  USS
US9  UR                  XS9  U$ )aW  
Make a thumbnail of image in *infile* with output filename *thumbfile*.

See :doc:`/gallery/misc/image_thumbnail_sgskip`.

Parameters
----------
infile : str or file-like
    The image file. Matplotlib relies on Pillow_ for image reading, and
    thus supports a wide range of file formats, including PNG, JPG, TIFF
    and others.

    .. _Pillow: https://python-pillow.github.io

thumbfile : str or file-like
    The thumbnail filename.

scale : float, default: 0.1
    The scale factor for the thumbnail.

interpolation : str, default: 'bilinear'
    The interpolation scheme used in the resampling. See the
    *interpolation* parameter of `~.Axes.imshow` for possible values.

preview : bool, default: False
    If True, the default backend (presumably a user interface
    backend) will be used which will cause a figure to be raised if
    `~matplotlib.pyplot.show` is called.  If it is False, the figure is
    created using `.FigureCanvasBase` and the drawing backend is selected
    as `.Figure.savefig` would normally do.

Returns
-------
`.Figure`
    The figure instance containing the thumbnail.
d   r   N)figsizer=  rj  )r   r   r(   r(   r   F)aspectrp  xticksyticksT)r  r*   r   )r=  )rf  r3   matplotlib.pyplotpyplotfigurer  rk  r   add_axesimshowr  )infile	thumbfiler{   r   previewr/  rowscolsdepthr=  r7   r8   pltr8  rk  r   s                   rI   	thumbnailr    s    N 
BD CZ%FJE'jj%cj:,e_#6	l6#Br 
 
;BIIb$mILKK	K#JrK   )r   rN   )NNNNNr  )g?r   F)Lr  r   r  loggingpathlibr   rw   numpyr-   	PIL.Imager;  PIL.PngImagePlugin
matplotlibr   r   r   r   matplotlib._imagematplotlib.artistartistr   matplotlib.colorizerr   r  matplotlib.backend_basesr   matplotlib.colorscolorsr   matplotlib.transformsr	   r
   r   r   r   r   r   	getLoggerr   rK  r<   BILINEARBICUBICSPLINE16SPLINE36HANNINGHAMMINGHERMITEKAISERQUADRICCATROMGAUSSIANBESSELMITCHELLSINCLANCZOSBLACKMANr   setr_  rJ   rq   r   r   ColorizingArtistrP   r  r  r  r0  rD  rf  r  rR  rb  r  r!  rK   rI   <module>r     s[  
  	        "    # ) 5 #( ( ( "
FNN
FNN v~~ 	
 v~~   v~~ v~~ v~~ fmm v~~ fmm  fmm  !" FKK#$ ~~>>)	. 9~ 5Dr 7;,` <@q5pG	,, G	Ty
 yxbi bJD) DN?* ?D@I
 @IFK%\ @D~(-1d~(B $F8< ;E=rK   