python example shouldn't run when imported as library
This commit is contained in:
+19
-19
@@ -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!'
|
||||
|
||||
Reference in New Issue
Block a user