python - How do I measure the length of the scale bar in pixel point? -


scalebar.png

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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -