简体   繁体   English

Emgucv打开tif 16bpp灰度文件,但将强度降低到8bpp

[英]Emgucv opens tif 16bpp greyscale file but scales intensity down to 8bpp

I am working in an application in C# winforms, which needs to process some images which are provided as 16bpp greyscale .tif files. 我正在使用C#winforms应用程序,该应用程序需要处理一些以16bpp灰度.tif文件提供的图像。 I am using emgucv to open the file and get the pixel array, but I found that actually the intensity of pixels is scaled down to 8bpp. 我正在使用emgucv打开文件并获取像素阵列,但是我发现实际上像素的强度已缩小到8bpp。

I used Gimp v2.10.10 to create a minimum example image that reproduces this. 我使用Gimp v2.10.10创建了一个最小的示例图像来重现此图像。 Using this code: 使用此代码:

string a = @"White.tif";

Image<Gray, UInt16> imgSinProcesar = new Image<Gray, UInt16>(a);

this.Text = "Color: " + imgSinProcesar.GetAverage().Intensity;

Link to the example file: https://drive.google.com/open?id=14UQ4efP8lnkwA3kg6XFMxan1OF_Skvoc The img I am using is full colored with 65535 intensity. 链接到示例文件: https ://drive.google.com/open ? id = 14UQ4efP8lnkwA3kg6XFMxan1OF_Skvoc我正在使用的img色彩完整,强度为65535。 However, the average calculated is 255, and I checked in debug that also each pixel has intensity 255. 但是,计算出的平均值为255,我在调试中检查了每个像素的强度也为255。

Is this a normal behavior? 这是正常现象吗? I really need the 16 bits precision to do the necessary task properly. 我确实需要16位精度才能正确完成必要的任务。

Thank you. 谢谢。

Think it is due to some auto conversion. 认为这是由于一些自动转换。 Try loading the image in this way. 尝试以这种方式加载图像。

CvInvoke.Imread(a, Emgu.CV.CvEnum.ImreadModes.AnyDepth);

This will return a Mat object, but if you need an Image object you can use .ToImage<Gray, UInt16>() . 这将返回Mat对象,但是如果需要Image对象,则可以使用.ToImage<Gray, UInt16>()

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

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