C#:使用Silverlight FJCore库以12位精度解码JPEG图像吗? [英] C#: Decoding JPEG images with 12-bit precision using Silverlight FJCore library?

查看:125
本文介绍了C#:使用Silverlight FJCore库以12位精度解码JPEG图像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#Silverlight应用程序中,我尝试使用 FJCore 类库。

In my C# Silverlight application, I am trying to decode DICOM images in compressed JPEG transfer syntax, using the FJCore class library.

DICOM图像通常以12位精度进行压缩。当尝试使用原始FJCore源代码解码此类图像时,出现异常消息不支持的编解码器类型,因为在原始FJCore实现中,只有SOF0(基准DCT)和SOF2(渐进DCT)帧开始标记是支持的。如果我更改实现以也接受SOF1标记(扩展顺序DCT)并以与SOF0帧相同的方式对待SOF1帧,则将对图像进行解码,但仅占8位。

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.

使用修改后的FJCore库解码后,一个典型的12位精度图像现在看起来像这样:

A typical 12-bit precision image now looks like this after decoding with the modified FJCore library:

理想情况下,图像应看起来像这样:

Ideally, the image should look like this:

据我从FJCore实现中得知,图像精度记录在JpegFrame类中,但从未用过的。最初的FJCore实现似乎只完全支持8位精度的灰度图像。

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.

我打算忍受牛角,并尝试将FJCore自己扩展到支持灰度图像的12位精度。但是在我这样做之前,我想我应该在StackOverflow中提出这个问题,看看以前是否有人遇到过并解决过此问题?在那种情况下,我将很高兴了解您如何解决该问题。

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.

在此先感谢!

Anders @ Cureos

Many thanks in advance!
Anders @ Cureos

推荐答案

我刚刚更新了自己的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.

这篇关于C#:使用Silverlight FJCore库以12位精度解码JPEG图像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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