C#:使用 Silverlight FJCore 库以 12 位精度解码 JPEG 图像?
在我的 C# Silverlight 应用程序中,我尝试使用 FJCore< 以压缩的 JPEG 传输语法解码 DICOM 图像/a> 类库。
DICOM 图像通常以 12 位精度压缩。当尝试使用原始 FJCore 源代码解码此类图像时,我收到一个异常,提示“不支持的编解码器类型”,因为在原始 FJCore 实现中,只有 SOF0(基线 DCT)和 SOF2(渐进 DCT)起始帧标记是支持。如果我更改实现以接受 SOF1 标记(扩展顺序 DCT)并以与 SOF0 帧相同的方式处理 SOF1 帧,则图像将被解码,但仅考虑 8 位。
使用修改后的 FJCore 库解码后,典型的 12 位精度图像现在看起来像这样:
理想情况下,图像应如下所示:
据我从FJCore实现中得知,图像精度记录在JpegFrame类中,但从未使用过。最初的 FJCore 实现似乎只完全支持 8 位精度的灰度图像。
我计划“不畏艰险”,尝试自己扩展 FJCore 以支持灰度图像的 12 位精度。但在此之前,我想我应该在 StackOverflow 中提出问题,看看以前是否有人遇到并解决过这个问题?在这种情况下,我会很高兴了解您如何解决问题。
非常感谢!
安德斯@Cureos
In my C# Silverlight application, I am trying to decode DICOM images in compressed JPEG transfer syntax, using the FJCore class library.
The DICOM images are normally compressed with 12-bit precision. When trying to decode such an image using the original FJCore source code, I get an exception saying "Unsupported codec type", because in the original FJCore implementation only SOF0 (Baseline DCT) and SOF2 (Progressive DCT) Start-of-Frame markers are supported. If I change the implementation to also accept the SOF1 marker (Extended Sequential DCT) and treat SOF1 frames the same way as SOF0 frames, the images are decoded, but only 8 bits are accounted for.
A typical 12-bit precision image now looks like this after decoding with the modified FJCore library:
Ideally, the image should look like this:
As far as I have been able to tell from the FJCore implementation, the image precision is recorded in the JpegFrame class, but it is never used. The original FJCore implementation seems to only fully support grayscale images with 8 bit precision.
I am planning to "take the bull by the horns" and try to extend FJCore myself to support 12-bit precision for grayscale images. But before I do, I thought I should pose the question here in StackOverflow to see if anyone has encountered and solved this problem before? In that case, I would be very happy to learn how you solved the problem.
Many thanks in advance!
Anders @ Cureos
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚更新了我自己的 JPEG 解码器来处理扩展模式,我需要更改的是逆 DCT。在更改代码之前,输出看起来与上面的示例图像类似。我一直存储来自熵解码的 16 位系数值,但我的 DCT 计算在进行数学计算时使用 16 位整数来保存临时值,从而破坏了较大的值。我更改了 DCT 代码以使用 32 位整数进行计算,这解决了问题。
I just updated my own JPEG decoder to handle the extended mode and what I needed to change was my inverse DCT. Before changing the code, the output looked similar to your sample image above. I have always stored 16-bit coefficient values from the entropy decode, but my DCT calculation was corrupting the larger values by using 16-bit integers to hold temporary values while doing the math. I changed the DCT code to use 32-bit integers for the calculations and that solved the problem.