diff --git a/Python/HandleDMPFiles.py b/Python/HandleDMPFiles.py index 9cd2951..34fa4e5 100644 --- a/Python/HandleDMPFiles.py +++ b/Python/HandleDMPFiles.py @@ -52,23 +52,23 @@ def writeDMP(array, outputfilename): array.tofile(dmpfile) dmpfile.close() -# Read example DMP file with the function defined above -DMPFileName = os.path.join(os.getcwd(), '..', 'example.DMP') -DMP = readDMP(DMPFileName) -# Show example image -plt.subplot(121) -plt.imshow(DMP, cmap='gray') -plt.title('example.DMP') +if __name__ == "__main__": + # Read example DMP file with the function defined above + DMPFileName = os.path.join(os.getcwd(), '..', 'example.DMP') + DMP = readDMP(DMPFileName) + # Show example image + plt.subplot(121) + plt.imshow(DMP, cmap='gray') + plt.title('example.DMP') + # Load some image from the internet and save its green channel as DMP. + URL = urllib2.urlopen('http://www.psi.ch/sls/tomcat/HomeEN/tomcat_banner.png') + image = plt.imread(URL)[:, :, 1] + writeDMP(image, 'randomimage.DMP') + # Read the image again as DMP and display it + plt.subplot(122) + plt.imshow(readDMP('randomimage.DMP'), cmap='gray') + plt.title('Some random image') -# Load some image from the internet and save its green channel as DMP. -URL = urllib2.urlopen('http://www.psi.ch/sls/tomcat/HomeEN/tomcat_banner.png') -image = plt.imread(URL)[:, :, 1] -writeDMP(image, 'randomimage.DMP') -# Read the image again as DMP and display it -plt.subplot(122) -plt.imshow(readDMP('randomimage.DMP'), cmap='gray') -plt.title('Some random image') - -plt.show() - -print 'Now open randomimage.DMP in Fiji!' + plt.show() + + print 'Now open randomimage.DMP in Fiji!'