python - How do I measure the length of the scale bar in pixel point? -
how measure length of scale bar in pixel point, white area in picture?
from pil import image im = image.open("scalebar.png") width, height = im.size print(width, height)
638 58
scalebar=io.imshow('scalebar.png')
profile=np.mean(scalebar[31:34,:],axis=0) pixels=np.arange(1,np.size(profile)+1,1)
typeerror: 'axesimage' object not subscriptable
plt.plot(pixels,profile) plt.xlabel('pixels') plt.ylabel('intensity');
this trying do.
when use imshow('scalebar.png')
return handle figure, , not data. can convert image data directly numpy array.
from pil import image import numpy np im = image.open("scalebar.png") width, height = im.size print(width, height) scalebar = np.asarray(im) profile = np.mean(scalebar[31:34,:],axis=0) pixels = np.arange(1,np.size(profile)+1,1) plot(pixels, profile)
Comments
Post a Comment