我在Pyspark中正确读取图像时遇到问题。我从示例程序中提取了以下内容。当我运行代码时,似乎返回的是一维数组而不是正确的数据。
是否需要配置此设置才能使其正常工作?
df = ImageSchema.readImages('path')
data = df.take(4)
for i in range(0,4):
im = data[i][0]
print("image index: {}".format(i))
print("image type: {}, number of fields: {}".format(type(im), len(im)))
print("image path: {}".format(im.origin))
print("height: {}, width: {}, Mode: {}".format(im.height, im.width, im.mode))
print('Channels: {}'.format(im.nChannels))
print("\n")
返回:
image index: 0
image type: <class 'pyspark.sql.types.Row'>, number of fields: 6
image path: 'path'
height: 1024, width: 1280, OpenCV type: 0
Channels: 1