DCM文件未正确压缩。 [英] DCM file not compressing properly.

查看:158
本文介绍了DCM文件未正确压缩。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用GDCM工具压缩dicom图像,但图像未正确压缩。我发布了示例代码。



我尝试过:



我的代码如下:

string inputFileNamepath = @G:\Test \ Test_07_06_2016 \Source\CT-MONO2-16-ankle.dcm;

string outputFileNamepath = @G:\Test \ Test_07_06_2016 \ Source1 \\\\\\\\\\\\\\\\\\\\\\\,,,,,, file = new FileInfo(@G:\Test \ Test_07_06_2016 \ Source \ BU001015MN-166-CL-001V01_2005101414120923_1_1.dcm);



字符串扩展名= Path.GetExtension(inputFileNamepath);

inputFileName = Path.GetFileName(inputFileNamepath);



outputFileName = Path.GetFileName(outputFileNamepath);



试试

{

gdcm.ImageReader reader = new ImageReader();

reader.SetFileName(inputFileNamepath);

if(!reader.Read())

{

//System.Console.WriteLine(\"Could not read:+ filename) ;

MessageBox.Show(错误);

返回;

}





gdcm.File file = reader.GetFile();



gdcm.DataSet ds = file.GetDataSet();

gdcm.Image image = reader.GetImage();



ImageChangeTransferSyntax change = new ImageChangeTransferSyntax();

TransferSyntax targets = new TransferSyntax(TransferSyntax.TSType.JPEG2000Lossless);

change.SetTransferSyntax(targets);



JPEGCodec codec = new JPEGCodec( );



if(!codec.CanCode(targets))

{

/ / MessageBox.Show(WrongData);

//返回;

}

codec.SetLossless(false);

codec.SetQuality(90); //质量差!

change.SetUserCodec(codec); //指定用于ImageChangeTransferSyntax的编解码器



change.SetInput(图片);



bool b = change.Change();



if(!b)

{

MessageBox.Show( 无法更改Ttansfer语法);

//返回;

}



ImageWriter writer = new ImageWriter();

writer.SetImage((gdcm.Image)change.GetOutput());

writer.SetFile(reader.GetFile());

writer.SetFileName(outputFileNamepath);



if(!writer.Write())

{

MessageBox.Show(无法写);

}









}

catch(Exception ex )

{



}


I am compressing dicom images using GDCM Tool but image is not compressed properly. I am Posting the Sample Code.

What I have tried:

My code is as follow:
string inputFileNamepath = @"G:\Test\Test_07_06_2016\Source\CT-MONO2-16-ankle.dcm";
string outputFileNamepath = @"G:\Test\Test_07_06_2016\Source1\CT-MONO2-16-ankle.dcm";

//FileInfo file = new FileInfo(@"G:\Test\Test_07_06_2016\Source\BU001015MN-166-CL-001V01_2005101414120923_1_1.dcm");

string extension = Path.GetExtension(inputFileNamepath);
inputFileName = Path.GetFileName(inputFileNamepath);

outputFileName = Path.GetFileName(outputFileNamepath);

try
{
gdcm.ImageReader reader = new ImageReader();
reader.SetFileName(inputFileNamepath);
if (!reader.Read())
{
//System.Console.WriteLine("Could not read: " + filename);
MessageBox.Show("Error ");
return;
}


gdcm.File file = reader.GetFile();

gdcm.DataSet ds = file.GetDataSet();
gdcm.Image image = reader.GetImage();

ImageChangeTransferSyntax change = new ImageChangeTransferSyntax();
TransferSyntax targets = new TransferSyntax(TransferSyntax.TSType.JPEG2000Lossless);
change.SetTransferSyntax(targets);

JPEGCodec codec = new JPEGCodec();

if(!codec.CanCode(targets))
{
// MessageBox.Show("WrongData");
//return;
}
codec.SetLossless(false);
codec.SetQuality(90); // poor quality !
change.SetUserCodec(codec); // specify the codec to use to the ImageChangeTransferSyntax

change.SetInput(image);

bool b = change.Change();

if (!b)
{
MessageBox.Show("Can not change Ttansfer Syntax");
//return;
}

ImageWriter writer = new ImageWriter();
writer.SetImage((gdcm.Image)change.GetOutput());
writer.SetFile(reader.GetFile());
writer.SetFileName(outputFileNamepath);

if (!writer.Write())
{
MessageBox.Show("Could not write");
}




}
catch (Exception ex)
{

}

推荐答案

你将拥有与编写您正在使用的GDCM工具的人交谈。您发布的代码似乎没有问题。
You're going to have to talk to the people who wrote the "GDCM tool" you're using. There doesn't appear to be a problem with the code you posted.


这篇关于DCM文件未正确压缩。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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