编辑 TIFF 图像而不更改标题数据
我有一个程序,它接受成堆的 TIFF 图像,并且对标头数据非常特殊(它期望所有标头都相同),但是我想在将其发送到该程序之前编辑堆栈中的几个图像。
到目前为止,我尝试过的每个程序(Paint.net、MS Paint、ImageJ)都更改了头文件,或者在保存新图像时彻底损坏了它。我可以访问 C# 和 LibTiff.Net,但即使在阅读文档后,我仍然对如何在不更改标头信息的情况下简单地替换图像数据感到困惑。
目前的想法只是简单地将图像替换为纯色,因此并不太复杂。
I have a program that takes in stacks of TIFF images and is very particular about the header data (it expects all headers to be the same), however I want to edit a couple of the images in the stack before sending it to this program.
Every program I've tried so far (Paint.net, MS Paint, ImageJ) has altered the header file or outright corrupted it when it saves the new images. I have access to C# and LibTiff.Net but even after reading the documents I'm confused as to how to simply replace the image data without changing the header information at all.
Currently the idea is simply to replace an image with a solid colour, so it isn't too complicated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我将如何解决这个问题。
检查 TIFF 文档以找出实际位图数据的存储位置。 (我相信它是一种结构化格式,因此它不会每次都位于同一位置,尽管如果所有标头都相同,则可能会出现这种情况。)
识别数据后,您可以提取它或将其替换为相同尺寸和格式的原始位图数据。
例如,您可以从具有更改的标头的 TIFF 文件中提取位图数据,并覆盖具有良好标头的文件中的数据。
这是相当低的水平,但应该可以工作。
或者,您可以读入已编辑的文件,并以正确的格式写回带有您自己的标题的 TIFF 文件。可能或多或少有些困难。
Here's how I would go about this.
Check TIFF documentation to find out where the actual bitmap data is stored. (I believe it is a structured format so it won't be at the same place every time, although it could be if all your headers are the same.)
Once you've identified the data, you can extract it or replace it with raw bitmap data of the same dimensions and format.
For example, you could extract the bitmap data from the TIFF file with the changed headers and overwrite the data in a file with a good header.
It's pretty low level, but it should work.
Alternatively, you could read-in the edited files and write back out a TIFF file with your own headers in the correct format. Might be more or less difficult.