Ejemplo n.º 1
0
        public static void RoundTripAndRender()
        {
            foreach (FileInfo fi in new DirectoryInfo("..\\CompressionSamples").GetFiles("*.dcm"))
            {
                Console.WriteLine("Compression Test -- Filename: " + fi.Name);

                DICOMData data = new DICOMData();
                data.ParseFile(fi.FullName, true, new NullLogger());
                TransferSyntax syntax = data.TransferSyntax;

                int compressedLength = (int)data[DICOMTags.PixelData].GetDataLength(false);

                data.Uncompress();

                Image testImage = DICOMQuickRenderer.QuickRender(data, 0);
                Assert.IsNotNull(testImage);

                int uncompressedLength = (int)data[DICOMTags.PixelData].GetDataLength(false);
                Assert.IsTrue(uncompressedLength > compressedLength);

                if (CompressionWorker.SupportsCompression(syntax.Compression))
                {
                    data.ChangeTransferSyntax(syntax);
                    int recompressedLength = (int)data[DICOMTags.PixelData].GetDataLength(false);
                    Assert.IsTrue(recompressedLength < uncompressedLength);
                }

                //data.WriteFile(fi.FullName.Replace(".dcm", "_un.dcm"));
            }
        }
Ejemplo n.º 2
0
        static void TestThumbnails()
        {
            foreach (FileInfo fi in new DirectoryInfo("..\\CompressionSamples").GetFiles("*.dcm"))
            //foreach (FileInfo fi in new DirectoryInfo("..\\CompressionSamples").GetFiles("JPEG-LS Lossless.dcm"))
            {
                Console.WriteLine("Compression Test -- Filename: " + fi.Name);

                DICOMData data = new DICOMData();
                data.ParseFile(fi.FullName, true, new NullLogger());
                //data.Uncompress();
                //data.WriteFile(fi.FullName.Replace(".dcm", "_un.dcm"));

                Image testImage = DICOMQuickRenderer.QuickRender(data, 0);

                testImage.Save(fi.FullName.Replace(".dcm", ".png"), ImageFormat.Png);
            }
        }