Aspose.Medical  for .NET

.NET API for DICOM Medical Imaging

Read, write, anonymize, transcode and render DICOM files in .NET C#, and exchange studies over DIMSE and DICOMweb, without any external software or native dependencies.

  Download Free Trial
  
 

Aspose.Medical for .NET is a pure .NET class library for working with DICOM (Digital Imaging and Communications in Medicine) files. It lets developers read, write, modify, anonymize, transcode and render medical imaging data, serialize it to DICOM JSON and DICOM XML, and exchange studies with other systems over DIMSE and DICOMweb, without any external software or native dependencies.

The library is written entirely in managed C# and runs on .NET 10 on Windows, Linux and macOS. There are no native binaries and no third-party NuGet packages, so the library deploys as a single assembly into any .NET application, from a desktop tool to a container in a cloud healthcare system.

Key Features:

  • Read and write DICOM files from a file, a stream or a pipe, synchronously or asynchronously, with full support for all standard data elements and value representations.
  • Control memory on large files: load every element, defer large elements until they are used, or skip them and read the metadata only.
  • Read and edit any data element, including sequences and private tags, with character set handling for non-ASCII text.
  • Anonymize DICOM files with the confidentiality profiles of DICOM PS 3.15, with options for retaining UIDs, dates, device and institution identifiers and patient characteristics.
  • Transcode between transfer syntaxes: JPEG, JPEG-LS, JPEG 2000, HTJ2K, JPEG XL and RLE, with every codec implemented in .NET.
  • Render frames to BGRA pixels with the modality LUT, the VOI LUT (window and level) and overlays applied by the renderer.
  • Serialize datasets to the DICOM JSON Model (PS3.18) and to DICOM XML (PS3.19) and back, including asynchronous streaming and pluggable bulk data loading.
  • Communicate over DIMSE with a client and a server: C-ECHO, C-STORE, C-FIND, C-MOVE, C-GET, the N-services, and TLS.
  • Query the modality worklist, report MPPS and hand out work with UPS-RS workitems, as a client and as a server.
  • Search, download and upload studies on any DICOMweb server with a typed client for QIDO-RS, WADO-RS, STOW-RS, rendered images, WADO-URI and the workflow services.
  • Build your own DICOMweb server: QIDO-RS, WADO-RS, STOW-RS and the workflow services on ASP.NET Core or any other HTTP host, with your storage behind them.

Aspose.Medical for .NET is self-contained. It needs no DICOM viewer, no medical imaging software and no native codecs to be installed. It fits healthcare IT systems, PACS integration, telemedicine platforms and any application that has to process DICOM data reliably.

Advanced .NET DICOM API Features

Read and write DICOM files from files, streams, or pipes

Access and manipulate all DICOM tags, sequences and private elements

Anonymize patient data with DICOM PS 3.15 confidentiality profiles

Transcode between transfer syntaxes, including HTJ2K and JPEG XL

Render frames to pixels for viewers, thumbnails and image export

Serialize DICOM data to JSON and XML, with asynchronous streaming

Exchange studies over DIMSE: C-ECHO, C-STORE, C-FIND, C-MOVE, C-GET

Keep memory flat on large files by deferring or skipping large elements

Render multi-frame images with modality LUT, VOI LUT and overlays

Pure .NET Library - Zero Dependencies

Aspose.Medical for .NET is written entirely in managed C# and ships as a single assembly with no native binaries and no third-party NuGet packages. Other medical imaging libraries rely on native codecs or external tools; this one does not. All image compression codecs (JPEG, JPEG-LS, JPEG 2000, HTJ2K, JPEG XL, RLE) are implemented in .NET, so the library behaves the same on Windows, Linux and macOS. That makes it a good fit for containers, cloud environments and any deployment where installing native libraries is not an option. The package targets .NET 10.

Anonymize DICOM Files for Privacy Compliance

Patient privacy is a hard requirement in healthcare applications. Aspose.Medical for .NET anonymizes DICOM data with the confidentiality profiles of DICOM PS 3.15. You can remove or replace patient identifying information while keeping the clinical value of the imaging data, and you can choose what a profile retains: safe private attributes, UIDs, device and institution identifiers, patient characteristics, and longitudinal temporal information. The DICOM anonymization page shows the profile options in detail.

Anonymize DICOM file - C#

// Load the DICOM file
DicomFile dicomFile = DicomFile.Open("patient_scan.dcm");

// Basic Application Level Confidentiality Profile of DICOM PS 3.15
ConfidentialityProfile profile = ConfidentialityProfile.CreateDefault(ConfidentialityProfileOptions.BasicProfile);
Anonymizer anonymizer = new(profile);

// Anonymize into a new file and save it
DicomFile anonymized = anonymizer.Anonymize(dicomFile);
anonymized.Save("anonymized_scan.dcm");

Render DICOM Frames in .NET C#

Aspose.Medical for .NET renders a DICOM frame into a 32-bit BGRA pixel image. The renderer applies the photometric interpretation, the modality LUT and the VOI LUT (window and level) from the dataset and draws the overlays, so the result matches what a viewer shows. The pixels are then yours: copy them into a buffer and pass them to any imaging library to save PNG, JPEG or TIFF. The only image encoder built into the library is PNM. The conversion pages show the full path for PNG, JPEG and TIFF.

Render a DICOM frame - C#

// Load the DICOM file
DicomFile dicomFile = DicomFile.Open("chest_xray.dcm");

// Render the first frame; LUTs and overlays are applied by the renderer
using PixelImage<Bgra32> image = dicomFile.RenderImage(0);

// Copy the pixels out and hand them to an imaging library
Bgra32[] pixels = new Bgra32[image.Width * image.Height];
image.CopyPixelsTo(pixels);

Transcode Between Transfer Syntaxes

Imaging systems and archives require specific DICOM transfer syntaxes. Aspose.Medical for .NET transcodes between uncompressed formats, JPEG Baseline, JPEG Extended, JPEG Lossless, JPEG-LS, JPEG 2000, HTJ2K (High-Throughput JPEG 2000), JPEG XL and RLE. HTJ2K and JPEG XL are the two newest options in the DICOM standard, and here they are implemented in .NET like every other codec. Transcoding matters for PACS integration, for archive size and for compatibility between systems. See the transfer syntax conversion page and the JPEG 2000 page.

Transcode DICOM to HTJ2K - C#

// Load existing DICOM file
DicomFile dicomFile = DicomFile.Open("input.dcm");

// Transcode to High-Throughput JPEG 2000, lossless
DicomFile transcoded = dicomFile.Transcode(TransferSyntax.HTJ2KLossless);

// Save the transcoded file
transcoded.Save("output.dcm");

DICOM to JSON and XML Serialization

Healthcare systems exchange data over web services, so Aspose.Medical for .NET serializes DICOM datasets to the DICOM JSON Model (PS3.18) and to DICOM XML (PS3.19), and parses both back into datasets. The serializers work on strings, streams and pipes, synchronously and asynchronously, and a sequence of datasets can be read one by one without holding the whole document in memory. Bulk data references are resolved through a pluggable loader, so large pixel data can stay outside the document. See the DICOM to JSON and DICOM to XML pages.

Serialize DICOM to JSON and XML - C#

// Load the DICOM file
DicomFile dicomFile = DicomFile.Open("patient_scan.dcm");
Dataset dataset = dicomFile.Dataset;

// Serialize the dataset to JSON (DICOM JSON Model) and to DICOM XML
string json = DicomJsonSerializer.Serialize(dataset, writeIndented: true);
string xml = DicomXmlSerializer.Serialize(dataset);

