做的libjpeg和.Net JPEG codeC真的在单色数据显著有什么不同? [英] Do the libjpeg and the .Net jpeg codec really differ significantly on monochrome data?

查看:233
本文介绍了做的libjpeg和.Net JPEG codeC真的在单色数据显著有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作有很多黑白图像数据,今天早上我注意到,有似乎是这样的libjpeg和.Net JPEG codeC处理单色数据之间的差异显著。看来,单色图像保存在任何质量设置使用的libjpeg并开通使用默认的.Net JPEG codeC实际上只是负载,16种不同的灰色色调和所有中间色调呈现为点画。

下面是保存的libjpeg和加载的平滑渐变的直方图.NET

直方图应该已经完全水平

这里是一个什么样的梯度看起来像(放大)样品(这应该是一个完美的平滑过渡)

这应该是在左边的灰色右侧136,但只有4灰色阴影其实都是呈现作出这样的转变。<​​/ P>灰85的平稳过渡

我的问题是我是疯了,如果不多远,这是否codeC的差异去了?有没有,如果你在不同程序中使用这两个库一个好的解决办法?

我不责怪任何codeC,只是指出这似乎是一个矛盾。我注意到这个与图片我就知道使用的libjpeg创建,认为这是一个质量设置问题,请使用faststone图像缩放来创建测试图像尝试,得到了相同的结果,利用IrfanView的尝试,并再次得到了同样的结果。由于这两个方案都必须使用一些JPEG库我倾向于他们也使用libjpeg的,并有一个真正的codeC冲突承担。

在负载侧我遇到了同样的结果加载图像,无论我自己的.NET code和使用Paint.net。

最后,这是正常分辨率的样本,所以你可以下载它,并自己尝试一下。加载在某些程序会给你一个漂亮的渐变(如浏览器),但你自己的.NET code加载它,或Paint.Net会给你像上面呈现的抖动梯度只用16级灰度。

有谁知道更多关于这一点,有多远去,可能是有什么好的解决方法?

解决方案

我能够在涂料中捆绑Windows 7的版本打开你的样本图像重现你的症状文件分析表明它是一个有效的JPEG,并让它正确显示在浏览器中证实了这一点。它看起来像微软真的搞砸了不好。它已经提交一个bug:

<一个href="https://connect.microsoft.com/VisualStudio/feedback/details/597657/grayscale-jpeg-image-read-as-format8bppindexed-but-quantized-as-format4bppindexed#details" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/details/597657/grayscale-jpeg-image-read-as-format8bppindexed-but-quantized-as-format4bppindexed#details

<一个href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9132e2bd-23cc-4e5a-a783-1fa4abe11624/" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9132e2bd-23cc-4e5a-a783-1fa4abe11624/

解决方法是创建您的JPEG作为一个全彩色图像,但只有把灰度像素值进去。

I work with a lot of monochrome image data and this morning I noticed that there appears to be a significant difference between the way libjpeg and the .Net jpeg codec handle monochrome data. It appears that a monochrome image saved at ANY quality setting using libjpeg and opened using the default .Net jpeg codec actually only loads with 16 different shades of gray and all intermediate shades are rendered as stippled.

Here is the histogram of a smooth gradient saved by libjpeg and loaded by .net

The histogram should have been perfectly level.

And here is a (zoomed in) sample of what that gradient looks like (it should a be perfectly smooth transition)

This should be a smooth transition from gray 85 on the left to gray 136 on the right but only 4 shades of gray are actually rendered to make that transition.

My question is am I crazy and if not just how far does this codec discrepancy go? Is there a good workaround if you are using both libraries in different programs?

I am not blaming either codec, just pointing out what appears to be a discrepancy. I noticed this with images I knew were created using libjpeg, assumed it was a quality setting issue, tried using faststone image resizer to create test images and got the same result, tried using irfanview and got the same result again. As both of those programs must use some jpeg library I tend to assume they are also using libjpeg and there is a genuine codec conflict.

On the loading side I have run into the same result loading images with both my own .net code and using Paint.net.

Finally, here is a sample at normal resolution so you can download it and try it yourself. Loading it in some programs will give you a nice gradient (e.g. your browser) but loading it with your own .Net code, or Paint.Net will give you a dithered gradient like the above rendered using only 16 shades of gray.

Does anyone know more about this, how far it goes and what good workarounds might be?

解决方案

I am able to reproduce your symptoms by opening your sample image in the version of Paint bundled with Windows 7. Analyzing the file shows it to be a valid JPEG, and having it show up properly in the browser confirms this. It looks like Microsoft really messed up bad. It has already been submitted as a bug:

https://connect.microsoft.com/VisualStudio/feedback/details/597657/grayscale-jpeg-image-read-as-format8bppindexed-but-quantized-as-format4bppindexed#details

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9132e2bd-23cc-4e5a-a783-1fa4abe11624/

The workaround would be to create your JPEG as a full color image, but only put grayscale pixel values into it.

这篇关于做的libjpeg和.Net JPEG codeC真的在单色数据显著有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