首页 > 编程知识 正文

python读取图片并显示,基于python的图片识别

时间:2023-05-04 20:22:57 阅读:12069 作者:4343

opencv的像素值在[ 0,1 ] [ 0,1 ],show时变换为[ 0,255 ]

import cv 2img=cv2.im read (imgfile ) (cv2.imshow ) ) img_win_name ),img ) cv2.waitKey(0) #无限cv2.imwrey )

高宽通道高宽通道。

分离方法为: b,g,r=cv2.split(img )1)1 2. scikit-image包

scikit-image的像素值在[ 1,1 ] [ 1,1 ],show时转换为[ 0,255 ]

importskimage.ioasioimportmatplotlib.pyplotaspltimg=io.im read (a.jpg ) ) io.im show (img ) plt.show ) ) 123456

3. matplotlib包matplotlib的像素值在[-1,1 ]之间,保存时转换为[ 0,255 ] [ 0,255 ],显示时转换为[ 0,255 ]

importmatplotlib.pyplotaspltimg=PLT.im read (img _ name ) (PLT.imshow ) img ) 1234 matplotlib读取图像也是heightwidhtcchow

4. tifffile软件包导入tiff file as tiff #将图像的像素值设置为[ 0,1 ]之间的defscale_percentile(matrix ) : w,h, d=matrix.shapematriff d ).astype(NP.float64 ) get 2nd and 98 thpercentilemins=NP.percentile (matrix,1 ), axis=0) maxs=NP.percentile )、axis=0) maxs ) NP.percen axis=0(-mins matrix=(matrix-mins [ none,] ) h] 1) returnmatriximg=tiff.im read (file _ name ) ) tiff.imshow(scale_percentile ) img ) 123456789101111121314155

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。