本文整理汇总了C#中DicomDataset.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DicomDataset.Clone方法的具体用法?C# DicomDataset.Clone怎么用?C# DicomDataset.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomDataset
的用法示例。
在下文中一共展示了DicomDataset.Clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/// <summary>
/// Loads the pixel data for specified frame and set the internal dataset
///
/// </summary>
/// <param name="dataset">dataset to load pixeldata from</param>
/// <param name="frame">The frame number to create pixeldata for</param>
private void Load(DicomDataset dataset, int frame)
{
Dataset = dataset;
if (PixelData == null) {
PixelData = DicomPixelData.Create(Dataset);
PhotometricInterpretation = PixelData.PhotometricInterpretation;
}
if (Dataset.InternalTransferSyntax.IsEncapsulated) {
// decompress single frame from source dataset
DicomCodecParams cparams = null;
if (Dataset.InternalTransferSyntax == DicomTransferSyntax.JPEGProcess1 || Dataset.InternalTransferSyntax == DicomTransferSyntax.JPEGProcess2_4) {
cparams = new DicomJpegParams {
ConvertColorspaceToRGB = true
};
}
var transcoder = new DicomTranscoder(Dataset.InternalTransferSyntax, DicomTransferSyntax.ExplicitVRLittleEndian);
transcoder.InputCodecParams = cparams;
transcoder.OutputCodecParams = cparams;
var buffer = transcoder.DecodeFrame(Dataset, frame);
// clone the dataset because modifying the pixel data modifies the dataset
var clone = Dataset.Clone();
clone.InternalTransferSyntax = DicomTransferSyntax.ExplicitVRLittleEndian;
var pixelData = DicomPixelData.Create(clone, true);
pixelData.AddFrame(buffer);
// temporary fix for JPEG compressed YBR images
if ((Dataset.InternalTransferSyntax == DicomTransferSyntax.JPEGProcess1 || Dataset.InternalTransferSyntax == DicomTransferSyntax.JPEGProcess2_4) && pixelData.SamplesPerPixel == 3)
pixelData.PhotometricInterpretation = PhotometricInterpretation.Rgb;
// temporary fix for JPEG 2000 Lossy images
if (pixelData.PhotometricInterpretation == PhotometricInterpretation.YbrIct || pixelData.PhotometricInterpretation == PhotometricInterpretation.YbrRct)
pixelData.PhotometricInterpretation = PhotometricInterpretation.Rgb;
_pixelData = PixelDataFactory.Create(pixelData, 0);
} else {
// pull uncompressed frame from source pixel data
_pixelData = PixelDataFactory.Create(PixelData, frame);
}
_pixelData = _pixelData.Rescale(_scale);
_overlays = DicomOverlayData.FromDataset(Dataset).Where(x => x.Type == DicomOverlayType.Graphics && x.Data != null).ToArray();
_currentFrame = frame;
CreatePipeline();
}
示例2: Transcode
public DicomDataset Transcode(DicomDataset dataset) {
if (!dataset.Contains(DicomTag.PixelData)) {
var newDataset = dataset.Clone();
newDataset.InternalTransferSyntax = OutputSyntax;
newDataset.RecalculateGroupLengths(false);
return newDataset;
}
if (!InputSyntax.IsEncapsulated && !OutputSyntax.IsEncapsulated) {
// transcode from uncompressed to uncompressed
var newDataset = dataset.Clone();
newDataset.InternalTransferSyntax = OutputSyntax;
var oldPixelData = DicomPixelData.Create(dataset, false);
var newPixelData = DicomPixelData.Create(newDataset, true);
for (int i = 0; i < oldPixelData.NumberOfFrames; i++) {
var frame = oldPixelData.GetFrame(i);
newPixelData.AddFrame(frame);
}
ProcessOverlays(dataset, newDataset);
newDataset.RecalculateGroupLengths(false);
return newDataset;
}
if (InputSyntax.IsEncapsulated && OutputSyntax.IsEncapsulated) {
// transcode from compressed to compressed
var temp = Decode(dataset, DicomTransferSyntax.ExplicitVRLittleEndian, InputCodec, InputCodecParams);
return Encode(temp, OutputSyntax, OutputCodec, OutputCodecParams);
}
if (InputSyntax.IsEncapsulated) {
// transcode from compressed to uncompressed
return Decode(dataset, OutputSyntax, InputCodec, InputCodecParams);
}
if (OutputSyntax.IsEncapsulated) {
// transcode from uncompressed to compressed
return Encode(dataset, OutputSyntax, OutputCodec, OutputCodecParams);
}
throw new DicomCodecException("Unable to find transcoding solution for {0} to {1}", InputSyntax.UID.Name, OutputSyntax.UID.Name);
}
示例3: Encode
private DicomDataset Encode(DicomDataset oldDataset, DicomTransferSyntax inSyntax, IDicomCodec codec, DicomCodecParams parameters) {
DicomPixelData oldPixelData = DicomPixelData.Create(oldDataset, false);
DicomDataset newDataset = oldDataset.Clone();
newDataset.InternalTransferSyntax = codec.TransferSyntax;
DicomPixelData newPixelData = DicomPixelData.Create(newDataset, true);
codec.Encode(oldPixelData, newPixelData, parameters);
if (codec.TransferSyntax.IsLossy && newPixelData.NumberOfFrames > 0) {
newDataset.Add(new DicomCodeString(DicomTag.LossyImageCompression, "01"));
List<string> methods = new List<string>();
if (newDataset.Contains(DicomTag.LossyImageCompressionMethod))
methods.AddRange(newDataset.Get<string[]>(DicomTag.LossyImageCompressionMethod));
methods.Add(codec.TransferSyntax.LossyCompressionMethod);
newDataset.Add(new DicomCodeString(DicomTag.LossyImageCompressionMethod, methods.ToArray()));
double oldSize = oldPixelData.GetFrame(0).Size;
double newSize = newPixelData.GetFrame(0).Size;
string ratio = String.Format("{0:0.000}", oldSize / newSize);
newDataset.Add(new DicomDecimalString(DicomTag.LossyImageCompressionRatio, ratio));
}
ProcessOverlays(oldDataset, newDataset);
newDataset.RecalculateGroupLengths(false);
return newDataset;
}
示例4: Decode
private DicomDataset Decode(DicomDataset oldDataset, DicomTransferSyntax outSyntax, IDicomCodec codec, DicomCodecParams parameters) {
DicomPixelData oldPixelData = DicomPixelData.Create(oldDataset, false);
DicomDataset newDataset = oldDataset.Clone();
newDataset.InternalTransferSyntax = outSyntax;
DicomPixelData newPixelData = DicomPixelData.Create(newDataset, true);
codec.Decode(oldPixelData, newPixelData, parameters);
ProcessOverlays(oldDataset, newDataset);
newDataset.RecalculateGroupLengths(false);
return newDataset;
}
示例5: DecodeFrame
/// <summary>
/// Decompress single frame from DICOM dataset and return uncompressed frame buffer.
/// </summary>
/// <param name="dataset">DICOM dataset</param>
/// <param name="frame">Frame number</param>
/// <returns>Uncompressed frame buffer</returns>
public IByteBuffer DecodeFrame(DicomDataset dataset, int frame) {
var pixelData = DicomPixelData.Create(dataset, false);
var buffer = pixelData.GetFrame(frame);
// is pixel data already uncompressed?
if (!dataset.InternalTransferSyntax.IsEncapsulated)
return buffer;
// clone dataset to prevent changes to source
var cloneDataset = dataset.Clone();
var oldPixelData = DicomPixelData.Create(cloneDataset, true);
oldPixelData.AddFrame(buffer);
var newDataset = Decode(cloneDataset, InputSyntax, InputCodec, InputCodecParams);
var newPixelData = DicomPixelData.Create(newDataset, false);
return newPixelData.GetFrame(0);
}
示例6: ExtractOverlays
public static DicomDataset ExtractOverlays(DicomDataset dataset) {
if (!DicomOverlayData.HasEmbeddedOverlays(dataset))
return dataset;
dataset = dataset.Clone();
var input = dataset;
if (input.InternalTransferSyntax.IsEncapsulated)
input = input.ChangeTransferSyntax(DicomTransferSyntax.ExplicitVRLittleEndian);
ProcessOverlays(input, dataset);
return dataset;
}