如何缩小 JPEG 图像以使文本尽可能清晰?

发布于 2024-08-31 16:55:49 字数 171 浏览 3 评论 0原文

我有一些 JPEG 图像,需要将其缩小到原始大小的 80% 左右。原始图像尺寸约为 700px × 1000px。图像包含一些计算机生成的文本,可能还包含一些图形(类似于您在公司 Word 文档中找到的内容)。

如何缩放图像以使文本尽可能清晰?目前,我们正在使用双三次插值缩小 imaeg,但这会使文本变得模糊。

I have some JPEG images that I need scale down to about 80% of original size. Original image dimension are about 700px × 1000px. Images contain some computer generated text and possibly some graphics (similar to what you would find in corporate word documents).

How to scale image so that the text is as legible as possible? Currently we are scaling the imaeg down using bicubic interpolation, but that makes the text blurry and foggy.

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

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

发布评论

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

评论(3

凉栀 2024-09-07 16:55:49

两个选项:

  1. 使用不同的重采样算法。 Lanczos 为您提供不太模糊的结果。

  2. 您可以使用高级 JPEG 库,将 8x8 块重新采样为 6x6 像素。

Two options:

  1. Use a different resampling algorithm. Lanczos gives you a much less blurrier result.

  2. You ight use an advances JPEG library that resamples the 8x8 blocks to 6x6 pixels.

待天淡蓝洁白时 2024-09-07 16:55:49

如果您没有设置为 80%,您可以尝试从 http://www.ijg.org/ 获取并构建 djpeg 因为它可以将您的 jpeg 解压缩到 6/8ths (75%) 或 7/8ths (87.5%) 大小,并且文本质量仍然相当不错:

原版

7/8

3/4

(所以决定内联显示图像时缩放图像)

可能有一种类似工作原理的缩放算法,但这是一个简单的现成解决方案。

If you are not set on exactly 80% you can try getting and building djpeg from http://www.ijg.org/ as it can decompress your jpeg to 6/8ths (75%) or 7/8ths (87.5%) size and the text quality will still be pretty good:

Original

7/8

3/4

(SO decided to scale the images when showing them inline)

There may be a scaling algorithm out there that works similarly, but this is an easy off the shelf solution.

櫻之舞 2024-09-07 16:55:49

缩小规模总是会带来损失,但这又取决于你的权衡。

  1. 对于 jpeg 图像来说,模糊和伪像生成是正常的,因此建议您第一次生成正确尺寸的图像。
  2. Lanczos 是一个很好的解决方案,但是您需要权衡。
  3. 如果它只是文本并且您担心它,您可以尝试对重新采样的图像进行膨胀过滤器。这可以纠正一些模糊现象,但也可能会影响图形。如果你能忍受它,那就太好了。或者,如果您可以识别文本区域,则可以在这些区域上应用扩张。

There is always a loss involved in scaling down, but it again depends of your trade offs.

  1. Blurring and artifact generation is normal for jpeg images, so its recommended that you generate images is the correct size the first time.
  2. Lanczos is a fine solution, but you have your trade offs
  3. If its just the text and you are concerned about it, you could try dilation filter over the resampled image. This would correct some blurriness but may also affects the graphics. If you can live with it, its good. Alternatively if you can identify the areas of text, you can apply dilation just over those areas.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文