LAUREL BRIDGE

LaurelBridge.DCF.Examples.DicomDiff Namespace

DICOM Connectivity Framework V3.4
The DicomDiff example demonstates how to use DCF to programmatically find differences between DICOM datasets.
Classes

  ClassDescription
Public classProgram
Compare two Dicom datasets (given as input filenames) using the DicomComparer in the DCF library.
Examples

DicomDiff Sample Code
public class Program
{
    /// <summary>
    /// Main entry point for DicomDiff.
    /// </summary>
    /// <param name="args">command line arguments</param>
    public static void Main(string[] args)
    {
        if (args.Length == 2)
        {
            try
            {
                string path1 = args[0].Trim();
                string path2 = args[1].Trim();

                Console.WriteLine("File1: {0}", path1);
                Console.WriteLine("File2: {0}", path2);

                using (DicomFileInput dfi1 = new DicomFileInput(path1))
                {
                    DicomDataSet ds1 = dfi1.ReadDataSet();
                    using (DicomFileInput dfi2 = new DicomFileInput(path2))
                    {
                        DicomDataSet ds2 = dfi2.ReadDataSet();
                        DifferenceFlags flags = DifferenceFlags.Recurse | DifferenceFlags.VrTrim;
                        foreach (IDicomDifference diff in new DicomComparer(flags).GetDifferences(ds1, ds2))
                            Console.WriteLine(diff);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem comparing datasets: {0}", e);
            }
        }
        else
        {
            Console.WriteLine("Usage: DicomDiff file1.dcm file2.dcm");
        }

        if (System.Diagnostics.Debugger.IsAttached)
        {
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }
    }