当前位置: 首页>>代码示例>>C#>>正文


C# DicomFile.Save方法代码示例

本文整理汇总了C#中DicomFile.Save方法的典型用法代码示例。如果您正苦于以下问题:C# DicomFile.Save方法的具体用法?C# DicomFile.Save怎么用?C# DicomFile.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DicomFile的用法示例。


在下文中一共展示了DicomFile.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteOptionsTest

        public void WriteOptionsTest(DicomFile sourceFile, DicomWriteOptions options)
        {
            bool result = sourceFile.Save(options);

            Assert.AreEqual(result, true);

            DicomFile newFile = new DicomFile(sourceFile.Filename);

            DicomReadOptions readOptions = DicomReadOptions.Default;
            newFile.Load(readOptions);

            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);

            // update a tag, and make sure it shows they're different
            newFile.DataSet[DicomTags.PatientsName].Values = "NewPatient^First";
            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), false);

            // Now update the original file with the name, and they should be the same again
            sourceFile.DataSet[DicomTags.PatientsName].Values = "NewPatient^First";
            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);

            // Return the original string value.
            sourceFile.DataSet[DicomTags.PatientsName].SetStringValue("Patient^Test");

        }
开发者ID:scottshea,项目名称:monodicom,代码行数:25,代码来源:FileTest.cs

示例2: LosslessImageTest

		public static void LosslessImageTest(TransferSyntax syntax, DicomFile theFile)
		{
			if (File.Exists(theFile.Filename))
				File.Delete(theFile.Filename);

			DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

			theFile.ChangeTransferSyntax(syntax);

			theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

			DicomFile newFile = new DicomFile(theFile.Filename);

			newFile.Load(DicomReadOptions.Default);

			newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

			List<DicomAttributeComparisonResult> list = new List<DicomAttributeComparisonResult>();
			bool result = newFile.DataSet.Equals(saveCopy.DataSet, ref list);

			StringBuilder sb = new StringBuilder();
			foreach (DicomAttributeComparisonResult compareResult in list)
				sb.AppendFormat("Comparison Failure: {0}, ", compareResult.Details);

			Assert.IsTrue(result,sb.ToString());
		}
开发者ID:scottshea,项目名称:monodicom,代码行数:26,代码来源:AbstractCodecTest.cs

示例3: TestFile

        public void TestFile()
        {
            string filename = "OutOfRange.dcm";

            DicomFile file = new DicomFile(filename, new DicomAttributeCollection(), new DicomAttributeCollection());
            SetupMR(file.DataSet);
            SetupMetaInfo(file);

            DicomTag tag = new DicomTag(0x00030010, "Test", "TestBad", DicomVr.LOvr, false, 1, 1, false);

            file.DataSet[tag].SetStringValue("Test");

            file.Save(filename);

            file = new DicomFile(filename);

            file.DataSet.IgnoreOutOfRangeTags = true;

            file.Load();

            Assert.IsNotNull(file.DataSet.GetAttribute(tag));

            file = new DicomFile(filename);

            file.DataSet.IgnoreOutOfRangeTags = false;

            try
            {
                file.Load();
                Assert.Fail("file.Load failed");
            }
            catch (DicomException)
            {
            }
        }
开发者ID:khaha2210,项目名称:radio,代码行数:35,代码来源:AttributeCollectionTest.cs

示例4: ReadOptionsTest

        public void ReadOptionsTest(DicomFile sourceFile, DicomReadOptions options, bool areEqual)
        {
            bool result = sourceFile.Save(DicomWriteOptions.Default);

            Assert.AreEqual(result, true);

            DicomFile newFile = new DicomFile(sourceFile.Filename);

            newFile.Load(options);

            if (areEqual)
                Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);
            else
                Assert.AreNotEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:15,代码来源:FileTest.cs

