Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. %pylab inline
  2. import matplotlib.image as mpimg
  3. from scipy import ndimage
  4.  
  5. img1 = mpimg.imread('1125150738.jpg')
  6. img1 = img1[800:1400,1000:3500,0]
  7. img1 = ndimage.rotate(img1,-3.5)
  8.  
  9. img2 = mpimg.imread('1125150738a.jpg')
  10. img2 = img2[800:1400,1000:3500,0]
  11. img2 = ndimage.rotate(img2,-3.5)
  12.  
  13. img1sum = img1[350:450,500:2100].sum(axis=0)
  14. img2sum = img2[400:500,500:2100].sum(axis=0)
  15.  
  16. fig, ((ax1, ax2),(ax3, ax4)) = plt.subplots(2,2,figsize=(10,4))
  17.  
  18. im1 = ax1.imshow(img1[100:600,500:2100])
  19. im2 = ax2.imshow(img2[100:600,500:2100])
  20.  
  21. im1.set_cmap('Reds')
  22. im2.set_cmap('Reds')
  23.  
  24. ax3.plot((img1sum-img1sum.min())/float32(img1sum.max()-img1sum.min()))
  25. ax4.plot((img2sum-img2sum.min())/float32(img2sum.max()-img2sum.min()))
  26.  
  27. ax1.set_ylim(100,500)
  28. ax2.set_ylim(100,500)
  29. ax3.set_ylim(0,1.1)
  30. ax4.set_ylim(0,1.1)
  31.  
  32. ax1.set_axis_off()
  33. ax2.set_axis_off()
  34.  
  35. ax4.set_yticklabels([])
  36.  
  37. ax3.set_ylabel('normalized intensity')
  38. ax3.set_xlabel('pixel')
  39. ax4.set_xlabel('pixel')
  40.  
  41. ax1.text(800,0,r'$d = 100$ $\mu$m',ha='center')
  42. ax2.text(800,0,r'$d = 200$ $\mu$m',ha='center')
  43.  
  44. fig.subplots_adjust(hspace=0, wspace = 0.07)
  45.  
  46. fig.savefig('single_slit_diffraction.png',dpi=300,bbox_inches='tight',pad_inches=0.05)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement