Imports Leadtools
Imports Leadtools.Dicom
Public Sub TestChangeTransferSyntax()
Dim dicomFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")
'Make sure to initialize the DICOM engine, this needs to be done only once
'In the whole application
DicomEngine.Startup()
Dim ds As DicomDataSet = New DicomDataSet()
Using (ds)
'Load DICOM File
ds.Load(dicomFileName, DicomDataSetLoadFlags.None)
Dim options As DicomJpeg2000Options = ds.DefaultJpeg2000Options
Console.WriteLine("JPEG 2000 Options:")
Console.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform)
Console.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization)
Console.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize)
Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset)
Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset)
Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth)
Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight)
Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset)
Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset)
Console.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels)
Console.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder)
Console.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth)
Console.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight)
Console.WriteLine("DicomJpeg2000Options.SelectiveAcBypass is : {0}", options.SelectiveAcBypass)
Console.WriteLine("DicomJpeg2000Options.ResetContextOnBoundaries is : {0}", options.ResetContextOnBoundaries)
Console.WriteLine("DicomJpeg2000Options.TerminationOnEachPass is : {0}", options.TerminationOnEachPass)
Console.WriteLine("DicomJpeg2000Options.VerticallyCausalContext is : {0}", options.VerticallyCausalContext)
Console.WriteLine("DicomJpeg2000Options.PredictableTermination is : {0}", options.PredictableTermination)
Console.WriteLine("DicomJpeg2000Options.ErrorResilienceSymbol is : {0}", options.ErrorResilienceSymbol)
Console.WriteLine("DicomJpeg2000Options.GuardBits is : {0}", options.GuardBits)
Console.WriteLine("DicomJpeg2000Options.DerivedBaseMantissa is : {0}", options.DerivedBaseMantissa)
Console.WriteLine("DicomJpeg2000Options.DerivedBaseExponent is : {0}", options.DerivedBaseExponent)
Console.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker)
Console.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest)
Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle)
options.CompressionControl = DicomJpeg2000CompressionControl.Ratio
options.CompressionRatio = 50
Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50")
ds.Jpeg2000Options = options
ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None)
ds.Save(Path.Combine(LEAD_VARS.ImagesDir, "DicomJ2K.dcm"), DicomDataSetSaveFlags.None)
End Using
DicomEngine.Shutdown()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Dicom;
public void TestChangeTransferSyntax()
{
string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm");
//Make sure to initialize the DICOM engine, this needs to be done only once
//In the whole application
DicomEngine.Startup();
using (DicomDataSet ds = new DicomDataSet())
{
//Load DICOM File
ds.Load(dicomFileName, DicomDataSetLoadFlags.None);
DicomJpeg2000Options options = ds.DefaultJpeg2000Options;
Console.WriteLine("JPEG 2000 Options:");
Console.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform);
Console.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization);
Console.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize);
Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset);
Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset);
Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth);
Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight);
Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset);
Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset);
Console.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels);
Console.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder);
Console.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth);
Console.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight);
Console.WriteLine("DicomJpeg2000Options.SelectiveAcBypass is : {0}", options.SelectiveAcBypass);
Console.WriteLine("DicomJpeg2000Options.ResetContextOnBoundaries is : {0}", options.ResetContextOnBoundaries);
Console.WriteLine("DicomJpeg2000Options.TerminationOnEachPass is : {0}", options.TerminationOnEachPass);
Console.WriteLine("DicomJpeg2000Options.VerticallyCausalContext is : {0}", options.VerticallyCausalContext);
Console.WriteLine("DicomJpeg2000Options.PredictableTermination is : {0}", options.PredictableTermination);
Console.WriteLine("DicomJpeg2000Options.ErrorResilienceSymbol is : {0}", options.ErrorResilienceSymbol);
Console.WriteLine("DicomJpeg2000Options.GuardBits is : {0}", options.GuardBits);
Console.WriteLine("DicomJpeg2000Options.DerivedBaseMantissa is : {0}", options.DerivedBaseMantissa);
Console.WriteLine("DicomJpeg2000Options.DerivedBaseExponent is : {0}", options.DerivedBaseExponent);
Console.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker);
Console.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest);
Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle);
options.CompressionControl = DicomJpeg2000CompressionControl.Ratio;
options.CompressionRatio = 50;
Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50");
ds.Jpeg2000Options = options;
ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None);
ds.Save(Path.Combine(LEAD_VARS.ImagesDir, "DicomJ2K.dcm"), DicomDataSetSaveFlags.None);
}
DicomEngine.Shutdown();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Dicom.Constants;
using Leadtools;
using Leadtools.Dicom;
public async Task TestChangeTransferSyntax()
{
//Make sure to initialize the DICOM engine, this needs to be done only once
//In the whole application
DicomEngine.Startup();
using (DicomDataSet ds = new DicomDataSet())
{
//Load DICOM File
string filePath = @"Assets\IMAGE3.dcm";
StorageFile file = await Tools.AppInstallFolder.GetFileAsync(filePath);
ILeadStream stream = LeadStreamFactory.Create(file);
bool success = await ds.LoadAsync(stream, DicomDataSetLoadFlags.None);
Debug.Assert(success);
DicomJpeg2000Options options = ds.DefaultJpeg2000Options;
Debug.WriteLine("JPEG 2000 Options:");
Debug.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform);
Debug.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization);
Debug.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize);
Debug.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset);
Debug.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset);
Debug.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth);
Debug.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight);
Debug.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset);
Debug.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset);
Debug.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels);
Debug.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder);
Debug.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth);
Debug.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight);
Debug.WriteLine("DicomJpeg2000Options.SelectiveAcBypass is : {0}", options.SelectiveAcBypass);
Debug.WriteLine("DicomJpeg2000Options.ResetContextOnBoundaries is : {0}", options.ResetContextOnBoundaries);
Debug.WriteLine("DicomJpeg2000Options.TerminationOnEachPass is : {0}", options.TerminationOnEachPass);
Debug.WriteLine("DicomJpeg2000Options.VerticallyCausalContext is : {0}", options.VerticallyCausalContext);
Debug.WriteLine("DicomJpeg2000Options.PredictableTermination is : {0}", options.PredictableTermination);
Debug.WriteLine("DicomJpeg2000Options.ErrorResilienceSymbol is : {0}", options.ErrorResilienceSymbol);
Debug.WriteLine("DicomJpeg2000Options.GuardBits is : {0}", options.GuardBits);
Debug.WriteLine("DicomJpeg2000Options.DerivedBaseMantissa is : {0}", options.DerivedBaseMantissa);
Debug.WriteLine("DicomJpeg2000Options.DerivedBaseExponent is : {0}", options.DerivedBaseExponent);
Debug.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker);
Debug.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker);
Debug.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest);
Debug.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest);
Debug.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight);
Debug.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle);
options.CompressionControl = DicomJpeg2000CompressionControl.Ratio;
options.CompressionRatio = 50;
Debug.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50");
ds.Jpeg2000Options = options;
ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None);
string dicomFileNameOutput = "DicomJ2K.dcm";
StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
ILeadStream streamOutput = LeadStreamFactory.Create(saveFile);
using (IDisposable disposableOUT = streamOutput as IDisposable)
{
await ds.SaveAsync(streamOutput, DicomDataSetSaveFlags.None);
}
}
DicomEngine.Shutdown();
}
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Examples;
public void TestChangeTransferSyntax(Stream dicomStream, Stream outputStream)
{
//Make sure to initialize the DICOM engine, this needs to be done only once
//In the whole application
DicomEngine.Startup();
using (DicomDataSet ds = new DicomDataSet())
{
//Load DICOM File
ds.Load(dicomStream, DicomDataSetLoadFlags.None);
DicomJpeg2000Options options = ds.DefaultJpeg2000Options;
Console.WriteLine("JPEG 2000 Options:");
Console.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform);
Console.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization);
Console.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize);
Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset);
Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset);
Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth);
Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight);
Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset);
Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset);
Console.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels);
Console.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder);
Console.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth);
Console.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight);
Console.WriteLine("DicomJpeg2000Options.SelectiveAcBypass is : {0}", options.SelectiveAcBypass);
Console.WriteLine("DicomJpeg2000Options.ResetContextOnBoundaries is : {0}", options.ResetContextOnBoundaries);
Console.WriteLine("DicomJpeg2000Options.TerminationOnEachPass is : {0}", options.TerminationOnEachPass);
Console.WriteLine("DicomJpeg2000Options.VerticallyCausalContext is : {0}", options.VerticallyCausalContext);
Console.WriteLine("DicomJpeg2000Options.PredictableTermination is : {0}", options.PredictableTermination);
Console.WriteLine("DicomJpeg2000Options.ErrorResilienceSymbol is : {0}", options.ErrorResilienceSymbol);
Console.WriteLine("DicomJpeg2000Options.GuardBits is : {0}", options.GuardBits);
Console.WriteLine("DicomJpeg2000Options.DerivedBaseMantissa is : {0}", options.DerivedBaseMantissa);
Console.WriteLine("DicomJpeg2000Options.DerivedBaseExponent is : {0}", options.DerivedBaseExponent);
Console.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker);
Console.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest);
Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight);
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle);
options.CompressionControl = DicomJpeg2000CompressionControl.Ratio;
options.CompressionRatio = 50;
Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50");
ds.Jpeg2000Options = options;
ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None);
ds.Save(outputStream, DicomDataSetSaveFlags.None);
}
DicomEngine.Shutdown();
}
Imports Leadtools
Imports Leadtools.Dicom
Public Sub TestChangeTransferSyntax(ByVal dicomStream As Stream, ByVal outputStream As Stream)
'Make sure to initialize the DICOM engine, this needs to be done only once
'In the whole application
DicomEngine.Startup()
Using ds As DicomDataSet = New DicomDataSet()
'Load DICOM File
ds.Load(dicomStream, DicomDataSetLoadFlags.None)
Dim options As DicomJpeg2000Options = ds.DefaultJpeg2000Options
Console.WriteLine("JPEG 2000 Options:")
Console.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform)
Console.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization)
Console.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize)
Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset)
Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset)
Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth)
Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight)
Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset)
Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset)
Console.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels)
Console.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder)
Console.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth)
Console.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight)
Console.WriteLine("DicomJpeg2000Options.SelectiveAcBypass is : {0}", options.SelectiveAcBypass)
Console.WriteLine("DicomJpeg2000Options.ResetContextOnBoundaries is : {0}", options.ResetContextOnBoundaries)
Console.WriteLine("DicomJpeg2000Options.TerminationOnEachPass is : {0}", options.TerminationOnEachPass)
Console.WriteLine("DicomJpeg2000Options.VerticallyCausalContext is : {0}", options.VerticallyCausalContext)
Console.WriteLine("DicomJpeg2000Options.PredictableTermination is : {0}", options.PredictableTermination)
Console.WriteLine("DicomJpeg2000Options.ErrorResilienceSymbol is : {0}", options.ErrorResilienceSymbol)
Console.WriteLine("DicomJpeg2000Options.GuardBits is : {0}", options.GuardBits)
Console.WriteLine("DicomJpeg2000Options.DerivedBaseMantissa is : {0}", options.DerivedBaseMantissa)
Console.WriteLine("DicomJpeg2000Options.DerivedBaseExponent is : {0}", options.DerivedBaseExponent)
Console.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker)
Console.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest)
Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight)
Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle)
options.CompressionControl = DicomJpeg2000CompressionControl.Ratio
options.CompressionRatio = 50
Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50")
ds.Jpeg2000Options = options
ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None)
ds.Save(outputStream, DicomDataSetSaveFlags.None)
End Using
DicomEngine.Shutdown()
End Sub