@@ -1291,24 +1291,33 @@ def imread(fname, format=None):
12911291 """
12921292 Read an image from a file into an array.
12931293
1294- *fname* may be a string path, a valid URL, or a Python
1295- file-like object. If using a file object, it must be opened in binary
1296- mode.
1297-
1298- If *format* is provided, will try to read file of that type,
1299- otherwise the format is deduced from the filename. If nothing can
1300- be deduced, PNG is tried.
1301-
1302- Return value is a :class:`numpy.array`. For grayscale images, the
1303- return array is MxN. For RGB images, the return value is MxNx3.
1304- For RGBA images the return value is MxNx4.
1305-
1306- matplotlib can only read PNGs natively, but if `PIL
1307- <http://www.pythonware.com/products/pil/>`_ is installed, it will
1308- use it to load the image and return an array (if possible) which
1309- can be used with :func:`~matplotlib.pyplot.imshow`. Note, URL strings
1310- may not be compatible with PIL. Check the PIL documentation for more
1311- information.
1294+ Parameters
1295+ ----------
1296+ fname : str or file-like
1297+ The image file to read. This can be a filename, a URL or a Python
1298+ file-like object opened in read-binary mode.
1299+ format : str, optional
1300+ The image file format assumed for reading the data. If not
1301+ given, the format is deduced from the filename. If nothing can
1302+ be deduced, PNG is tried.
1303+
1304+ Returns
1305+ -------
1306+ imagedata : :class:`numpy.array`
1307+ The image data. The returned array has shape
1308+
1309+ - (M, N) for grayscale images.
1310+ - (M, N, 3) for RGB images.
1311+ - (M, N, 4) for RGBA images.
1312+
1313+ Notes
1314+ -----
1315+ Matplotlib can only read PNGs natively. Further image formats are
1316+ supported via the optional dependency on Pillow. Note, URL strings
1317+ are not compatible with Pillow. Check the `Pillow documentation`_
1318+ for more information.
1319+
1320+ .. _Pillow documentation: http://pillow.readthedocs.io/en/latest/
13121321 """
13131322
13141323 def pilread (fname ):
@@ -1374,26 +1383,29 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
13741383 Parameters
13751384 ----------
13761385 fname : str or file-like
1377- Path string to a filename, or a Python file-like object.
1378- If *format* is *None* and *fname* is a string, the output
1379- format is deduced from the extension of the filename .
1386+ The filename or a Python file-like object to store the image in .
1387+ The necessary output format is inferred from the filename extension
1388+ but may be explicitly overwritten using *format* .
13801389 arr : array-like
1381- An MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA) array.
1382- vmin, vmax: [ None | scalar ]
1390+ The image data. The shape can be one of
1391+ MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA).
1392+ vmin, vmax : scalar, optional
13831393 *vmin* and *vmax* set the color scaling for the image by fixing the
13841394 values that map to the colormap color limits. If either *vmin*
13851395 or *vmax* is None, that limit is determined from the *arr*
13861396 min/max value.
1387- cmap : matplotlib.colors.Colormap, optional
1388- For example, ``cm.viridis``. If ``None``, defaults to the
1389- ``image.cmap`` rcParam.
1390- format : str
1391- One of the file extensions supported by the active backend. Most
1392- backends support png, pdf, ps, eps and svg.
1393- origin : [ 'upper' | 'lower' ]
1394- Indicates whether the ``(0, 0)`` index of the array is in the
1395- upper left or lower left corner of the axes. Defaults to the
1396- ``image.origin`` rcParam.
1397+ cmap : str or `~matplotlib.colors.Colormap`, optional
1398+ A Colormap instance or registered colormap name. The colormap
1399+ maps scalar data to colors. It is ignored for RGB(A) data.
1400+ Defaults to :rc:`image.cmap` ('viridis').
1401+ format : str, optional
1402+ The file format, e.g. 'png', 'pdf', 'svg', ... . If not given, the
1403+ format is deduced form the filename extension in *fname*.
1404+ See `.Figure.savefig` for details.
1405+ origin : {'upper', 'lower'}, optional
1406+ Indicates whether the ``(0, 0)`` index of the array is in the upper
1407+ left or lower left corner of the axes. Defaults to :rc:`image.origin`
1408+ ('upper').
13971409 dpi : int
13981410 The DPI to store in the metadata of the file. This does not affect the
13991411 resolution of the output image.
0 commit comments