简体   繁体   中英

Convert DICOM to PNG using dicom2.exe

I am currently trying to convert DICOM files to PNG files using a command line program named dicom2 .

Below is the code from a .NET toy application that I wrote to test its conversion functionality. It attempts to run dicom2 from within a C# console application:

public static void Main(string[] args)
{
    StartDicom2();
    Console.ReadLine();
}

private static void StartDicom2()
{
    string fileName = @"E:\Temp\Projects\FYP\SCE11-0353\Uploads\dicom2.exe";
    string commandLineArguments = @"-p *.dcm";

    ProcessStartInfo info = new ProcessStartInfo();
    info.CreateNoWindow = false;
    info.UseShellExecute = false;
    info.FileName = fileName;
    info.Arguments = commandLineArguments;

    try
    {
        Process dicom2 = Process.Start(info);
        dicom2.WaitForExit();
    }
    catch(Exception e)
    {
        Console.WriteLine(e.ToString());
    }
}

Now for some reason dicom2 does not start execution at all.

Upon debugging, it was discovered that a System.InvalidOperationException was thrown. Not sure whether it came from dicom2 or something else.

Continued exploring about and found an isolated PNG file in the \\bin folder of the project.

Apparently the program works like a charm, just that I did not look hard enough.

To make sure that dicom2 works in a specific directory, use the following line of code:

info.WorkingDirectory = @"E:\Temp\Projects\FYP\SCE11-0353\Uploads";

All converted images will appear in the specified folder. Replace the paths to whichever is convenient for you.

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