Word中的TIF图像保存后再打开就模糊了

改论文的时候,好不容易把tif图按照期刊要求都改完了,保存了再打开一看,好家伙全变糊了。

原因:Word会自动压缩TIF图像。

解决办法:文件--选项--高级--不压缩文件中的图像。

 

 

  • 13
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
要使用libtiff保存tif格式的图像,可以使用以下代码: ```c++ #include "tiffio.h" #include <iostream> #include <opencv2/opencv.hpp> using namespace cv; using namespace std; void save_tiff(const string& filename, const Mat& image) { TIFF* tif = TIFFOpen(filename.c_str(), "w"); if (tif) { int width = image.cols; int height = image.rows; int channels = image.channels(); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, channels); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); for (int y = 0; y < height; y++) { TIFFWriteScanline(tif, (unsigned char*)image.ptr(y), y); } TIFFClose(tif); } } int main() { Mat image = imread("test.jpg"); if (image.empty()) { cout << "Failed to read image!" << endl; return -1; } // 旋转图像 Mat rotated = rotate(image, 45); // 保存tif格式 save_tiff("test.tif", rotated); // 读取并显示tif格式图像 Mat image_tif = imread("test.tif", IMREAD_ANYDEPTH | IMREAD_ANYCOLOR); if (image_tif.empty()) { cout << "Failed to read tiff image!" << endl; return -1; } imshow("TIF image", image_tif); waitKey(0); return 0; } ``` 这个例子,我们首先使用opencv读取一张jpg格式的图像,然后对它进行旋转,然后使用save_tiff函数保存tif格式的图像。在保存过程,我们使用了libtiff的函数来设置图像的各种属性,然后使用TIFFWriteScanline函数逐行写入图像数据。最后,我们再使用opencv读取保存tif格式图像并显示。 在读取tif格式图像时,需要使用IMREAD_ANYDEPTH和IMREAD_ANYCOLOR参数来读取图像的深度和颜色信息。如果不指定这些参数,则可能会导致图像显示不正确。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值