image_helper.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:HSISeg 作者: HSISeg 项目源码 文件源码
def get_data_from_image(image_path):
#   from osgeo import gdal
    from skimage import io
    if image_path.split(".")[1] == "tif":
        M = io.imread(image_path)
#       dataset = gdal.Open(image_path,gdal.GA_ReadOnly)
#       col = dataset.RasterXSize
#       row = dataset.RasterYSize
#       a = [[[]for y in xrange(col)] for z in xrange(row)]
#       for i in xrange(1,dataset.RasterCount + 1):
#           band = dataset.GetRasterBand(i).ReadAsArray()
#           for m in xrange(0,row):
#               for n in xrange(0,col):
#                   a[m][n].append(band[m][n])
#       M = np.array(a,dtype='uint16')
    else:
        M = np.asarray(Image.open(image_path))
    return M
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号