Skip to content

Conversation

@ccrrkk
Copy link

@ccrrkk ccrrkk commented Nov 1, 2025

原代码中的逻辑是不断寻找两两rect判断他们能不能完成合并,这会导致在处理一些复杂的pdf矢量图的时候耗时极大。我修改成了:1.先排除孤立的长细线(定义为长/宽>8, 且周围有相交bbox数目<2的线) 2.将rect膨胀distance/2(distance是合并判定距离),然后使用shapely.ops内置的更为高效的​​unary_union进行统一合并。

实验发现代码能显著提升提升效率。在手动检查了部分部分pdf文件的图片提取情况,发现总体提取情况令人满意,和原版代码相比提取质量并无明显下降

改进后时间分布:
time_distribution_fast

原来的时间分布:
time_distribution2

  Max time(s) Min time(s)​​ Avg time(s)​​ Middle time(s)​​
原版 981.5505 1.4643 78.9128 9.4675
改进 22.5599 1.5866 7.0962 5.3395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant