温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何在python中使用plotdigitizer模块抠取论文的图片的数据

发布时间:2021-03-08 11:35:14 来源:亿速云 阅读:443 作者:Leah 栏目:开发技术

今天就跟大家聊聊有关如何在python中使用plotdigitizer模块抠取论文的图片的数据,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

python可以做什么

Python是一种编程语言,内置了许多有效的工具,Python几乎无所不能,该语言通俗易懂、容易入门、功能强大,在许多领域中都有广泛的应用,例如最热门的大数据分析,人工智能,Web开发等。

plotdigitizer的安装

这里我们使用pip来安装python第三方库plotdigitizer,该库的主要功能就是可以自动化的从图片中提取出数据,我们可以使用腾讯的pip镜像源来加速我们的安装过程:

[dechin@dechin-manjaro plotdigitizer]$ python3 -m pip install -i https://mirrors.cloud.tencent.com/pypi/simple plotdigitizer
Looking in indexes: https://mirrors.cloud.tencent.com/pypi/simple
Collecting plotdigitizer
 Downloading https://mirrors.cloud.tencent.com/pypi/packages/89/bb/ff753093458c05ce3b52fd17527b6b0622ca096aadcf561c6316320ab793/plotdigitizer-0.1.3-py3-none-any.whl (20 kB)
Collecting loguru<0.6.0,>=0.5.3
 Downloading https://mirrors.cloud.tencent.com/pypi/packages/6d/48/0a7d5847e3de329f1d0134baf707b689700b53bd3066a5a8cfd94b3c9fc8/loguru-0.5.3-py3-none-any.whl (57 kB)
   |████████████████████████████████| 57 kB 521 kB/s 
Collecting opencv-python<5.0.0,>=4.5.1
 Downloading https://mirrors.cloud.tencent.com/pypi/packages/2a/9a/ff309b530ac1b029bfdb9af3a95eaff0f5f45f6a2dbe37b3454ae8412f4c/opencv_python-4.5.1.48-cp38-cp38-manylinux2014_x86_64.whl (50.4 MB)
   |████████████████████████████████| 50.4 MB 467 kB/s 
Collecting numpy<2.0.0,>=1.19.5
 Downloading https://mirrors.cloud.tencent.com/pypi/packages/c7/e6/dccac76b7e825915ffb906beeba5a953597b6cfe1fe686b5276e122cb07c/numpy-1.20.1-cp38-cp38-manylinux2010_x86_64.whl (15.4 MB)
   |████████████████████████████████| 15.4 MB 20.4 MB/s 
Collecting matplotlib<4.0.0,>=3.3.4
 Downloading https://mirrors.cloud.tencent.com/pypi/packages/ab/20/60cfe5d611ac86df07b7b1f9b9582f22f7eda5edbe2124ba85bdf3133822/matplotlib-3.3.4-cp38-cp38-manylinux1_x86_64.whl (11.6 MB)
   |████████████████████████████████| 11.6 MB 4.4 MB/s 
Requirement already satisfied: python-dateutil>=2.1 in /home/dechin/anaconda3/lib/python3.8/site-packages (from matplotlib<4.0.0,>=3.3.4->plotdigitizer) (2.8.1)
Requirement already satisfied: cycler>=0.10 in /home/dechin/anaconda3/lib/python3.8/site-packages (from matplotlib<4.0.0,>=3.3.4->plotdigitizer) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in /home/dechin/anaconda3/lib/python3.8/site-packages (from matplotlib<4.0.0,>=3.3.4->plotdigitizer) (8.0.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/dechin/anaconda3/lib/python3.8/site-packages (from matplotlib<4.0.0,>=3.3.4->plotdigitizer) (1.3.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /home/dechin/anaconda3/lib/python3.8/site-packages (from matplotlib<4.0.0,>=3.3.4->plotdigitizer) (2.4.7)
Requirement already satisfied: six>=1.5 in /home/dechin/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.1->matplotlib<4.0.0,>=3.3.4->plotdigitizer) (1.15.0)
Installing collected packages: loguru, numpy, opencv-python, matplotlib, plotdigitizer
 Attempting uninstall: numpy
  Found existing installation: numpy 1.19.2
  Uninstalling numpy-1.19.2:
   Successfully uninstalled numpy-1.19.2
 Attempting uninstall: matplotlib
  Found existing installation: matplotlib 3.3.2
  Uninstalling matplotlib-3.3.2:
   Successfully uninstalled matplotlib-3.3.2
Successfully installed loguru-0.5.3 matplotlib-3.3.4 numpy-1.20.1 opencv-python-4.5.1.48 plotdigitizer-0.1.3

通过运行帮助指令,我们可以查看是否安装成功:

[dechin@dechin-manjaro plotdigitizer]$ plotdigitizer -h
usage: plotdigitizer [-h] --data-point DATA_POINT [--location LOCATION] [--plot PLOT] [--output OUTPUT]
           [--preprocess] [--debug]
           INPUT

Digitize image.

positional arguments:
 INPUT         Input image file.

optional arguments:
 -h, --help      show this help message and exit
 --data-point DATA_POINT, -p DATA_POINT
            Datapoints (min 3 required). You have to click on them later. At least 3 points
            are recommended. e.g -p 0,0 -p 10,0 -p 0,1 Make sure that point are comma
            separated without any space.
 --location LOCATION, -l LOCATION
            Location of a points on figure in pixels (integer). These values should appear in
            the same order as -p option. If not given, you will be asked to click on the
            figure.
 --plot PLOT      Plot the final result. Requires matplotlib.
 --output OUTPUT, -o OUTPUT
            Name of the output file else trajectory will be written to <INPUT>.traj.csv
 --preprocess     Preprocess the image. Useful with bad resolution images.
 --debug        Enable debug logger

执行指令与输出图片

先把需要抠取数据的图片放到当前目录下,然后运行如下指令:

plotdigitizer ./test1.png -p 0,-1 -p 20,0 -p 0,0.1 --plot output.png

该指令会将test1.png中的数据提取出来,可以使用-o存储为csv格式的数据表格。这里实际使用中我们发现,即使不用plot指令,也会在Manjaro Linux系统下不断的输出打印图片,只有通过kill -9的方式才能强行将进程杀死,有可能是开源库中存在的某个bug。

看完上述内容,你们对如何在python中使用plotdigitizer模块抠取论文的图片的数据有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI