0

I got a problem to transfer the filename from the dialog box into my Python code.I intend to do the histogram for the filename in the code

This is my code:

    from SimpleCV import Image
    import numpy as np
    import matplotlib.pyplot as plt
    from tkFileDialog import askopenfilename

    filename = Image(askopenfilename(filetypes = (("Gambar", ".jpg",),("Gambar", ".png",),("Semua Fail","*.*",))))
    img=Image(filename)
    histogram = img.histogram(256)
    len(histogram)
    plt.plot(histogram)
    plt.show()

should be the img=Image(filename) will call the selected file from the opened dialog box, and then it will create histogram for the selected file. But its not happening. But,If I do "print filename" then the location of the file is written in the console. Can somebody help? Thank you very much for your help.

Sophe
  • 1
  • 2
  • Have you tried removing the comma after the extensions in filetypes = blah? – Rob Jun 11 '15 at 12:25
  • erm yup,still cannot. if we remove the comma, there is another problem,the dialog box wont open. – Sophe Jun 12 '15 at 03:29

0 Answers0