国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python使用scipy保存圖片的一些注意點(diǎn)

瀏覽:4日期:2022-06-19 11:51:56

首先我們載入一張灰度圖片,一般灰度圖片像素為0-255.

Python使用scipy保存圖片的一些注意點(diǎn)

Python使用scipy保存圖片的一些注意點(diǎn)

可以發(fā)現(xiàn)該圖片的最大像素為254,最小像素為2。一般處理圖片時(shí)會(huì)轉(zhuǎn)化為double類型。

Python使用scipy保存圖片的一些注意點(diǎn)

我們將圖片使用scipy保存為pgm格式。

然后我們重新讀取該圖片信息。

Python使用scipy保存圖片的一些注意點(diǎn)

Python使用scipy保存圖片的一些注意點(diǎn)

其像素值發(fā)生了變化,自動(dòng)標(biāo)準(zhǔn)化到了0-255范圍,最小值變?yōu)?,最大值變?yōu)?55.

Python使用scipy保存圖片的一些注意點(diǎn)

所以,使用scipy保存圖像時(shí),加上2個(gè)參數(shù),cmin和cmax。就可以了

重新讀取圖片。結(jié)果正確

Python使用scipy保存圖片的一些注意點(diǎn)

補(bǔ)充:from scipy import misc 讀取和保存圖片

from scipy import misc

def imread(name, flatten=False, mode=None) pass'''讀取一張圖片返回array,uint8,'''def imsave(name, arr, format=None): pass'''Save an array as an image. 自動(dòng)的調(diào)用將圖片轉(zhuǎn)成0-255范圍內(nèi)的arr : ndarray, MxN or MxNx3 or MxNx4Array containing image values. If the shape is ``MxN``, the arrayrepresents a grey-level image. Shape ``MxNx3`` stores the red, greenand blue bands along the last dimension. An alpha layer may beincluded, specified as the last colour band of an ``MxNx4`` array.'''

注意上面對(duì)圖片讀取和保存的函數(shù)會(huì)被棄用,使用如下代替:

import imageioimageio.imread()imageio.imwrite()

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 德格县| 新源县| 临西县| 茌平县| 历史| 唐河县| 合肥市| 荣昌县| 甘南县| 尤溪县| 常德市| 太湖县| 浙江省| 铅山县| 彭水| 通河县| 象州县| 西吉县| 镶黄旗| 荣昌县| 红河县| 宝坻区| 曲周县| 宜春市| 邻水| 水城县| 双流县| 弋阳县| 铜山县| 北安市| 新乐市| 泸溪县| 仙居县| 普兰县| 桐城市| 贵州省| 镇宁| 丹阳市| 阳谷县| 凤庆县| 台中县|