本文整理汇总了C#中ClearCanvas.Dicom.DicomFile.ChangeTransferSyntax方法的典型用法代码示例。如果您正苦于以下问题:C# DicomFile.ChangeTransferSyntax方法的具体用法?C# DicomFile.ChangeTransferSyntax怎么用?C# DicomFile.ChangeTransferSyntax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClearCanvas.Dicom.DicomFile
的用法示例。
在下文中一共展示了DicomFile.ChangeTransferSyntax方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonCompress_Click
private void buttonCompress_Click(object sender, EventArgs e)
{
TransferSyntax syntax = this.comboBoxCompressionType.SelectedItem as TransferSyntax;
if (syntax == null)
{
MessageBox.Show("Transfer syntax not selected");
return;
}
DicomFile dicomFile = new DicomFile(textBoxSourceFile.Text);
dicomFile.Load();
if (dicomFile.TransferSyntax.Encapsulated)
{
MessageBox.Show(String.Format("Message encoded as {0}, cannot compress.", dicomFile.TransferSyntax));
return;
}
dicomFile.Filename = textBoxDestinationFile.Text;
dicomFile.ChangeTransferSyntax(syntax);
dicomFile.Save();
}
示例2: buttonDecompress_Click
private void buttonDecompress_Click(object sender, EventArgs e)
{
if (this.textBoxSourceFile.Text.Length == 0 || this.textBoxDestinationFile.Text.Length == 0)
{
MessageBox.Show("Invalid source or destination filename");
return;
}
DicomFile dicomFile = new DicomFile(textBoxSourceFile.Text);
dicomFile.Load();
dicomFile.Filename = textBoxDestinationFile.Text;
dicomFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
dicomFile.Save();
}
示例3: ProcessDuplicate
private ProcessDuplicateResult ProcessDuplicate(DicomFile dupFile, WorkQueueUid uid, StudyXml studyXml)
{
var result = new ProcessDuplicateResult();
var data = uid.SerializeWorkQueueUidData;
string duplicateSopPath = ServerHelper.GetDuplicateUidPath(StorageLocation, uid);
string basePath = StorageLocation.GetSopInstancePath(uid.SeriesInstanceUid, uid.SopInstanceUid);
if (!File.Exists(basePath))
{
// NOTE: This is special case. The file which caused dicom service to think this sop is a duplicate
// no longer exists in the study folder. Perhaps it has been moved to another folder during auto reconciliation.
// We have nothing to compare against so let's just throw it into the SIQ queue.
CreateDuplicateSIQEntry(uid, dupFile, null);
result.ActionTaken = DuplicateProcessResultAction.Reconcile;
}
else
{
var duplicateEnum = data.DuplicateProcessing.HasValue ? data.DuplicateProcessing.Value : DuplicateProcessingEnum.Compare;
// Check if system is configured to override the rule for this study
if (duplicateEnum == DuplicateProcessingEnum.OverwriteSop)
{
return OverwriteDuplicate(dupFile, uid, studyXml);
}
// Check if system is configured to override the rule for this study
if (duplicateEnum == DuplicateProcessingEnum.OverwriteSopAndUpdateDatabase)
{
return OverwriteAndUpdateDuplicate(dupFile, uid, studyXml);
}
var baseFile = new DicomFile(basePath);
baseFile.Load();
if (duplicateEnum == DuplicateProcessingEnum.OverwriteReport)
{
return ProcessDuplicateReport(dupFile, baseFile, uid, studyXml);
}
// DuplicateProcessingEnum.Compare
if (!dupFile.TransferSyntax.Equals(baseFile.TransferSyntax))
{
// If they're compressed, and we have a codec, lets decompress and still do the comparison
if (dupFile.TransferSyntax.Encapsulated
&& !dupFile.TransferSyntax.LossyCompressed
&& DicomCodecRegistry.GetCodec(dupFile.TransferSyntax) != null)
{
dupFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
}
if (baseFile.TransferSyntax.Encapsulated
&& !baseFile.TransferSyntax.LossyCompressed
&& DicomCodecRegistry.GetCodec(baseFile.TransferSyntax) != null)
{
baseFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
}
if (dupFile.TransferSyntax.Encapsulated || baseFile.TransferSyntax.Encapsulated)
{
string failure = String.Format("Base file transfer syntax is '{0}' while duplicate file has '{1}'",
baseFile.TransferSyntax, dupFile.TransferSyntax);
var list = new List<DicomAttributeComparisonResult>();
var compareResult = new DicomAttributeComparisonResult
{
ResultType = ComparisonResultType.DifferentValues,
TagName = DicomTagDictionary.GetDicomTag(DicomTags.TransferSyntaxUid).Name,
Details = failure
};
list.Add(compareResult);
CreateDuplicateSIQEntry(uid, dupFile, list);
result.ActionTaken = DuplicateProcessResultAction.Reconcile;
return result;
}
}
var failureReason = new List<DicomAttributeComparisonResult>();
if (baseFile.DataSet.Equals(dupFile.DataSet, ref failureReason))
{
Platform.Log(LogLevel.Info,
"Duplicate SOP being processed is identical. Removing SOP: {0}",
baseFile.MediaStorageSopInstanceUid);
RemoveWorkQueueUid(uid, duplicateSopPath);
result.ActionTaken = DuplicateProcessResultAction.Delete;
}
else
{
CreateDuplicateSIQEntry(uid, dupFile, failureReason);
result.ActionTaken = DuplicateProcessResultAction.Reconcile;
}
}
return result;
}
示例4: ChangeAspectRatio
public void ChangeAspectRatio(DicomFile file)
{
if (NewAspectRatio.IsNull || FloatComparer.AreEqual(NewAspectRatio.Value, 1))
throw new InvalidOperationException("Invalid new aspect ratio");
if (file.TransferSyntax.Encapsulated)
file.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
OldInfo = new PixelDataInfo(file.DataSet);
if (!OldInfo.IsSquare)
throw new ArgumentException("Pixels are already non-square.");
NewInfo = OldInfo.Clone();
NewInfo.AspectRatio = NewAspectRatio;
if (IncreasePixelDimensions)
{
if (NewAspectRatio.Value < 1)
NewInfo.Rows = (int)(OldInfo.Rows / NewAspectRatio.Value + 0.5);
else
NewInfo.Columns = (int)(OldInfo.Columns * NewAspectRatio.Value + 0.5);
}
else
{
if (NewAspectRatio.Value < 1)
NewInfo.Columns = (int)(OldInfo.Columns * NewAspectRatio.Value + 0.5);
else
NewInfo.Rows = (int)(OldInfo.Rows / NewAspectRatio.Value + 0.5);
}
float rowScale = OldInfo.Rows / (float)NewInfo.Rows;
float colScale = OldInfo.Columns / (float)NewInfo.Columns;
if (RemoveCalibration)
{
NewInfo.PixelSpacing = new PixelSpacing(0, 0);
NewInfo.ImagerPixelSpacing = new PixelSpacing(0, 0);
}
else
{
NewInfo.PixelSpacing = new PixelSpacing(NewInfo.PixelSpacing.Row * rowScale, NewInfo.PixelSpacing.Column * colScale);
NewInfo.ImagerPixelSpacing = new PixelSpacing(NewInfo.ImagerPixelSpacing.Row * rowScale, NewInfo.ImagerPixelSpacing.Column * colScale);
}
ValidateNewInfo();
NewInfo.SeriesDescription = (OldInfo.SeriesDescription ?? "") + String.Format(" ({0}:{1}, dim/cal={2}/{3})",
NewAspectRatio.Row, NewAspectRatio.Column,
IncreasePixelDimensions ? "y" : "n",
NewInfo.IsCalibrated ? "y" : "n");
NewInfo.PlanarConfiguration = 0;
PixelData oldPixelData = OldInfo.GetPixelData();
PixelData newPixelData = NewInfo.GetPixelData();
for (int row = 0; row < NewInfo.Rows; ++row)
{
for (int column = 0; column < NewInfo.Columns; ++column)
{
var sourcePoint = new PointF(column * colScale, row * rowScale);
int interpolated = PerformBilinearInterpolationAt(oldPixelData, sourcePoint);
newPixelData.SetPixel(column, row, interpolated);
}
}
NewInfo.SetPixelData(newPixelData);
NewInfo.UpdateDataSet(file.DataSet);
}
示例5: CompareDuplicates
/// <summary>
/// Compares received duplicate with the existing copy in the filesystem and throw it into the SIQ if they differ.
/// Otherwise, simply delete the duplicate and keep everything as it.
/// </summary>
/// <param name="dupFile"></param>
/// <param name="baseFile"></param>
/// <param name="uid"></param>
/// <returns></returns>
private ProcessDuplicateResult CompareDuplicates(DicomFile dupFile, DicomFile baseFile, WorkQueueUid uid)
{
var result = new ProcessDuplicateResult();
string duplicateSopPath = ServerHelper.GetDuplicateUidPath(StorageLocation, uid);
if (!dupFile.TransferSyntax.Equals(baseFile.TransferSyntax))
{
// If they're compressed, and we have a codec, lets decompress and still do the comparison
if (dupFile.TransferSyntax.Encapsulated
&& !dupFile.TransferSyntax.LossyCompressed
&& DicomCodecRegistry.GetCodec(dupFile.TransferSyntax) != null)
{
dupFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
}
if (baseFile.TransferSyntax.Encapsulated
&& !baseFile.TransferSyntax.LossyCompressed
&& DicomCodecRegistry.GetCodec(baseFile.TransferSyntax) != null)
{
baseFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
}
if (dupFile.TransferSyntax.Encapsulated || baseFile.TransferSyntax.Encapsulated)
{
string failure = String.Format("Base file transfer syntax is '{0}' while duplicate file has '{1}'",
baseFile.TransferSyntax, dupFile.TransferSyntax);
var list = new List<DicomAttributeComparisonResult>();
var compareResult = new DicomAttributeComparisonResult
{
ResultType = ComparisonResultType.DifferentValues,
TagName = DicomTagDictionary.GetDicomTag(DicomTags.TransferSyntaxUid).Name,
Details = failure
};
list.Add(compareResult);
CreateDuplicateSIQEntry(uid, dupFile, list);
result.ActionTaken = DuplicateProcessResultAction.Reconcile;
return result;
}
}
var failureReason = new List<DicomAttributeComparisonResult>();
if (baseFile.DataSet.Equals(dupFile.DataSet, ref failureReason))
{
Platform.Log(LogLevel.Info,
"Duplicate SOP being processed is identical. Removing SOP: {0}",
baseFile.MediaStorageSopInstanceUid);
RemoveWorkQueueUid(uid, duplicateSopPath);
result.ActionTaken = DuplicateProcessResultAction.Delete;
}
else
{
CreateDuplicateSIQEntry(uid, dupFile, failureReason);
result.ActionTaken = DuplicateProcessResultAction.Reconcile;
}
return result;
}