示例5: CreateCStoreReceiveStream

        /// <summary>
        /// The purpose of this method is to return the Stream that a SopInstance received
        /// via CStoreSCP will be written to.  This default implementation creates a temporary
        /// file and returns a FileStream on top of it.  Child classes can override this to write
        /// to another stream and avoid the I/O associated with the temporary file if so desired.
        /// Beware that some SopInstances can be very large so using a MemoryStream() could cause
        /// out of memory situations.
        /// </summary>
        /// <param name="file">A DicomFile with FileMetaInfo populated</param>
        /// <returns>The stream to write the SopInstance to</returns>
        protected virtual Stream CreateCStoreReceiveStream(DicomFile file)
        {
            var fileName = TemporaryFile.Create();

            file.Save(fileName);

            var dimseStream = File.Open(fileName, FileMode.Open, FileAccess.ReadWrite);
            _isTempFile = true;
            dimseStream.Seek(0, SeekOrigin.End);
            return dimseStream;
        }
开发者ID:dremerdt,项目名称:fo-dicom,代码行数:21,代码来源:DicomService.cs

示例6: RleOverlayTest

        public void RleOverlayTest()
        {
            DicomFile file = new DicomFile("RleCodecOverlayTest.dcm");

            SetupMRWithOverlay(file.DataSet);

            SetupMetaInfo(file);

            // Save a copy
            file.Save();


            // Load the file into new DicomFile object
            DicomFile newFile = new DicomFile(file.Filename);

            newFile.Load();

            OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(newFile.DataSet);
            OverlayPlane overlay = overlayIod[0];
            
            // SHould be no OverlayData tag
            Assert.IsNull(overlay.OverlayData, "Overlay should be in pixel data");

            // Overlay should be extracted out of pixel data here
            newFile.ChangeTransferSyntax(TransferSyntax.RleLossless);

            Assert.IsNotNull(overlay.OverlayData,"Overlay Data is not null");

            newFile.Save();

            // Load a new copy
            newFile = new DicomFile(file.Filename);

            newFile.Load();

            newFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);

            newFile.Filename = "Output" + file.Filename;
            newFile.Save();

            List<DicomAttributeComparisonResult> results = new List<DicomAttributeComparisonResult>();
            bool compare = file.DataSet.Equals(newFile.DataSet, ref results);

            // Shouldn't be the same, OverlayData tag should have been added
            Assert.IsFalse(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty);                      
        }
开发者ID:nhannd,项目名称:Xian,代码行数:46,代码来源:CodecTest.cs

示例7: LossyImageTest

		public static void LossyImageTest(TransferSyntax syntax, DicomFile theFile)
		{
			if (File.Exists(theFile.Filename))
				File.Delete(theFile.Filename);

			DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

			theFile.ChangeTransferSyntax(syntax);

			theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

			DicomFile newFile = new DicomFile(theFile.Filename);

			newFile.Load(DicomReadOptions.Default);

			newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

			Assert.IsFalse(newFile.DataSet.Equals(saveCopy.DataSet));

			Assert.IsTrue(newFile.DataSet.Contains(DicomTags.DerivationDescription));
			Assert.IsTrue(newFile.DataSet.Contains(DicomTags.LossyImageCompression));
			Assert.IsTrue(newFile.DataSet.Contains(DicomTags.LossyImageCompressionMethod));
			Assert.IsTrue(newFile.DataSet.Contains(DicomTags.LossyImageCompressionRatio));

			Assert.IsFalse(newFile.DataSet[DicomTags.DerivationDescription].IsEmpty);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompression].IsEmpty);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompressionMethod].IsEmpty);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompressionRatio].IsEmpty);

			Assert.IsFalse(newFile.DataSet[DicomTags.DerivationDescription].IsNull);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompression].IsNull);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompressionMethod].IsNull);
			Assert.IsFalse(newFile.DataSet[DicomTags.LossyImageCompressionRatio].IsNull);

			// Make copies of datasets, delete the tags that don't match, and ensure the same
			DicomAttributeCollection newDataSet = newFile.DataSet.Copy(true, true, true);
			DicomAttributeCollection oldDataSet = theFile.DataSet.Copy(true, true, true);

			oldDataSet.RemoveAttribute(DicomTags.PixelData);
			newDataSet.RemoveAttribute(DicomTags.PixelData);
			oldDataSet.RemoveAttribute(DicomTags.DerivationDescription);
			newDataSet.RemoveAttribute(DicomTags.DerivationDescription);
			oldDataSet.RemoveAttribute(DicomTags.LossyImageCompression);
			newDataSet.RemoveAttribute(DicomTags.LossyImageCompression);
			oldDataSet.RemoveAttribute(DicomTags.LossyImageCompressionMethod);
			newDataSet.RemoveAttribute(DicomTags.LossyImageCompressionMethod);
			oldDataSet.RemoveAttribute(DicomTags.LossyImageCompressionRatio);
			newDataSet.RemoveAttribute(DicomTags.LossyImageCompressionRatio);
			oldDataSet.RemoveAttribute(DicomTags.PhotometricInterpretation);
			newDataSet.RemoveAttribute(DicomTags.PhotometricInterpretation);

			List<DicomAttributeComparisonResult> results = new List<DicomAttributeComparisonResult>();

			bool check = oldDataSet.Equals(newDataSet, ref results);
			Assert.IsTrue(check, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty);
		}
