我有两个图像处理函数的代码,它们将结果打印到控制台:
def haralick(self): #function for Haralick features computation
for filename in glob.iglob ('*.tif'):
imgg = mahotas.imread (filename)
cancertwo = mahotas.features.haralick (imgg)
arr = numpy.array([cancertwo])
for x in arr:
for y in arr:
for h in y:
for z in h: print '%f' %z
def humoments(self): #function for HuMoments computation
for filename in glob.iglob ('*.tif'):
img = cv.LoadImageM(filename, cv.CV_LOAD_IMAGE_GRAYSCALE)
cancer = cv.GetHuMoments(cv.Moments(img))
arr = numpy.array([cancer])
for x in arr:
for x in cancer:
print '%f' %x
我需要将计算的数字结果放入一个 .csv 文件“ResultsComp”中
如何更改行 numpy.savetxt("ResultsComp.csv", array.flat[:50], delimiter=" ") 来排列数字
在一个 .csv 文件的单独行中输出并将处理后的图像的名称放在行的第一个单元格中?
谢谢你。