)Uc@ sdZddlmZddlZddlZddlZddlmZddlm Z ddl j Z ddl m Z ddljZddljZddljZddljZddljZddlTddlmZmZddljZd e jejfd YZ d e fd YZ!d e!fdYZ"de jejfdYZ#de jejfdYZ$de fdYZ%e&dZ'e&e&e&e&e&ddZ(dZ)dde*dZ+dS(sS The image module supports basic image loading, rescaling and display operations. i(tdivisionN(tma(trcParams(tallow_rasterization(t*(tBboxBasetBboxt_AxesImageBasecB seZdZiejd6ejd6ejd6ejd6ejd6ej d6ej d6ej d6ej d 6ej d 6ejd 6ejd 6ejd 6ejd6ejd6ejd6ejd6ZegejD]\ZZeef^qZejZdZd,d,d,d,ddedZ dZ!dZ"dZ#ddZ$dZ%e&dZ'dZ(dZ)e*dZ+d Z,ed!Z-d"Z.d#Z/d$Z0d%Z1d&Z2d'Z3d(Z4d)Z5d*Z6d+Z7RS(-itnearesttbilineartbicubictspline16tspline36thanningthammingthermitetkaisertquadrictcatromtgaussiantbesseltmitchelltsinctlanczostblackmancC sdt|jjjS(NsAxesImage(%g,%g;%gx%g)(ttupletaxestbboxtbounds(tself((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt__str__:sig@c K stjj|tjj||||dkr?td}n||_|j||j |||_ |j ||j |||_ d|_d|_|j| dS(s 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 s image.originN(tmartisttArtistt__init__tcmtScalarMappabletNoneRtorigintset_filternormt set_filterradt _filterradtset_interpolationt set_resampleRt_imcachet_image_skew_coordinatetupdate( Rtaxtcmaptnormt interpolationR%t filternormt filterradtresampletkwargs((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR!=s          cC s,|jdkrtdn|jjd S(s+Get the numrows, numcols of the input images"You must first set the image arrayiN(t_AR$t RuntimeErrortshape(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytget_sizelscC s tjj||d|_dS(sw Set the alpha value used for blending - not supported on all backends ACCEPTS: float N(RR t set_alphaR$R+(Rtalpha((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR:sscC s&d|_d|_tjj|dS(sb Call this whenever the mappable is changed so observers can update state N(R$R+t _rgbacacheR"R#tchanged(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR=}s  g?cC stddS(Ns)The make_image method must be overridden.(R7(Rt magnification((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt make_imagesc C s|\}}}}||}||} |jdkrJ|dkrJd} n ||j} |jdkr{| dkr{d} n | |j} |jd \} } | dkr\|j||| }tdt||j}|j||| }t| t||j}t ||}|}|||| }|||| }||}||j} nt d| }| dkrU|j || | }tdt||j}|j || | }t| t||j}|j dkrt | || |}nt ||}|}||| | }||| | }||} | |j} nt d| }||j ks||jkrd|_||_ ||_n|jdkr|jjtjkrt|jjdkrtj|j||ddfd}t|_n|jdkrC|j|j|j}||_n |j}tj|||fd}t|jjdkr|jj|_n t|_||_|j dkr|j qn |j}||||| | | fS(s convert numpy array A with given extents ([x1, x2, y1, y2] in data coordinate) into the Image, given the vielim (should be a bbox instance). Image will be clipped if the extents is significantly larger than the viewlim. gg?iitupperiN(!twidththeightR8tx0tmaxtintR(tx1tmintslicety0ty1R%t _oldxslicet _oldysliceR$R+R6tdtypetnptuint8tlent_imagetfrombytetFalset is_grayscaleR<tto_rgbat_alphat fromarrayR/tis_grayt flipud_in(RtAt image_extentstviewlimtxmintxmaxtymintymaxtdxintvtdyintvtsxtsytnumrowstnumcolsRCtix0RFtix1txslicetxmin_oldRItiy0RJtiy1tyslicetymin_oldtimtx((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt_get_unsampled_imagesr             -(      cC s,tj}|j| | |j||f\}}|j||f\} } d|| || tj| | g| |gg} | tj|g|ggj\} } | tj|gdggj\}}tjj| || |dd}||tjj||jj }|S(sh Retuen a transform that does (x1, y1) -> (x1, y1) (x2, y2) -> (x2, y2) (x2, y1) -> (x3, y3) It was intended to derive a skew transform that preserve the lower-left corner (x1, y1) and top-right corner(x2,y2), but change the the lower-right-corner(x2, y1) to a new position (x3, y3). g?i( t mtransformstAffine2Dt translatettransform_pointRNtmattflatt from_valuestinvertedt get_affine(RFRJtx2ty2tx3ty3ttr1tx2aty2atx3aty3atinv_mattatbtctdttr2ttr((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt_get_rotate_and_skew_transforms 7((!,c+C s|j}|j\}}}}|jtj||f||fg}|d\} } |d\} } | | | | f} |jr|j\}}|jtj||fg}|d\}}|j| | | | ||}||j}n |j}|jj j \}}}}|j }|j tj||f||f||f||fg}t |dddft|dddf}}t |dddft|dddf}}tj||||}|j|j| |\} }!}"}#}$}%}&| dkr0dS|jjj}'tjj|'d}(| j|(| j| j\})}*| j|*|)|j| _|j||!|"| |#|$|dS(su draw unsampled image. The renderer should support a draw_image method with scale parameter. iiN( t get_transformt get_extentttransform_non_affineRNtarrayR,RRzRRtextentsRyt transformRGRDRt from_extentsRqR6R$tpatcht get_facecolortmcolorstcolorConverterRUtset_bgt reset_matrixR9tresizetget_urlt_urlt draw_image(+Rtrenderertgcttranstx_llctx_trcty_llcty_trctxyt_xx1t_yy1t_xx2t_yy2t extent_in_ictx_lrcty_lrctxy2t_xx3t_yy3ttr_rotate_skewttrans_ic_to_canvasRFRJR{R|ttrans_canvas_to_ictxy_tx1_tx2_ty1_ty2_t viewLim_in_icRoR]R_RaRbRcRdtfctbgReRf((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt_draw_unsampled_imagesJ  !      99-   cC stS(s{ return True if the image is better to be drawn unsampled. The derived class needs to override it. (RS(RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt_check_unsampled_imageIsc O s6|jsdS|jjdks:|jjdkrJtjdn|jjj\}}}}|j}|j |jjj |j |j |j |r|j||ni|jdk rtjdn|j|j} | dkrdS|j| _|j|||| |jdS(Ntlinears,Images are not supported on non-linear axes.s4Image will not be shown correctly with this backend.(t get_visibleRt get_xscalet get_yscaletwarningstwarnRRtnew_gctset_clip_rectangletfrozent set_clip_patht get_clip_pathRRR,R$R?tget_image_magnificationRRRtrestore( RRtargsR5tlRt widthDisplayt heightDisplayRRo((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytdrawPs&   c C st|jr|j||S|j|j}}|j\}}}}||krf||}}n||kr||}}n|dk r|dk r||ko||ko||ko||k}nt}|ifS(sH Test whether the mouse event occured within the image. N(tcallablet _containstxdatatydataRR$RS( Rt mouseeventRptyR]R^R_R`tinside((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytcontainsis  3c C s|j}|dkrdS|r^|j\}}|j|jd|j||n|j|j\}}}tj ||||dS(s&Write the image to png file with fnameNi( R?R$R9RR)Rt flipud_outt as_rgba_strt_pngt write_png( RtfnametnoscaleRoReRftrowstcolstbuffer((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs     cC st|dr!t||_ntj||_|jjtjkrstj|jjtj  rst dn|jj d ks|jj dkr|jj dd krt dnd|_d|_d|_d|_dS( sI Set the image array ACCEPTS: numpy/PIL Image A tgetpixels#Image data can not convert to floatiiiis!Invalid dimensions for image dataN(ii(ii(thasattrt pil_to_arrayR6tcbooktsafe_masked_invalidRMRNROtcan_casttfloatt TypeErrortndimR8R$R+R<RKRL(RRZ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytset_datas1(   cC s|j|dS(sq retained for backwards compatibility - use set_data instead ACCEPTS: numpy array A or PIL ImageN(R(RRZ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt set_arrays cC s|jS(s Return the interpolation method the image uses when resizing. One of 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', (t_interpolation(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytget_interpolationscC sP|dkrtd}n|j}||jkrCtdn||_dS(s? Set the interpolation method the image uses when resizing. ACCEPTS: ['nearest' | 'bilinear' | 'bicubic' | 'spline16' | 'spline36' | 'hanning' | 'hamming' | 'hermite' | 'kaiser' | 'quadric' | 'catrom' | 'gaussian' | 'bessel' | 'mitchell' | 'sinc' | 'lanczos' | ] simage.interpolationsIllegal interpolation stringN(R$Rtlowert_interpdt ValueErrorR(Rts((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR)s  cC s&|dkrtd}n||_dS(sZ set whether or not image resampling is used ACCEPTS: True|False simage.resampleN(R$Rt _resample(Rtv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR*s cC s|jS(s!return the image resample boolean(R(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt get_resamplescC s|rd|_n d|_dS(sy Set whether the resize filter norms the weights -- see help for imshow ACCEPTS: 0 or 1 iiN(t _filternorm(RR2((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR&s cC s|jS(sreturn the filternorm setting(R(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytget_filternormscC st|}||_dS(s Set the resize filter radius only applicable to some interpolation schemes -- see help for imshow ACCEPTS: positive float N(RR((RR3tr((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR's cC s|jS(sreturn the filterrad setting(R((R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt get_filterradsN(8t__name__t __module__tzorderRQtNEARESTtBILINEARtBICUBICtSPLINE16tSPLINE36tHANNINGtHAMMINGtHERMITEtKAISERtQUADRICtCATROMtGAUSSIANtBESSELtMITCHELLtSINCtLANCZOStBLACKMANRtdicttitemstkRt _interpdrtkeyst interpnamesRR$RSR!R9R:R=R?Rqt staticmethodRRRRRRRRRRR)R*RR&RR'R(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRsd                 1   (   R O        t AxesImagec B sYeZdZd d d d d ddedZddZdZdZdZ RS( cC sdt|jjjS(NsAxesImage(%g,%g;%gx%g)(RRRR(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRsig@c K sJ||_tj||d|d|d|d|d|d|d| | dS( s 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/R0R1R%R2R3R4N(t_extentRR!( RR.R/R0R1R%textentR2R3R4R5((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR!s g?c"C s|jdkrtdn|j\}}}}|j}|jtj||f||fg}|d\}} |d\} } tj |j j |} |j |j|| | | g| \} }}}}}}|j j j}tjj|d}| j|| j| j\}}|dksE|dkrIdS| j|j|j| j|j|dkrd}n|| j||}|dkrd}n|| j||}| j|||j jj\}}}}t||dt||d}t||dt||d}||} ||}!| j | ||!|| j!t"|dt"|dd|j#d|j$| S(Ns9You must first set the image array or the image attributeiigg?R0tradius(%R6R$R7RRRRNRRrtTransformedBboxRtviewLimRqRRRRRURRR9R)RRR*RRCRItapply_translationRRtroundt apply_scalingRRERR(("RR>RFR{RJR|RRt_x1t_y1t_x2t_y2ttransformed_viewLimRoR]R_RaRbRcRdRRReRfttxttyRRRttRRtrxtry((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR?'sJ        &&  #cC s*|jr"|jdkr"tStSdS(sK return True if the image is better to be drawn unsampled. RN(toption_scale_imageRtTrueRS(RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRascC s||_|\}}}}||f||ff}|jj||jjrn|jj||fddn|jjr|jj||fddndS(sc extent is data axes (left, right, bottom, top) for making image plots This updates ax.dataLim, and, if autoscaling, sets viewLim to tightly fit the image, regardless of dataLim. Autoscaling state is not changed, so following this with ax.autoscale_view will redo the autoscaling in accord with dataLim. tautoN(RRtupdate_datalimt _autoscaleXontset_xlimR$t _autoscaleYontset_ylim(RRR]R^R_R`tcorners((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt set_extentjs   cC sq|jdk r|jS|j}|\}}|jdkrUd|d|ddfSd|dd|dfSdS(s.get the image extent: left, right, bottom, topR@gg?N(RR$R9R%(RtszReRf((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR~s  N( RRRR$RSR!R?RR.R(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs  : tNonUniformImagecB sneZdZdZddZdZdZdZdZdZ d Z d Z d Z RS( cK s6|jdd}tj||||j|dS(sx kwargs are identical to those for AxesImage, except that 'interpolation' defaults to 'nearest' R1RN(tpopRR!R)(RR.R5tinterp((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR!s cC stS(s; return False. Do not use unsampled image. (RS(RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRsg?c C s0|jdkrtdn|jjj\}}}}|jjj\}}}} t|dt|d} t| dt|d} | |9} | |9} t j |j |j |j| | ||||||f|j |j} |jjj} tjj| d}| j||j| _| S(Ns"You must first set the image arrayg?i(R6R$R7RRRRRRRQtpcolort_Axt_AyRRRRRRRURRT(RR>RCRItv_widthtv_heightRRRR"RARBRoRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR?s"    c C stj|tj}tj|tj}tj|}t|jdkst|jdks|jdd!|jd|jdfkrtdnt|jd krtdnt|jdkr|jdd krtdnt|jdkr5|jddkr5|jdd!|_nt|jdkr|jtj kr|j |j |d j tj }|j j |_qtj|d d d d tjfdd}d |d d d d dfRRRRRR"RARBRZtvlRo((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR?"s0  !     cO s|jsdS|j|j}|j}|j|jjj|j|j |j |t |jjj t |jjj ||jdS(N(RR?RRRRRRRRRRR]R_R(RRRR5RoR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR=s   cC sMtj|}|dkrDtjd|jdddtj}ntj|tjj}|dkrtjd|jdddtj}ntj|tjj}|jd |j d|j dfkr|jGH|j GH|j GHt dn|j d krt dn|j dkrP|jddkrP|jd |_nt |_ |j dkr!|jdd kr|dddddf|dddddfkjr|dddddf|dddddfkjrt|_ qq!t d n||_||_||_t|jd (RtfigR/R0toffsetxtoffsetyR%R5((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR!zs      c C st|jr|j||S|j\}}}}|j|j}}|dk r|dk r||ko||ko||ko||k}nt}|ifS(s?Test whether the mouse event occured within the image. N(RRRRpRR$RS( RRR]R^R_R`RRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs3cC s,|jdkrtdn|jjd S(s+Get the numrows, numcols of the input images"You must first set the image arrayiN(R6R$R7R8(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR9scC sF|j\}}d|j|d|jd|j|d|jfS(s.get the image extent: left, right, bottom, topgg?(R9RQRR(RReRf((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRscC s tjj|tj|dS(s& Set the image array N(R"R#RRR(RRZ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRscC s|j|dS(sR Deprecated; use set_data for consistency with other image types. N(R(RRZ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRsg?c C s9|jdkrtdn|j|j|j}||_|dk}|rZd}nd}tj||}|jj }|j t j j|d|j jdkot|jjdk|_|r|j\}}||9}||9}|jtj|j||n|jdkr5|jn|S(Ns"You must first set the image arrayiitgrayiR@(R6R$R7RURVR>RQRWRPRRRRR/tnameRPR8RTR9R)RRR%R( RR>RptismagtisoutputRoRReRf((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR?s,      cO s|jsdS|j|j}|j}|j|jj|j|j|j |t |j t |j ||j dS(N(RR?RRRRPRRRRRRQRRR(RRRR5RoR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs  (cC s;|j}|j\}}}tj||||dS(s&Write the image to png file with fnameN(R?RRR(RRRoRRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs N(RRRR$R!RR9RRRR?RRR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyROxs        t BboxImagecB seeZdZd d d d ddedZd dZdZdZddZ e d Z RS( sE The Image class whose size is determined by the given bbox. ig@c K sMtj|dd d|d|d|d|d|d|d|| ||_d S( s 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 R.R/R0R1R%R2R3R4N(RR!R$R( RRR/R0R1R%R2R3R4R5((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR!scC sc|dkr|jj}nt|jtr7|jSt|jrS|j|StddS(Nsunknown type of bbox(R$t get_figuret_cachedRenderert isinstanceRRRR(RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytget_window_extents  cC sjt|jr|j||S|js5tifS|j|j}}|jj||}|ifS(s?Test whether the mouse event occured within the image. (RRRRSRpRR^R(RRRpRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs  cC s,|jdkrtdn|jjd S(s+Get the numrows, numcols of the input images"You must first set the image arrayiN(R6R$R7R8(R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR9(sg?cC s;|jdkrtdn|jdkr'|jjtjkr{t|jjdkr{t j |jd}t |_ n|j dkr|j|j|j}||_ n |j }t j|d}t|jjdkr|jj|_ n t |_ ||_|jdkr0|jq0n |j}|j|j|j|j|j|j|j|j\}}}}t|dt|d} t|dt|d} | |9} | |9} |jjd \} } | | } | | }|j| ||jt | t | d|j!d|j"|S( Ns9You must first set the image array or the image attributeiiiR@g?R0R(#R6R$R7R+RMRNRORPR8RQRRRSRTR<RURVRWR/RXR%RYRR)RRR*RR^RRRRRERR((RRR>RoRpRRRR"RRReRfR#R$((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyR?/sB-           c O s|jsdS|j}|j||}|j|j\}}}} |j} |j| |j| t|t||| j dS(N( RRR?R^RRt _set_gc_clipRRR( RRRR5t image_magRoRRRR"R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRds    "N( RRRNR$RSR!R^RR9R?RR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRZs    5c sfd}itjd6}|dkrntjretjj\}}|jd}qtd}n|}||j kr|}|dkrt d|j n|S||}tjrt dn|S(s Return image file in *fname* as :class:`numpy.array`. *fname* may be a string path or a Python file-like object. If *format* is provided, will try to read file of that type, otherwise the format is deduced from the filename. If nothing can be deduced, PNG is tried. Return value is a :class:`numpy.array`. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4. matplotlib can only read PNGs natively, but if `PIL `_ is installed, it will use it to load the image and return an array (if possible) which can be used with :func:`~matplotlib.pyplot.imshow`. c s>yddl}Wntk r$dSX|j}t|S(s-try to load the image with PIL or return NoneiN(tImaget ImportErrorR$topenR(Ratimage(R(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytpilreads  tpngis\Only know how to handle extensions: %s; with PIL installed matplotlib can handle more imagestrbN( Rtread_pngR$Rtis_string_liketostpathtsplitextRRRRc(RtformatRethandlerstbasenametextRothandler((RsC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytimreadss"     idc C sddlm}ddlm} g|jdddD]} | t|^q7} | d| d|dt} || } | j|d|d |d |d |}| j|d|d |dS( s Saves a 2D :class:`numpy.array` as an image with one pixel per element. The output formats available depend on the backend being used. Arguments: *fname*: A string containing a path to a filename, or a Python file-like object. If *format* is *None* and *fname* is a string, the output format is deduced from the extension of the filename. *arr*: A 2D array. Keyword arguments: *vmin*/*vmax*: [ None | scalar ] *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*: cmap is a colors.Colormap instance, eg cm.jet. If None, default to the rc image.cmap value. *format*: One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg. *origin* [ 'upper' | 'lower' ] Indicates where the [0,0] index of the array is in the upper left or lower left corner of the axes. Defaults to the rc image.origin value. *dpi* The DPI to store in the metadata of the file. This does not affect the resolution of the output image. i(tFigureCanvasAgg(tFigureNtfigsizetdpitframeonR/tvmintvmaxR%Rm( tmatplotlib.backends.backend_aggRstmatplotlib.figureRtR8RRStfigimagetsavefig(RtarrRxRyR/RmR%Rvt FigureCanvasRtRpRuRStcanvasRo((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pytimsaves 3 'cC s d}|jd kr!|}n|jdkrc|}||}|jd|jdf|_|S|jdkr|}||}|jd|jddf|_|Sy|jd}Wntk rtd nX||}|jd|jdd f|_|S( s load a PIL image and return it as a numpy array of uint8. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4 cS s4|jd|jdd}tj|tj}|S(sreturn a 1D array of floatstrawii(ttostringtmodeRNt fromstringRO(Rotx_strRp((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyttoarraystRGBAtRGBXtLiitRGBisUnknown image modei(RR(RRKR8tconvertRR7(tpilImageRRoRp((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyRs(        g?R c C stjj|\}}tjj|\}}t|} | j\} } } d} t| | |}t| | |}|j}|rddlj }|j d||fd| }n|dkrddl m }nJ|dkrdd l m}n+|d krdd lm}n td dd lm}|d||fd| }||}|jddddgdddtdgdg}tjj|\}}|j| dddtdd|j|d| |S(s make a thumbnail of image in *infile* with output filename *thumbfile*. *infile* the image file -- must be PNG or PIL readable if you have `PIL `_ installed *thumbfile* the thumbnail filename *scale* the scale factor for the thumbnail *interpolation* the interpolation scheme used in the resampling *preview* if True, the default backend (presumably a user interface backend) will be used which will cause a figure to be raised if :func:`~matplotlib.pyplot.show` is called. If it is False, a pure image backend will be used depending on the extension, 'png'->FigureCanvasAgg, 'pdf'->FigureCanvasPDF, 'svg'->FigureCanvasSVG See examples/misc/image_thumbnail.py. .. htmlonly:: :ref:`misc-image_thumbnail` Return value is the figure instance containing the thumbnail idiNRuRvs.png(Rss.pdf(tFigureCanvasPDFs.svg(tFigureCanvasSVGs0Can only handle extensions 'png', 'svg' or 'pdf'(RtiitaspectR'RwtxtickstyticksR4R1R (RjRktsplitRlRrR8RRtmatplotlib.pyplottpyplotRPRzRstmatplotlib.backends.backend_pdfRtmatplotlib.backends.backend_svgRRR{Rttadd_axesRStimshowR&R}(tinfilet thumbfiletscaleR1tpreviewtbasedirRotbaseouttextoutRoRRtdepthRvRBRAt extensiontpltRSRRtRR.Rp((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyt thumbnails4&  !     3(,RNt __future__RRjRtnumpyRNRt matplotlibRtmatplotlib.artisttartistRRtmatplotlib.colorstcolorsRt matplotlib.cmR"tmatplotlib.cbookRtmatplotlib._imageRQtmatplotlib._pngRtmatplotlib.transformsRRt transformsRrR R#RRR0RCRORZR$RrRRRSR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/image.pyts8  vus 5 ) &