Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Google colaboratory将存储在变量中的Python图像数组写入Excel电子表格_Python_Excel_Data Science_Google Colaboratory_Export To Excel - Fatal编程技术网

如何使用Google colaboratory将存储在变量中的Python图像数组写入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 =

在这段代码中,我的图像功能数组存储在名为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 = 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')