If you do not have mathematical formulas or numerical data and only have a graph image, you may want to read the plot coordinates from the image and quantify it.
I tried using Python's matplotlib to achieve this.
What you are doing
That is. By setting the coordinate axes properly, you should be able to quantify the graph data, but I would like to think about that in the future.
$ python3 py_img_test.py
/Users/kk/.pyenv/versions/3.5.2/lib/python3.5/site-packages/matplotlib/backend_bases.py:2437: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
warnings.warn(str, mplDeprecation)
I got the above warning and couldn't get rid of it, so I put the line below to get rid of the warning.
import warnings;warnings.filterwarnings('ignore')
`` `ginput``` is used to get the click coordinates.
Below is a sentence that adjusts the margins of the image and outputs it, which is often forgotten even though it is often used.
plt.savefig('fig_test.png', bbox_inches="tight", pad_inches=0.2)
py_img_test.py
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import warnings;warnings.filterwarnings('ignore')
im=Image.open('fig_PSHQ1.png')
im_list=np.asarray(im)
plt.imshow(im_list)
nn=5
a=plt.ginput(n=nn)
for x,y in a:
print(x,y)
plt.plot( x,y, 'ro' )
plt.savefig('fig_test.png', bbox_inches="tight", pad_inches=0.2)
plt.show()
If you load a separately created graph (file name: fig_PSHQ1.png) and click 5 points on the image, the console output below and the graph showing the click points in red circles will be displayed and saved.
$ python3 py_img_test.py
205.951612903 1005.9516129
318.85483871 825.306451613
489.822580645 689.822580645
680.14516129 589.822580645
1125.30645161 415.629032258
http://qiita.com/zaburo/items/5637b424c655b136527a [http://www.mwsoft.jp/programming/computer_vision_with_python/1_2_matplotlib.html] (http://www.mwsoft.jp/programming/computer_vision_with_python/1_2_matplotlib.html)
[http://seesaawiki.jp/python-project/d/%BA%C2%C9%B8%C3%CD%BC%E8%C6%C0(ginput)] (http://seesaawiki.jp/python-project/d/%BA%C2%C9%B8%C3%CD%BC%E8%C6%C0(ginput))
http://dothiko.hatenablog.com/entry/2014/11/27/001000
Recommended Posts