简体   繁体   English

将图像另存为未压缩的16位灰度TIFF文件

[英]Save image as uncompressed 16 bit greyscale TIFF file

It's my first time working with images and I'm trying to save in Image as 16 bit greyscale tiff file that should look like 1 from the attached picture. 这是我第一次使用图像,我试图将图像另存为16位灰度tiff文件,该文件应与所附图片中的图像相似。

I've tried using img.Save(".\\\\MyFile\\\\myImage.tif",ImageFormat.Tiff); 我已经尝试使用img.Save(".\\\\MyFile\\\\myImage.tif",ImageFormat.Tiff); but the result was 2 from attached picture. 但结果是所附图片中的2。

I've changed the save to 我将保存更改为

EncoderParameters eps = new EncoderParameters(2);
eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth,24L);
eps.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression,(long)EncoderValue.CompressionNone);

//var ei = GetEncoderInfo(ImageFormat.Tiff);
var ei = GetEncoderInfo("image/tiff");
img.Save(".\\MyFile\\myImage.tif", ei, eps);

and because color depth cannot be 16 I only managed to obtain the result 3 from attached picture. 而且由于色深不能为16,我只能设法从所附图片中获得结果3。 Is there a way to save the image as uncompressed 16 bit grayscale tiff file without using other libraries? 有没有一种方法可以在不使用其他库的情况下将图像另存为未压缩的16位灰度tiff文件?

图片

Use OpenCV like: 像这样使用OpenCV:

cv::Mat rawData( height_, width_, CV_16UC1, (void*)pPicData_);
cv::imwrite(fileName_.toStdString().c_str(), rawData);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM