/// <summary> /// Update a <see cref="DicomAttributeCollection"/> with the pixel data contained /// within this object and also update pixel data related tags. /// </summary> /// <remarks> /// This method will replace the pixel data attribute in <paramref name="dataset"/> /// and update other pixel data related tags within the collection. /// </remarks> /// <param name="dataset">The collection to update.</param> public override void UpdateAttributeCollection(DicomAttributeCollection dataset) { dataset.SaveDicomFields(this); if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1) { dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames); } if (dataset.Contains(DicomTags.PlanarConfiguration)) { dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration); } if (dataset.Contains(DicomTags.LossyImageCompressionRatio)) { dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio); } if (dataset.Contains(DicomTags.LossyImageCompressionMethod)) { dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod); } if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) { dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope); } if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) { dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept); } if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0) { Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts); } dataset[DicomTags.PixelData] = _pd; //Remove the palette color lut, if the pixels were translated to RGB if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData) && dataset.Contains(DicomTags.BluePaletteColorLookupTableData) && dataset.Contains(DicomTags.GreenPaletteColorLookupTableData) && !HasPaletteColorLut) { dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData); } UpdatePixelDataAttribute(); }
/// <summary> /// Converts this object into a <see cref="DicomAttributeCollection"/>. /// </summary> public DicomAttributeCollection ToDicomAttributeCollection() { var attributes = new DicomAttributeCollection(); if (!string.IsNullOrEmpty(SpecificCharacterSet)) { attributes.SpecificCharacterSet = SpecificCharacterSet; } attributes[DicomTags.QueryRetrieveLevel].SetStringValue(QueryRetrieveLevel); attributes.SaveDicomFields(this); return(attributes); }
public void UpdateDataSet(DicomAttributeCollection dataset) { dataset.SaveDicomFields(this); if (IsColor) { dataset[DicomTags.PixelRepresentation].SetEmptyValue();; } else { dataset[DicomTags.PlanarConfiguration].SetEmptyValue();; } if (PixelSpacing.IsNull && ImagerPixelSpacing.IsNull) { dataset[DicomTags.PixelAspectRatio].SetStringValue(AspectRatio.ToString()); } if (!PixelSpacing.IsNull) { dataset[DicomTags.PixelSpacing].SetStringValue(PixelSpacing.ToString()); } else { dataset[DicomTags.PixelSpacing].SetEmptyValue(); } if (!ImagerPixelSpacing.IsNull) { dataset[DicomTags.ImagerPixelSpacing].SetStringValue(ImagerPixelSpacing.ToString()); } else { dataset[DicomTags.ImagerPixelSpacing].SetEmptyValue(); } }
/// <summary> /// Update a <see cref="DicomAttributeCollection"/> with the pixel data contained /// within this object and also update pixel data related tags. /// </summary> /// <remarks> /// This method will replace the pixel data attribute in <paramref name="dataset"/> /// and update other pixel data related tags within the collection. /// </remarks> /// <param name="dataset">The collection to update.</param> public override void UpdateAttributeCollection(DicomAttributeCollection dataset) { dataset.SaveDicomFields(this); if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1) dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames); if (dataset.Contains(DicomTags.PlanarConfiguration)) dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration); if (dataset.Contains(DicomTags.LossyImageCompressionRatio)) dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio); if (dataset.Contains(DicomTags.LossyImageCompressionMethod)) dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod); if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope); if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept); if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0) Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts); dataset[DicomTags.PixelData] = _pd; //Remove the palette color lut, if the pixels were translated to RGB if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData) && dataset.Contains(DicomTags.BluePaletteColorLookupTableData) && dataset.Contains(DicomTags.GreenPaletteColorLookupTableData) && !HasPaletteColorLut) { dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData); } UpdatePixelDataAttribute(); }
/// <summary> /// Update an <see cref="DicomAttributeCollection"/> with pixel data related tags. /// </summary> /// <param name="dataset">The collection to update.</param> public override void UpdateAttributeCollection(DicomAttributeCollection dataset) { if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1) { dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames); } if (dataset.Contains(DicomTags.PlanarConfiguration)) { dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration); } if (dataset.Contains(DicomTags.LossyImageCompression) || LossyImageCompression.Length > 0) { dataset[DicomTags.LossyImageCompression].SetString(0, LossyImageCompression); } if (dataset.Contains(DicomTags.LossyImageCompressionRatio) || (LossyImageCompressionRatio != 1.0f && LossyImageCompressionRatio != 0.0f)) { dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio); } if (dataset.Contains(DicomTags.LossyImageCompressionMethod) || LossyImageCompressionMethod.Length > 0) { dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod); } if (dataset.Contains(DicomTags.DerivationDescription) || DerivationDescription.Length > 0) { string currentValue = dataset[DicomTags.DerivationDescription].ToString(); dataset[DicomTags.DerivationDescription].SetStringValue(DerivationDescription); if (!currentValue.Equals(DerivationDescription)) { DicomSequenceItem item = new DicomSequenceItem(); CodeSequenceMacro macro = new CodeSequenceMacro(item); macro.CodeMeaning = "Lossy Compression"; macro.CodeValue = "113040"; macro.CodingSchemeDesignator = "DCM"; macro.ContextGroupVersion = new DateTime(2005, 8, 22); macro.ContextIdentifier = "7203"; macro.MappingResource = "DCMR"; dataset[DicomTags.DerivationCodeSequence].AddSequenceItem(item); } } if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) { dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope); } if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) { dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept); } if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0) { Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts); } //Remove the palette color lut, if the pixels were translated to RGB if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData) && dataset.Contains(DicomTags.BluePaletteColorLookupTableData) && dataset.Contains(DicomTags.GreenPaletteColorLookupTableData) && !HasPaletteColorLut) { dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData); } dataset.SaveDicomFields(this); dataset[DicomTags.PixelData] = _sq; }
public void UpdateDataSet(DicomAttributeCollection dataset) { dataset.SaveDicomFields(this); if (IsColor) { dataset[DicomTags.PixelRepresentation].SetEmptyValue(); ; } else { dataset[DicomTags.PlanarConfiguration].SetEmptyValue(); ; } if (PixelSpacing.IsNull && ImagerPixelSpacing.IsNull) dataset[DicomTags.PixelAspectRatio].SetStringValue(AspectRatio.ToString()); if (!PixelSpacing.IsNull) dataset[DicomTags.PixelSpacing].SetStringValue(PixelSpacing.ToString()); else dataset[DicomTags.PixelSpacing].SetEmptyValue(); if (!ImagerPixelSpacing.IsNull) dataset[DicomTags.ImagerPixelSpacing].SetStringValue(ImagerPixelSpacing.ToString()); else dataset[DicomTags.ImagerPixelSpacing].SetEmptyValue(); }
/// <summary> /// Update an <see cref="DicomAttributeCollection"/> with pixel data related tags. /// </summary> /// <param name="dataset">The collection to update.</param> public override void UpdateAttributeCollection(DicomAttributeCollection dataset) { if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1) dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames); if (dataset.Contains(DicomTags.PlanarConfiguration)) dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration); if (dataset.Contains(DicomTags.LossyImageCompression) || LossyImageCompression.Length > 0) dataset[DicomTags.LossyImageCompression].SetString(0, LossyImageCompression); if (dataset.Contains(DicomTags.LossyImageCompressionRatio) || (LossyImageCompressionRatio != 1.0f && LossyImageCompressionRatio != 0.0f)) dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio); if (dataset.Contains(DicomTags.LossyImageCompressionMethod) || LossyImageCompressionMethod.Length > 0) dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod); if (dataset.Contains(DicomTags.DerivationDescription) || DerivationDescription.Length > 0) { string currentValue = dataset[DicomTags.DerivationDescription].ToString(); dataset[DicomTags.DerivationDescription].SetStringValue(DerivationDescription); if (!currentValue.Equals(DerivationDescription)) { DicomSequenceItem item = new DicomSequenceItem(); CodeSequenceMacro macro = new CodeSequenceMacro(item); macro.CodeMeaning = "Lossy Compression"; macro.CodeValue = "113040"; macro.CodingSchemeDesignator = "DCM"; macro.ContextGroupVersion = new DateTime(2005,8,22); macro.ContextIdentifier = "7203"; macro.MappingResource = "DCMR"; dataset[DicomTags.DerivationCodeSequence].AddSequenceItem(item); } } if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope); if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept); if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0) Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts); //Remove the palette color lut, if the pixels were translated to RGB if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData) && dataset.Contains(DicomTags.BluePaletteColorLookupTableData) && dataset.Contains(DicomTags.GreenPaletteColorLookupTableData) && !HasPaletteColorLut) { dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData); } dataset.SaveDicomFields(this); dataset[DicomTags.PixelData] = _sq; }