image - 合成古代肮脏英文文献的虚拟生成

标签 image image-processing histogram signal-processing

我收集了一些肮脏的背景图片,下面是示例:

enter image description here

我还有一个带有文本的脏文档的实际图像的集合,如下所示:

enter image description here

我对带有文本的脏文档的实际图像的问题是,文本不是用英文字母写的,而是手写的。所以,我的任务是创建印有英文文本的旧文档。我所要做的就是将任何英文文本覆盖到空白的脏文档中。

叠加后,我的任务是找到一个衡量标准,表明合成生成的英文文本脏文档与我收集的原始非英文文本脏文档几乎相同。也许我可以比较它们的直方图之类的,以找到它们的共性。帮我找到那个措施。找到该度量的目的是确保合成生成的文档在特定阈值范围内具有与原始文档相同的质量。

我将使用合成生成的文档作为我的研究数据,并且我需要确保我将使用的数据与原始数据一样好。

最佳答案

不确定您的问题是关于生成文档还是分析它们,但我尝试了一下生成文档,并认为我不妨分享一下我所做的事情 - 既为了乐趣又为了我自己的引用。

我在命令行中使用了ImageMagick。它包含在大多数 Linux 发行版中,并且适用于 macOS 和 Windows。

我做了另一个关于照片合成老化的有点相关的答案here 。沿着这些思路:

enter image description here

所以,我从 here 中获取了“Olde English”字体并安装它以供 ImageMagick 使用,如图 here .

我从 Nietzsche Ipsum 中抓取了一些无意义的英文文本因为“Lorem Ipsum”是拉丁文。我假装聪明,将其保存在一个名为 wisdom.txt 的文件中:

Derive oneself good inexpedient derive ideal society. Mountains burying prejudice prejudice endless transvaluation contradict evil endless right. Burying transvaluation selfish passion overcome suicide contradict insofar madness spirit strong enlightenment suicide. Ubermensch fearful right god sexuality madness truth against superiority salvation.

Pinnacle faithful ascetic evil society marvelous will ultimate play christianity noble spirit good. Burying faithful war prejudice justice contradict of. Morality moral enlightenment gains zarathustra superiority joy war. Christianity value reason strong ideal. Deceptions justice god suicide battle of. Christian decieve abstract society revaluation derive ultimate joy.

Right morality grandeur value decieve. Revaluation christianity endless derive endless morality. Hatred of deceptions suicide snare pinnacle overcome society suicide ideal. Transvaluation christian pinnacle ultimate faith war ubermensch noble strong insofar prejudice abstract morality. Prejudice ascetic gains horror strong good against intentions snare.

Deceptions moral madness free inexpedient holiest convictions morality. Pious abstract moral christian deceptions overcome sexuality hope horror inexpedient. Against spirit.

然后,我将您的“脏文档”保存为 papyrus.jpg 并在终端中运行以下 ImageMagick 命令:

magick papyrus.jpg -size 360x600 -background none -font OldeEnglish -pointsize 20 -fill '#555' caption:@wisdom.txt -gravity center -compose multiply -composite result.png

结果如下:

enter image description here

基本上,我在比纸张稍小的区域(-尺寸 360x600)中生成深灰色文本(-fill '#555')透明背景 (-background none),然后将其居中 (-gravity center) 并将其合成 (-compose multiply -composite) 到背景上.

您可以做其他事情,例如:

  • 在将文本合成到背景上之前先用噪点对文本进行处理
  • 使用 Pango 将其设置为两列跨页
  • 将其扭曲成轻微的波浪形

但是基本的想法就在这里,任何有时间的人都可以进一步发展它。

关键词:图像处理、古代文本、手稿、古英语、纸莎草纸、Lorem Ipsum、遇险、中世纪、文档、老化、合成老化。

关于image - 合成古代肮脏英文文献的虚拟生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59865162/

相关文章:

python - 如何简单地为 numpy 直方图设置替代的不等式条件?

html - 背景不显示

image - .tga 图像 : Value that should be represented by a word is only correct if I read the first half word

php - 为什么这个基本的 imagejpeg() 缩放器返回黑色图像?

GitHub 贡献直方图

r - 规范化 ggplot 直方图,使 R 中的第一个高度为 1(显示增长)

html - 如何在 css/html 中获取图像上的文本?

android - 选择 ImageView 时如何在其顶部添加透明图像?

algorithm - 如何区分照片和文字图像

java - 将 XMP 写入多页 TIFF 的库