将大 1 位 tiff 缩小为 8 位灰度/24 位
假设我有一个 100000x100000 1 位(K 通道)tiff,dpi 为 2000,我想将其缩小到 dpi 200。我生成的图像将是 10000x10000 图像。这是否意味着 1 位图像中的每 10 位对应于新图像中的 1 个像素?顺便说一句,我正在使用 libtiff 并使用 tiffreadscanline 读取 1 位 tiff。谢谢!
Let's say i have a 100000x100000 1 bit (K channel) tiff with a dpi of 2000 and i want to downscale this to a dpi of 200. My resulting image would be 10000x10000 image. Does this mean that every 10 bits in the 1 bit image correspond to 1 pixel in the new image? By the way, i am using libtiff and reading the 1 bit tiff with tiffreadscanline. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着 1 位图像中的每 100 位对应于新图像中的 1 个像素。您需要对 10x10 1 位像素区域的值进行平均。为了获得更平滑的灰度,您最好对 n 位进行平均,其中 n 是目标像素的位深度,将计算出的区域与相邻区域部分重叠(16x16 像素的正方形,间隔 10x10 像素) ,因此它们的边框重叠,以获得平滑的 8 位灰度。)
That means every 100 bits in the 1 bit image correspond to 1 pixel in the new image. You'd need to average the value over 10x10 1bit pixel area. For smoother greyscales, you'd better average over n bits where n is the bit depth of your target pixel, overlying the calculated area partially with neighbor areas (16x16px squares 10x10px apart, so their borders overlay, for a smooth 8-bit grayscale.)
重要的是要了解为什么要缩小规模(因为输出介质还是因为文件大小?)。正如 SF 指出的,颜色/灰度在某种程度上可以与分辨率互换。如果它只是关于文件大小,无损/有损压缩也值得一看。
另一件事是了解源图像的一些特征。例如,如果源图像被光栅化(对于报纸图像),您可能会得到奇怪的图案,因为点阵被弄乱了。我曾经尝试过修复旧报纸图像,但发现工作量很大。在增强图像之前,我最终先将其转换为灰度。
我建议用 VIPS 或 Irfanview 进行一些实验,以找到最佳结果(即是某种重采样算法对图像质量的影响)。使用这些程序(例如 Photoshop)的原因是您可以尝试 GUI/命令行,同时了解其背后算法的名称/参数。使用 VIPS,您可以控制大多数(如果不是全部)参数。
[编辑]
TiffDump(与 LibTiff 二进制文件一起提供)是一个有价值的信息源。它会告诉你有关字节排序等的信息。我所做的是从一个已知的图像开始。例如,LibTIFF.NET 附带了许多测试图像,包括黑白(有些带有 0=黑色,有些 1=黑色)。 [/编辑]
It is important to understand why you want to downscale (because of output medium or because of file size?). As SF pointed out, colors/grayscale are somewhat interchangeable with resolution. If it is only about file size losless/lossy compression is also worth to look at..
The other thing is to understand a bit of the characteristics of your source image. For instance, if the source image is rasterized (as for newspaper images) you may get akward patterns because the dot-matrix is messed up. I have once tried to restore an old news-paper image, and I found it a lot of work. I ended up converting it to gray scale first before enhancing the image.
I suggest to experiment a bit with VIPS or Irfanview to find the best results (i.e. what is the effect of a certain resampling algorithm on your image quality). The reason for these programs (over i.e. Photoshop) is that you can experiment with GUI/command line while being aware of name/parameters of the algorithms behind it. With VIPS you can control most if not all parameters.
[Edit]
TiffDump (supplied with LibTiff binaries) is a valuable source of information. It will tell you about byte ordering etc. What I did was to start with a known image. For instance, LibTIFF.NET comes with many test images, including b&w (some with 0=black, some with 1=black). [/Edit]