开发者ID:khaha2210,项目名称:radio,代码行数:56,代码来源:AbstractCodecTest.cs

示例8: StorageScuFromDisk

        public void StorageScuFromDisk()
        {
            int port = 2112;

            _serverHandlerList.Clear();

            /* Setup the Server */
            var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port));
            byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage);
            serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian);
            serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian);
            serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian);

            _serverType = TestTypes.Receive;
            DicomServer.StartListening(serverParameters, ServerHandlerCreator);

            StorageScu scu = SetupScu();

            IList<DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID);

            foreach (DicomAttributeCollection collection in list)
            {
                var file = new DicomFile("test", new DicomAttributeCollection(), collection)
                {
                    TransferSyntax = TransferSyntax.ExplicitVrLittleEndian,
                    MediaStorageSopClassUid = SopClass.MrImageStorage.Uid,
                    MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString()
                };

				string instancePath = file.MediaStorageSopInstanceUid + ".dcm";

	            file.Save(instancePath);

				var instance = new StorageInstance(instancePath)
					{
						SopClass = file.SopClass,
						TransferSyntax = file.TransferSyntax,
						SopInstanceUid = file.MediaStorageSopClassUid,
						PatientId = file.DataSet[DicomTags.PatientId].GetString(0, string.Empty),
						PatientsName = file.DataSet[DicomTags.PatientsName].GetString(0, string.Empty),
						StudyInstanceUid = file.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty)
					};

	            scu.AddStorageInstance(instance);
            }

            scu.Send();
            scu.Join();

            Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning);

            var handler = CollectionUtils.FirstElement(_serverHandlerList);
            var serverHandler = handler as ServerHandler;

            Assert.NotNull(serverHandler);

            foreach (var message in serverHandler.MessagesReceived)
            {
				foreach (var file in list)
				{
					if (message.AffectedSopInstanceUid.Equals(file[DicomTags.SopInstanceUid].ToString()))
					{
						Assert.IsTrue(message.DataSet.Equals(file));
					}
				}
            }

            // StopListening
            DicomServer.StopListening(serverParameters);
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:70,代码来源:ScuTests.cs

示例9: PartialFrameTest

        public void PartialFrameTest()
        {
            DicomFile file = new DicomFile("RlePartialFrameTest.dcm");

            SetupMultiframeXA(file.DataSet, 511, 511, 7);

            file.ChangeTransferSyntax(TransferSyntax.RleLossless);

            file.Save();

            DicomFile newFile = new DicomFile(file.Filename);

            newFile.Load(DicomReadOptions.StorePixelDataReferences);

            DicomPixelData pd;

            if (!newFile.TransferSyntax.Encapsulated)
                pd = new DicomUncompressedPixelData(newFile);
            else if (newFile.TransferSyntax.Equals(TransferSyntax.RleLossless))
                pd = new DicomCompressedPixelData(newFile);
            else
                throw new DicomCodecException("Unsupported transfer syntax: " + newFile.TransferSyntax);

            for (int i=0; i< pd.NumberOfFrames; i++)
            {
                pd.GetFrame(i);
            }
        }
