Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %pylab inline
- import matplotlib.image as mpimg
- from scipy import ndimage
- img1 = mpimg.imread('1125150738.jpg')
- img1 = img1[800:1400,1000:3500,0]
- img1 = ndimage.rotate(img1,-3.5)
- img2 = mpimg.imread('1125150738a.jpg')
- img2 = img2[800:1400,1000:3500,0]
- img2 = ndimage.rotate(img2,-3.5)
- img1sum = img1[350:450,500:2100].sum(axis=0)
- img2sum = img2[400:500,500:2100].sum(axis=0)
- fig, ((ax1, ax2),(ax3, ax4)) = plt.subplots(2,2,figsize=(10,4))
- im1 = ax1.imshow(img1[100:600,500:2100])
- im2 = ax2.imshow(img2[100:600,500:2100])
- im1.set_cmap('Reds')
- im2.set_cmap('Reds')
- ax3.plot((img1sum-img1sum.min())/float32(img1sum.max()-img1sum.min()))
- ax4.plot((img2sum-img2sum.min())/float32(img2sum.max()-img2sum.min()))
- ax1.set_ylim(100,500)
- ax2.set_ylim(100,500)
- ax3.set_ylim(0,1.1)
- ax4.set_ylim(0,1.1)
- ax1.set_axis_off()
- ax2.set_axis_off()
- ax4.set_yticklabels([])
- ax3.set_ylabel('normalized intensity')
- ax3.set_xlabel('pixel')
- ax4.set_xlabel('pixel')
- ax1.text(800,0,r'$d = 100$ $\mu$m',ha='center')
- ax2.text(800,0,r'$d = 200$ $\mu$m',ha='center')
- fig.subplots_adjust(hspace=0, wspace = 0.07)
- 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