I wrote a method computing Robert Haralick image features (using Mahotas package) on .tif medical images in the working directory. I receive the print output in a column like:
567657657
788979877
787879787
I need to convert it to the horizontal row appearance like: 1789789 8909888 898098098
and, if possible, append the name of the processed file before that row of output (like: imagename 7897987 90890898...
). Here is the code:
def haralick(self):
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
print('\n')
I have no experience with Python; If you mean however to print the same numbers consecutive to console or file or whatever, it will be just a matter of not printing the \n\r character but substituting them with for example a tab \t or a comma ',',