开发者ID:nhannd,项目名称:Xian,代码行数:28,代码来源:CodecTest.cs

示例10: ReadPixelDataReferencesTest

		public void ReadPixelDataReferencesTest()
		{
			DicomFile file = new DicomFile("LittleEndianReadFileTest2.dcm");

			DicomAttributeCollection dataSet = file.DataSet;

			SetupMR(dataSet);

			SetupMetaInfo(file);

			// Little Endian Tests
			file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;

			DicomReadOptions readOptions = DicomReadOptions.StorePixelDataReferences;
			bool result = file.Save(DicomWriteOptions.Default);

			Assert.AreEqual(result, true);

			DicomFile newFile = new DicomFile(file.Filename);

			newFile.Load(readOptions);

			DicomAttribute attrib = newFile.DataSet[DicomTags.PixelData];

			Assert.IsFalse(attrib.IsEmpty);
			Assert.IsFalse(attrib.IsNull);
			Assert.AreEqual(attrib.StreamLength, dataSet[DicomTags.PixelData].StreamLength);

			// Set the pixel data to null and re-read
			dataSet[DicomTags.PixelData].SetNullValue();
			
			result = file.Save(DicomWriteOptions.Default);
			Assert.AreEqual(result, true);

			newFile = new DicomFile(file.Filename);

			newFile.Load(readOptions);

			attrib = newFile.DataSet[DicomTags.PixelData];

			Assert.IsFalse(attrib.IsEmpty);
			Assert.IsTrue(attrib.IsNull);
			Assert.AreEqual(attrib.StreamLength, dataSet[DicomTags.PixelData].StreamLength);
		}
开发者ID:scottshea,项目名称:monodicom,代码行数:44,代码来源:FileTest.cs

