如何使用Google colaboratory将存储在变量中的Python图像数组写入Excel电子表格
在这段代码中,我的图像功能数组存储在名为numpydata的变量中 我想将完整数组数据存储到excel工作表中,而不是变量 请帮忙如何使用Google colaboratory将存储在变量中的Python图像数组写入Excel电子表格,python,excel,data-science,google-colaboratory,export-to-excel,Python,Excel,Data Science,Google Colaboratory,Export To Excel,在这段代码中,我的图像功能数组存储在名为numpydata的变量中 我想将完整数组数据存储到excel工作表中,而不是变量 请帮忙 import numpy as np from skimage.io import imread, imshow from skimage.filters import prewitt_h,prewitt_v import matplotlib.pyplot as plt %matplotlib inline #reading the image image =
import numpy as np
from skimage.io import imread, imshow
from skimage.filters import prewitt_h,prewitt_v
import matplotlib.pyplot as plt
%matplotlib inline
#reading the image
image = imread('/content/drive/My Drive/train_greenchromide/22.jpg',as_gray=True)
#calculating horizontal edges using prewitt kernel
edges_prewitt_horizontal = prewitt_h(image)
#calculating vertical edges using prewitt kernel
edges_prewitt_vertical = prewitt_v(image)
#imshow(edges_prewitt_vertical, cmap='gray')
imshow(edges_prewitt_horizontal,cmap='gray')
from numpy import asarray
numpydata = asarray(edges_prewitt_horizontal )
print(numpydata)
# Writing to an excel
# sheet using Python
import xlwt
from xlwt import Workbook
# Workbook is created
wb = Workbook()
# add_sheet is used to create sheet.
sheet1 = wb.add_sheet('Sheet 1')
sheet1.write(1, 0, 'numpydata')
wb.save('data1.xls')