比较两个矢量图像

发布于 2024-12-06 02:43:29 字数 338 浏览 2 评论 0原文

我想比较两个矢量图像(例如 SVG),看看它们有多接近。 基本上,我想测试将光栅图像转换为矢量格式的跟踪算法的正确性。

我想测试这个算法的方法是:

- 拍摄一些矢量图像。

-将矢量图像光栅化为png。

- 将上述 png 输入到跟踪算法。

-将跟踪程序的输出(SVG)与原始输出进行比较。

虽然我知道光栅图像有一些度量,例如 RMSE(在 imagemagick 中),但我不熟悉矢量格式是否有一些标准度量。 我可以想到一些简单的方法,例如弧线、直线、曲线的数量等。但是这些无法检测几何形状和颜色的偏差。有人可以建议一个好的标准指标或解决此问题的其他方法吗?

I want to compare two vector images (say SVG) and see how close they are.
Basically, I want to test the correctness of a tracing algorithm which converts raster images to vector format.

The way I am thinking to test this algorithm is:

-Take some vector images.

-Rasterize the vector image to png.

-Feed the above png to tracing algorithm.

-Compare the output of tracing program (which is SVG) with the original one.

While I know there are some metrices for raster images like RMSE (in imagemagick), I am not familiar if there are some standard metrices for vector formats.
I can think of some simple ones like number of arcs, lines, curves etc. But these can not detect the deviation in geometry and colors. Could someone suggest a good standard metric or some other approach to this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-12-13 02:43:29

我不知道这方面的标准指标,但我确实有一个指针,希望对您有所帮助。

Batik 项目使用一组工具来测试其对 SVG 文档的渲染是否与一组参考图像相差太大。我的理解是,它本质上是对 SVG 进行栅格化,并对两个图像执行基于像素的差异,以了解它们有何不同。它应该足够聪明,能够忽略不可避免的差异,例如抗锯齿方面的细微差异。

您可以在以下位置阅读有关它的更多信息(尤其是 SVGRenderingAccuracyTest 部分): http:// /jpfop.sourceforge.net/jaxml-batik/html-docs/test.html

当然,这意味着您将进行光栅比较而不是矢量比较。在你的情况下,矢量比较将非常困难,因为完全不同的曲线可能会产生极其相似的渲染——我认为这很好。更重要的是,输入的形状可能隐藏在另一个形状后面,使得输出不可能猜测它是什么。因此,即使它可能产生像素完美的等效渲染,输出最终也会显示为完全错误。

然而,如果您确实希望执行矢量比较(也许您的数据受到某种方式的限制,从而使其更可行),最简单的方法可能是首先对两个 SVG 进行标准化(将所有形状转换为路径、消除所有元数据、应用所有属性的继承以及标准化它们的值,标准化路径数据以始终使用相同的形式等)并将其用于两个目的:首先,查看标准化树结构中的差异。这应该已经为您提供了一些有用的信息。其次,如果您有勇气,可以测量各个曲线之间差异的表面。不过,我会三思而后行,因为它可能会给你带来很多误报。

I am not aware of standard metrics for this, but I do have a pointer that I hope will be helpful.

The Batik project uses a set of tools to test that its rendering of SVG documents does not diverge excessively from a set of reference images. My understanding is that it essentially rasterises the SVG and performs a pixel-based diff of the two images to see how they differ. It ought to be smart enough to overlook unavoidable differences that may stem for instance from subtle differences in antialiasing.

You can read more about it (especially the SVGRenderingAccuracyTest section) at: http://jpfop.sourceforge.net/jaxml-batik/html-docs/test.html.

That, of course, means that you'll be doing raster comparisons and not vector comparisons. Vector comparisons in your case will be fiendishly difficult because entirely different curves may produce extremely similar rendering — something which I assume is fine. What's more, the input may have a shape that is hidden behind another, making it impossible for the output to possibly guess what it is. The output will therefore end up showing as entirely wrong even though it may produce a pixel-perfect equivalent rendering.

If however you do wish to perform vector comparisons (perhaps your data is constrained in a manner that makes this more viable) the simplest may be to first normalise both SVGs (convert all shapes to paths, eliminate all metadata, apply inheritance of all properties and normalise their values, normalise path data to always use the same form, etc.) and use this for two purposes: first, to look at the diffs in the normalised tree structure. That should already give you some useful information. Second, if you feel brave, measure the surface of the difference between individual curves. I would think twice about embarking on the latter though, because it is likely to give you lots of false negatives.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文