C# Dicom Library
C# DICOM - DICOM Imaging in C#.NET
Overview for How to Use DICOM Image in C#.NET Imaging Program
Set DICOM Image File Rendering Options in C# Overview
RasterEdge .NET Document Imaging SDK enables C# programmers to render and convert DICOM image file to documents and images, like PDF, TIFF, GIF, JPEG, PNG, BMP, JBIG2, etc.
Moreover, C# programmers can have full control over DICOM document rendering and converting options, like setting image resolution/size, window center and window width to get high quality rendered file, and defining C# DICOM document rendering through page-by-page or converting the whole document at a time.
As we mentioned, C# programmers can adjust window center and window width values for DICOM image during converting DICOM document to other images and documents. As for window center and window width, they are similar to the notions of contrast and brittleness in common image processing.
In this section, we will illustrate the C#.NET class code for you to set and control DICOM image file conversion through window center and window width.
If you want to know other DICOM rendering options mentioned above, please directly download the package of DocImage SDK for .NET and see its developer guide.
C# Class Code for DICOM Rendering Options Setting
Add necessary references references;
RasterEdge.Imaging.Basic.dll
RasterEdge.Imaging.Basic.Codec.dll
RasterEdge.Imaging.JPEG2000.dll
RasterEdge.Imaging.DICOM.dll
Use corresponding namespaces;
using RasterEdge.Imaging.Basic;
using RasterEdge.Imaging.DICOM;
Below is C# sample code to set DICOM image file rendering options: window center and window width. Please note that, some .NET DICOM Conversion DLLs should be added to your C#.NET project first.
DCMDocument doc = new DCMDocument(@"C:\demo1.dcm");
// get the first page
DCMPage page = (DCMPage)doc.GetPage(0);
// you can get recommended range for value of window width and window center
int[] centerRange = page.GetRecommendedWindowCenter();
int[] widthRange = page.GetRecommendedWindowWidth();
// for illustration purpose, we choose random value in the range
Random randomGenerater = new Random();
int randomCenter = randomGenerater.Next(centerRange[0], centerRange[1]);
int randomWidth = randomGenerater.Next(widthRange[0], widthRange[1]);
// get REImage with specified values of width and center
Bitmap img = page.GetModifiedREImage(randomWidth, randomCenter);
// save the image in file
img.Save(@"c:\dicom.png");
|