Python Forum

Full Version: python analysing image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys. I have a project to do and I'm in chaos. I have data from a camera that shows the spots of the incident electrons. The camera saves each image in txt files but there are some letters in the beggining that make my life difficult. I want to open this txt file and view the image of the matxrix from a certain line and the rest. the matrix consists only 0 and1 depending on the electron, if it hit the certain spot or not. then i need to sum every column and create the spectrum of it. if someone has the time to help me I would really appreciate it! thank you in advance
(Nov-15-2016, 08:24 PM)Aggeliki Wrote: [ -> ]... The camera saves each image in txt files but there are some letters in the beggining that make my life difficult. I want to open this txt file and view the image of the matxrix from a certain line and the rest.

Not sure what your saying here, why would the 'camera' save a picture as a text file? Every file contains a magic number/signature at the very beginning that describes information necessary to interact with that file type (you can see this info with a hex editor). Perhaps you could supply a portion of this 'text file'?
(Nov-15-2016, 08:37 PM)sparkz_alot Wrote: [ -> ]
(Nov-15-2016, 08:24 PM)Aggeliki Wrote: [ -> ]... The camera saves each image in txt files but there are some letters in the beggining that make my life difficult. I want to open this txt file and view the image of the matxrix from a certain line and the rest.
Not sure what your saying here, why would the 'camera' save a picture as a text file? Every file contains a magic number/signature at the very beginning that describes information necessary to interact with that file type (you can see this info with a hex editor). Perhaps you could supply a portion of this 'text file'?

Actually I wasn't at the experiment so I don't know for sure if it was a camera.. All I know is that I have this txt (which unfortunately I can't provide now because I'm not on the pc from work ) which can be used as an array, I gues.. So long I have written this code:
import numpy as np
import pylab as p

path = "/home/users2/afentaki/Bureau/afentaki.a/2015_SOLEIL/friday/"

file_name = "CO2_C1s_100"

stkin = input("what's the kinetic energy at the beginning?" )
endkin = input("what's the kinetic energy at the end?")
step = input("what's the step?" )

numspots = ( endkin - stkin ) / step 

line = input ("what's the line that the array begins? ")


mat = np.genfromtxt( path + file_name, delimiter = '', skip_header = line) 


p.figure
p.pcolor(mat)

from PIL import mat 
img = mat.open('151116.png')
img.show()

second = np.sum(mat, axis = 0 )
img = second.open('151116.png')
img.show()
but I get a lot of errors that I have no idea how to fix
Please post the Traceback error in error code tags when you have errors with you codes.