日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

图片操作scipy.ndimage.imread和scipy.misc.imresize

發布時間:2025/3/20 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 图片操作scipy.ndimage.imread和scipy.misc.imresize 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

讀圖片str or file object--ndarray

scipy.ndimage.imread(*args,?**kwds)

imread?is deprecated!?imread?is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use?imageio.imread?instead.

1.2.0版本用imageio.imread代替

Read an image from a file as an array.從文件中把圖片讀成數組

This function is only available if Python Imaging Library (PIL) is installed.該功能只在安裝了PIL情況下使用

?

Parameters:

fname?: str or file object

The file name or file object to be read.

flatten?:?bool, optional

If True, flattens(扁平化)?the color layers into a single gray-scale(灰度)?layer.

將彩色層轉化成單個灰度層

mode?:?str, optional

Mode to convert image to, e.g.?'RGB'. See the Notes for more details.

Returns:

imread?: ndarray(多維數組)

The array obtained by reading the image.

Notes

imread?uses the Python Imaging Library (PIL) to read an image. The following notes are from the PIL documentation.

mode?can be one of the following strings:

?·??‘L’ (8-bit pixels, black and white)

?·??‘P’ (8-bit pixels, mapped to any other mode using a color palette)

?·??‘RGB’ (3x8-bit pixels, true color)

?·??‘RGBA’ (4x8-bit pixels, true color with transparency mask)

?·??‘CMYK’ (4x8-bit pixels, color separation)

?·??‘YCbCr’ (3x8-bit pixels, color video format)

?·??‘I’ (32-bit signed integer pixels)

?·??‘F’ (32-bit floating point pixels)

PIL also provides limited support for a few special modes, including ‘LA’ (‘L’ with alpha), ‘RGBX’ (true color with padding) and ‘RGBa’ (true color with premultiplied alpha).

When translating a color image to black and white (mode ‘L’, ‘I’ or ‘F’), the library uses the ITU-R 601-2 luma transform:

L =?R *?299/1000?+?G *?587/1000?+?B *?114/1000

When?flatten?is True, the image is converted using mode ‘F’. When?mode?is not None and?flatten?is True, the image is first converted according to?mode, and the result is then flattened using mode ‘F’.


調整圖片尺寸ndarray--ndarray

scipy.misc.imresize(*args,?**kwds)

imresize?is deprecated!?imresize?is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use?skimage.transform.resize?instead.

imresize功能將在1.2.0版本中,被skimage.transform.resize取代

Resize an image.調整圖片大小

This function is only available if Python Imaging Library (PIL) is installed.該功能只在安裝了PIL情況下使用

?

Warning

This function uses?bytescale?under the hood to rescale images to use the full (0, 255) range if?mode?is one of?None,?'L',?'P',?'l'. It will also cast data for 2-D images to?uint32?for?mode=None?(which is the default).

如果是None,?'L',?'P',?'l模式之一該函數使用bytescale在底層調整圖片,到(0, 255)全范圍內。并在默認模式mode=None計算二維圖片的32位(uint32)數據。

?

Parameters:

arr?: ndarray(多維數組)

The array of image to be resized.

size?:?int, float or tuple

?·??int - Percentage of current size.

?·??float - Fraction of current size.

?·??tuple - Size of the output image (height, width).

interp?:?str, optional

Interpolation to use for re-sizing (‘nearest’(最近鄰插值), ‘lanczos’(lanczos蘭佐斯 interpolation), ‘bilinear(雙線性插值)’, ‘bicubic’(雙三次插值)?or ‘cubic’(三次樣條插值)).

mode?:?str, optional

The PIL image mode (‘P’, ‘L’, etc.) to convert?arr?before resizing. If?mode=None?(the default), 2-D images will be treated like?mode='L', i.e. casting to long integer. For 3-D and 4-D arrays,?mode?will be set to'RGB'?and?'RGBA'?respectively.

Returns:

imresize?: ndarray

The resized array of image.

See also

toimage

Implicitly used to convert?arr?according to?mode.

scipy.ndimage.zoom

More generic implementation that does not use PIL.


總結

以上是生活随笔為你收集整理的图片操作scipy.ndimage.imread和scipy.misc.imresize的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。