// Parse both back into datasets
Dataset? fromJson = DicomJsonSerializer.Deserialize(json);
Dataset fromXml = DicomXmlSerializer.Deserialize(xml);

DICOM Networking over DIMSE

Aspose.Medical for .NET talks to other DICOM systems directly. The library provides a DIMSE client and a DIMSE server for C-ECHO, C-STORE, C-FIND, C-MOVE and C-GET, together with the N-services, association negotiation with presentation contexts and roles, asynchronous operation windows, user identity negotiation and TLS. Requests are queued on an association and answered by handlers you register, so a store-and-forward node, a query proxy or a test SCP is a matter of a few classes. The modality worklist page shows the worklist and MPPS workflow on both sides. The DICOM networking guide covers the full API.

Send a study to a PACS with C-STORE - C#

DicomFile dicomFile = DicomFile.Open("study.dcm");

DicomNetworkClient client = DicomNetworkClient
    .CreateBuilder(new DicomNetworkClientOptions
    {
        Called = "PACS_AE",
        Calling = "CLIENT_AE",
        Connection = new DicomNetworkConnectionOptions
        {
            TargetHost = new IPEndPoint(IPAddress.Parse("192.0.2.10"), 104)
        },
        AssociationNegotiation = new AssociationNegotiationOptions()
            .WithPresentationContext(new PresentationContext
            {
                AbstractSyntax = Uid.CTImageStorage,
                Role = null,
                TransferSyntaxes = ImmutableArray.Create(TransferSyntax.ExplicitVrLittleEndian)
            })
    })
    .Build();

client.QueueRequest(new CStoreRequest(dicomFile.Dataset, TransferSyntax.ExplicitVrLittleEndian));

await client.SendAsync(CancellationToken.None);
await client.StopAsync();

DICOMweb Client and Server

Cloud imaging services and modern archives expose DICOM over HTTP. The DICOMweb client in Aspose.Medical for .NET wraps every standard transaction in a typed method: QIDO-RS search, WADO-RS retrieval of studies, series, instances, frames, rendered images and thumbnails, STOW-RS upload, WADO-URI, and the worklist, procedure step and storage commitment services. It runs on your own HttpClient, so authentication and TLS stay where your application configures them, and results arrive as the same datasets and files the rest of the library works with. The same library implements the server side: it handles the protocol of QIDO-RS, WADO-RS, STOW-RS and the workflow services, and your code connects the storage. See the DICOMweb client and DICOMweb server pages.

Search studies on a DICOMweb server - C#

using HttpClient http = new HttpClient();

DicomWebClient client = new DicomWebClient(http, new DicomWebClientOptions
{
    BaseUri = new Uri("https://pacs.example.org/dicom-web/")
});

DicomWebSearchOptions search = new DicomWebSearchOptions
{
    MatchingParameters = [new DicomWebQueryParameter("PatientID", "PATIENT-001")]
};

await using DicomWebClientStream<Dataset> studies = await client.Studies.SearchAsync(search);

await foreach (Dataset study in studies)
    Console.WriteLine(study.GetSingleValueOrDefault(Tag.StudyInstanceUID, string.Empty));

Large DICOM Files Without Large Memory

Whole slide images, long series and multi-frame studies do not fit comfortably in memory. Aspose.Medical for .NET lets you decide how much of a file is loaded: read everything, defer elements above a size threshold until they are accessed, or skip them and work with the metadata alone. Reading from a stream or a pipe and writing back the same way keeps the data moving instead of accumulating. The memory management guide explains the trade-offs.

Read metadata without pixel data - C#

// Elements larger than the threshold are not loaded into memory
DicomFile metadataOnly = DicomFile.Open(
    "whole_slide.dcm",
    ReadDicomFileOptions.Default,
    TagDataReadingStrategies.SkipLargeTags());

string? patientName = metadataOnly.Dataset.GetSingleValueOrDefault(Tag.PatientName, string.Empty);
  

Support and Learning Resources