示例11: ProcessPDataTF

		private void ProcessPDataTF(object state) {
			var pdu = (PDataTF)state;
			try {
				foreach (var pdv in pdu.PDVs) {
					if (_dimse == null) {
						// create stream for receiving command
						if (_dimseStream == null)
							_dimseStream = new MemoryStream();
					} else {
						// create stream for receiving dataset
						if (_dimseStream == null) {
							if (_dimse.Type == DicomCommandField.CStoreRequest) {
								var pc = Association.PresentationContexts.FirstOrDefault(x => x.ID == pdv.PCID);

								var file = new DicomFile();
								file.FileMetaInfo.MediaStorageSOPClassUID = pc.AbstractSyntax;
								file.FileMetaInfo.MediaStorageSOPInstanceUID = _dimse.Command.Get<DicomUID>(DicomTag.AffectedSOPInstanceUID);
								file.FileMetaInfo.TransferSyntax = pc.AcceptedTransferSyntax;
								file.FileMetaInfo.ImplementationClassUID = Association.RemoteImplemetationClassUID;
								file.FileMetaInfo.ImplementationVersionName = Association.RemoteImplementationVersion;
								file.FileMetaInfo.SourceApplicationEntityTitle = Association.CallingAE;

								var fileName = TemporaryFile.Create();

								file.Save(fileName);

								_dimseStream = File.OpenWrite(fileName);
								_dimseStream.Seek(0, SeekOrigin.End);
							} else {
								_dimseStream = new MemoryStream();
							}
						}
					}

					_dimseStream.Write(pdv.Value, 0, pdv.Value.Length);

					if (pdv.IsLastFragment) {
						if (pdv.IsCommand) {
							_dimseStream.Seek(0, SeekOrigin.Begin);

							var command = new DicomDataset();

							var reader = new DicomReader();
							reader.IsExplicitVR = false;
							reader.Read(new StreamByteSource(_dimseStream), new DicomDatasetReaderObserver(command));

							_dimseStream = null;

							var type = command.Get<DicomCommandField>(DicomTag.CommandField);
							switch (type) {
							case DicomCommandField.CStoreRequest:
								_dimse = new DicomCStoreRequest(command);
								break;
							case DicomCommandField.CStoreResponse:
								_dimse = new DicomCStoreResponse(command);
								break;
							case DicomCommandField.CFindRequest:
								_dimse = new DicomCFindRequest(command);
								break;
							case DicomCommandField.CFindResponse:
								_dimse = new DicomCFindResponse(command);
								break;
							case DicomCommandField.CMoveRequest:
								_dimse = new DicomCMoveRequest(command);
								break;
							case DicomCommandField.CMoveResponse:
								_dimse = new DicomCMoveResponse(command);
								break;
							case DicomCommandField.CEchoRequest:
								_dimse = new DicomCEchoRequest(command);
								break;
							case DicomCommandField.CEchoResponse:
								_dimse = new DicomCEchoResponse(command);
								break;
							case DicomCommandField.NActionRequest:
								_dimse = new DicomNActionRequest(command);
								break;
							case DicomCommandField.NActionResponse:
								_dimse = new DicomNActionResponse(command);
								break;
							case DicomCommandField.NCreateRequest:
								_dimse = new DicomNCreateRequest(command);
								break;
							case DicomCommandField.NCreateResponse:
								_dimse = new DicomNCreateResponse(command);
								break;
							case DicomCommandField.NDeleteRequest:
								_dimse = new DicomNDeleteRequest(command);
								break;
							case DicomCommandField.NDeleteResponse:
								_dimse = new DicomNDeleteResponse(command);
								break;
							case DicomCommandField.NEventReportRequest:
								_dimse = new DicomNEventReportRequest(command);
								break;
							case DicomCommandField.NEventReportResponse:
								_dimse = new DicomNEventReportResponse(command);
								break;
							case DicomCommandField.NGetRequest:
								_dimse = new DicomNGetRequest(command);
//.........这里部分代码省略.........
开发者ID:jinyda,项目名称:fo-dicom,代码行数:101,代码来源:DicomService.cs

示例12: Print

        public void Print(IList<FilmBox> filmBoxList)
        {
            try
            {
                Status = PrintJobStatus.Pending;

                OnStatusUpdate("Preparing films for printing");

                var printJobDir = new System.IO.DirectoryInfo(FullPrintJobFolder);
                if (!printJobDir.Exists)
                {
                    printJobDir.Create();
                }

                DicomFile file;
                int filmsCount = FilmBoxFolderList.Count;
                for (int i = 0; i < filmBoxList.Count; i++)
                {
                    var filmBox = filmBoxList[i];
                    var filmBoxDir = printJobDir.CreateSubdirectory(string.Format("F{0:000000}", i + 1 + filmsCount));

                    file = new DicomFile(filmBox.FilmSession);
                    file.Save(string.Format(@"{0}\FilmSession.dcm", filmBoxDir.FullName));

                    FilmBoxFolderList.Add(filmBoxDir.Name);
                    filmBox.Save(filmBoxDir.FullName);
                }

                FilmSessionLabel = filmBoxList.First().FilmSession.FilmSessionLabel;

                var thread = new Thread(new ThreadStart(DoPrint));
                thread.Name = string.Format("PrintJob {0}", SOPInstanceUID.UID);
                thread.IsBackground = true;
                thread.Start();
            }
            catch (Exception ex)
            {
                Error = ex;
                Status = PrintJobStatus.Failure;
                OnStatusUpdate("Print failed");
                DeletePrintFolder();
            }
        }
开发者ID:fo-dicom,项目名称:fo-dicom-samples,代码行数:43,代码来源:PrintJob.cs

示例13: Save

        /// <summary>
        /// Save the image box contents to file.
        /// </summary>
        /// <param name="imageBoxFile">Name of the image box file.</param>
        public void Save(string imageBoxFile)
        {
            var imageBoxDicomFile = imageBoxFile + ".dcm";
            var imageBoxTextFile = imageBoxFile + ".txt";

            using (var stream = IOManager.CreateFileReference(imageBoxTextFile).Create())
            using (var writer = new StreamWriter(stream))
            {
                writer.Write(this.WriteToString());
            }

            var file = new DicomFile(this);
            file.Save(imageBoxDicomFile);
        }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:18,代码来源:ImageBox.cs

示例14: LosslessImageTestWithBitsAllocatedConversion

        public static void LosslessImageTestWithBitsAllocatedConversion(TransferSyntax syntax, DicomFile theFile)
        {
            if (File.Exists(theFile.Filename))
                File.Delete(theFile.Filename);

            DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

            theFile.ChangeTransferSyntax(syntax);

            theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

            DicomFile newFile = new DicomFile(theFile.Filename);

            newFile.Load(DicomReadOptions.Default);

            newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

            string failureDescription;
            var newPd = DicomPixelData.CreateFrom(newFile);
            var oldPd = DicomPixelData.CreateFrom(saveCopy);

            bool result = Compare(newPd, oldPd, out failureDescription);
            Assert.IsFalse(result, failureDescription);

            Assert.IsFalse(newFile.DataSet.Equals(saveCopy.DataSet));

            DicomAttributeCollection newDataSet = newFile.DataSet.Copy(true, true, true);
            DicomAttributeCollection oldDataSet = theFile.DataSet.Copy(true, true, true);

            oldDataSet.RemoveAttribute(DicomTags.BitsAllocated);
            newDataSet.RemoveAttribute(DicomTags.BitsAllocated);
            oldDataSet.RemoveAttribute(DicomTags.PixelData);
            newDataSet.RemoveAttribute(DicomTags.PixelData);

            var results = new List<DicomAttributeComparisonResult>();

            bool check = oldDataSet.Equals(newDataSet, ref results);
            Assert.IsTrue(check, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty);

            for (int i = 0; i < oldPd.NumberOfFrames; i++)
            {
                var frame = oldPd.GetFrame(i);
                var convertedFrame = DicomUncompressedPixelData.ToggleBitDepth(frame, frame.Length,
                                                                              oldPd.UncompressedFrameSize,
                                                                              oldPd.BitsStored, oldPd.BitsAllocated);
                var newFrame = newPd.GetFrame(i);

                int pixelsVarying = 0;
                decimal totalVariation = 0.0m;
                for (int j = 0; j < convertedFrame.Length; j++)
                    if (convertedFrame[j] != newFrame[j])
                    {
                        pixelsVarying++;
                        totalVariation += Math.Abs(convertedFrame[i] - newFrame[i]);
                    }

                if (pixelsVarying > 0)
                {
                    Assert.Fail(String.Format(
                        "Tag (7fe0,0010) Pixel Data: {0} of {1} pixels varying, average difference: {2}",
                        pixelsVarying, convertedFrame.Length, totalVariation/pixelsVarying));
                }
            }
        }
开发者ID:nhannd,项目名称:Xian,代码行数:64,代码来源:AbstractCodecTest.cs

示例15: LosslessImageTestWithConversion

		public static void LosslessImageTestWithConversion(TransferSyntax syntax, DicomFile theFile)
		{
			if (File.Exists(theFile.Filename))
				File.Delete(theFile.Filename);

			DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

			theFile.ChangeTransferSyntax(syntax);

			theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

			DicomFile newFile = new DicomFile(theFile.Filename);

			newFile.Load(DicomReadOptions.Default);

			newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

            string failureDescription;
            bool result = Compare(DicomPixelData.CreateFrom(newFile),
                                  DicomPixelData.CreateFrom(saveCopy), out failureDescription);
            Assert.IsTrue(result, failureDescription);

			Assert.IsFalse(newFile.DataSet.Equals(saveCopy.DataSet));
		}
开发者ID:nhannd,项目名称:Xian,代码行数:24,代码来源:AbstractCodecTest.cs


注:本文中的DicomFile.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。