简体   繁体   中英

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. 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.

I used Gimp v2.10.10 to create a minimum example image that reproduces this. 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. However, the average calculated is 255, and I checked in debug that also each pixel has intensity 255.

Is this a normal behavior? I really need the 16 bits precision to do the necessary task properly.

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>() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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