Class DicomImage
- Namespace
- Aspose.Imaging.FileFormats.Dicom
- Assembly
- Aspose.Imaging.dll
This Class implements Digital Imaging and Communications in Medicine (DICOM) raster image format support and offers a comprehensive solution for processing DICOM images with precision and flexibility. You can seamlessly manipulate image pages, including operations to get, add, or remove pages, and control the default and active pages. With capabilities to work with alpha channels, embed XMP metadata, resize, rotate, crop, binarize, adjust, apply filters, and convert to other raster formats. This API empowers developers to handle DICOM images effectively while meeting diverse application requirements in medical imaging contexts.
public sealed class DicomImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
- Inheritance
-
DicomImage
- Implements
- Inherited Members
Constructors
DicomImage(DicomOptions, int, int)
Initialize a fresh instance of the DicomImage class effortlessly with this constructor, utilizing dicomOptions parameters. Perfect for developers looking to dive into DicomImage objects swiftly and efficiently in their projects.
public DicomImage(DicomOptions dicomOptions, int width, int height)
Parameters
dicomOptions
DicomOptionsThe dicom options.
width
intThe width.
height
intThe height.
DicomImage(Stream)
Create a new instance of the DicomImage class by utilizing a stream parameter in this constructor. Perfect for developers seeking a streamlined way to initialize DicomImage objects from existing data streams in their projects.
public DicomImage(Stream stream)
Parameters
stream
StreamThe stream.
DicomImage(Stream, LoadOptions)
Initiate a new instance of the DicomImage class smoothly by employing a stream and loadOptions parameters in this constructor. Ideal for developers eager to start working with DicomImage objects promptly and effectively in their projects.
public DicomImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
StreamThe stream.
loadOptions
LoadOptionsThe load options.
Properties
ActivePage
Manage the active page of the image with this intuitive property. Ideal for developers seeking to dynamically switch between pages within multi-page images, ensuring efficient navigation and processing.
public DicomPage ActivePage { get; set; }
Property Value
- DicomPage
The active page.
Exceptions
- DicomImageException
The active page cannot be set as it belongs to another image.
ActivePageIndex
Retrieve the index of the active page effortlessly with this intuitive property. Ideal for developers seeking quick access to the current page index within multi-page images, ensuring efficient navigation and processing.
public int ActivePageIndex { get; }
Property Value
- int
The index active page.
DicomPages
Access the pages of the image with this intuitive property. Ideal for developers seeking to interact with individual pages within the image, ensuring seamless navigation and manipulation.
public DicomPage[] DicomPages { get; }
Property Value
- DicomPage[]
The pages.
FileFormat
Retrieve the file format value effortlessly with this intuitive property. Ideal for developers seeking quick access to the format of the image file, ensuring efficient handling and processing based on the file type.
public override FileFormat FileFormat { get; }
Property Value
FileInfo
Retrieve valuable header information from the DICOM file effortlessly with this intuitive property. Ideal for developers seeking quick access to essential details encapsulated within the DICOM file, ensuring efficient data extraction and analysis.
public DicomImageInfo FileInfo { get; }
Property Value
HasAlpha
Retrieve whether the image has an alpha channel effortlessly with this intuitive property. Ideal for developers seeking to determine if the image contains transparency information, ensuring precise handling of alpha channel data in image processing tasks.
public override bool HasAlpha { get; }
Property Value
- bool
The Has alpha channel.
PageCount
Retrieve the total page count of the image with this intuitive property. Ideal for developers seeking quick access to the number of pages within an image, ensuring efficient navigation and management.
public override int PageCount { get; }
Property Value
- int
The page count.
PageExportingAction
Manage the page exporting action with this intuitive property. Ideal for developers seeking to control the export behavior of image pages, ensuring seamless integration and customization in various image processing workflows. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.
public override PageExportingAction PageExportingAction { get; set; }
Property Value
- PageExportingAction
The page exporting action.
Pages
Access the pages of the image with this intuitive property. Ideal for developers seeking to interact with individual pages within the image, ensuring seamless navigation and manipulation.
public override Image[] Pages { get; }
Property Value
- Image[]
The pages.
Methods
AddPage()
Append a new page to the end of the image's page list with this straightforward method. Ideal for developers seeking to dynamically expand multi-page images, ensuring seamless integration and organization of image content.
public DicomPage AddPage()
Returns
AddPage(RasterImage)
Expand your image collection by adding a new page with this intuitive method. Ideal for developers seeking to dynamically append pages to multi-page images, ensuring seamless expansion and organization of image content.
public void AddPage(RasterImage page)
Parameters
page
RasterImageThe page to add.
Exceptions
- ArgumentNullException
page
is null.
AdjustBrightness(int)
Enhance image luminance with the adjustment of brightness
, a
parameterized method that allows developers to finely tune the luminosity of images.
This user-friendly function empowers developers to seamlessly manipulate image
brightness, offering flexibility and control over visual aesthetics.
public override void AdjustBrightness(int brightness)
Parameters
brightness
intBrightness value.
AdjustContrast(float)
Enhance Image contrast with this user-friendly method, which adjusts the disparity between light and dark areas. Improve visual clarity and definition effortlessly, providing developers with intuitive control over image contrast for optimal rendering.
public override void AdjustContrast(float contrast)
Parameters
contrast
floatContrast value (in range [-100; 100])
AdjustGamma(float)
Enhance image quality and adjust it with gamma correction, a powerful technique for fine-tuning visual appearance. Perfect for developers aiming to optimize image presentation, adjust color balance, and ensure consistent rendering across different devices and environments.
public override void AdjustGamma(float gamma)
Parameters
gamma
floatGamma for red, green and blue channels coefficient
AdjustGamma(float, float, float)
Achieve precise color adjustments by applying gamma correction independently to the red, green, and blue components of an image. This method ensures accurate color balance and optimal visual output, catering to developers seeking granular control over image rendering and color accuracy.
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
floatGamma for red channel coefficient
gammaGreen
floatGamma for green channel coefficient
gammaBlue
floatGamma for blue channel coefficient
BinarizeBradley(double, int)
Binarize images with Bradley's adaptive thresholding algorithm, leveraging integral image thresholding for improved performance. Ideal for developers looking to automatically segment images based on local variations in brightness, ensuring accurate object detection and extraction in varying lighting conditions.
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
doubleThe brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.
windowSize
intThe size of s x s window of pixels centered around this pixel
BinarizeFixed(byte)
Easily convert the image into a binary format using a predefined threshold with this straightforward method. Ideal for developers looking to simplify image processing tasks by segmenting the image into foreground and background components based on specified intensity levels.
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byteThreshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
BinarizeOtsu()
Apply Otsu thresholding to binarize the image, automatically determining the optimal threshold value based on the image's histogram. Perfect for developers seeking a reliable method to segment images into foreground and background regions with minimal manual intervention.
public override void BinarizeOtsu()
CacheData()
This method efficiently caches data, optimizing performance and ensuring swift access when needed. Ideal for developers seeking to enhance the speed and efficiency of their applications by intelligently managing data resources.
public override void CacheData()
Crop(Rectangle)
Crop the image to remove unwanted areas and focus on essential content with this simple method. Ideal for developers seeking to customize the visual composition of images, ensuring they convey the desired message effectively.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
RectangleThe rectangle.
Crop(int, int, int, int)
Adjust the cropping area of the image by applying shifts with this versatile method. Perfect for developers who need precise control over the cropping process, ensuring that important details are retained while eliminating unnecessary elements.
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
intThe left shift.
rightShift
intThe right shift.
topShift
intThe top shift.
bottomShift
intThe bottom shift.
Dither(DitheringMethod, int, IColorPalette)
Enhance the current image by applying dithering effects with this straightforward method. Perfect for developers aiming to add texture and depth to images, improving their visual quality and overall appeal.
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethodThe dithering method.
bitsCount
intThe final bits count for dithering.
customPalette
IColorPaletteThe custom palette for dithering.
Filter(Rectangle, FilterOptionsBase)
Effortlessly enhance specific areas of your image by applying filters to designated rectangles. This method provides developers with precise control over image manipulation, allowing for targeted adjustments to achieve desired visual effects with ease.
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
RectangleThe rectangle.
options
FilterOptionsBaseThe options.
Grayscale()
Easily transform images into their grayscale representation, simplifying visual analysis and processing tasks. Perfect for developers seeking to enhance image clarity, reduce complexity, and facilitate efficient grayscale-based algorithms for diverse applications.
public override void Grayscale()
InsertPage(int)
Insert a new page into the image's page list at a specified index with this intuitive method. Ideal for developers seeking precise control over the arrangement of pages in multi-page images, ensuring seamless organization and customization of image content.
public DicomPage InsertPage(int pageIndex)
Parameters
pageIndex
intIndex of the page.
Returns
Exceptions
- ArgumentOutOfRangeException
pageIndex
is out of range.
ReleaseManagedResources()
protected override void ReleaseManagedResources()
RemovePage(int)
Eliminate the page at the specified index from the page list with this convenient method. Ideal for developers seeking precise control over the management of multi-page images, ensuring seamless organization and customization of image content.
public void RemovePage(int pageIndex)
Parameters
pageIndex
intIndex of the page.
Exceptions
- ArgumentOutOfRangeException
pageIndex
is out of range.
Resize(int, int, ImageResizeSettings)
Adjust the size of your image with this simple resizing method. Whether you need to shrink or enlarge your image, this function ensures that your resizing needs are met efficiently and accurately, making it perfect for developers seeking quick and easy image size adjustments.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
settings
ImageResizeSettingsThe resize settings.
Resize(int, int, ResizeType)
Adjust the size of the image with this straightforward method. Ideal for developers looking to dynamically resize images, ensuring they fit seamlessly into various contexts and layouts within their applications.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeHeightProportionally(int, ResizeType)
Adjust the height of the image while maintaining its aspect ratio with this user-friendly method. Perfect for developers seeking to dynamically resize images while preserving their proportions, ensuring optimal display and usability in their applications.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
intThe new height.
resizeType
ResizeTypeType of the resize.
ResizeProportional(int, int, ResizeType)
Resize the image while maintaining its aspect ratio with this convenient method. Ideal
for developers seeking to adjust the image dimensions proportionally, ensuring
consistency and preserving the original content's proportions.
The proportional resize will resize each frame according to the ratio of newWidth
/width and newHeight
/height.
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeWidthProportionally(int, ResizeType)
Adjust the width of the image while maintaining its aspect ratio with this convenient method. Ideal for developers seeking to resize images proportionally, ensuring consistent and visually appealing results across different display environment.
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
intThe new width.
resizeType
ResizeTypeType of the resize.
Rotate(float, bool, Color)
Rotate the image around its center with this convenient method. Ideal for developers seeking to adjust image orientation dynamically, ensuring optimal presentation and alignment within their applications.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
floatThe rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
boolif set to
true
you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.backgroundColor
ColorColor of the background.
RotateFlip(RotateFlipType)
Easily manipulate the active frame by rotating, flipping, or performing both actions simultaneously with this straightforward method. Ideal for developers who need to dynamically adjust the orientation of specific frames within their image sequences, ensuring optimal presentation and alignment.
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipTypeThe rotate flip type.
Save(Stream, ImageOptionsBase, Rectangle)
Easily save your image data to a specified stream in the desired file format using this convenient method. Whether you're working with JPEG, PNG, or another format, this function ensures that your image data is saved efficiently and accurately, making it ideal for developers looking to streamline their file-saving processes.
public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
StreamThe stream to save the image's data to.
optionsBase
ImageOptionsBaseThe save options.
boundsRectangle
RectangleThe destination image bounds rectangle. Set the empty rectangle for use sourse bounds.
SaveAll(string, ImageOptionsBase)
Preserve the object's data by saving it to the designated file (indexer + filename) location along with specified file format and options. Ideal for developers seeking to securely store data in various formats while maintaining flexibility and control over saving parameters.
public void SaveAll(string filePath, ImageOptionsBase options)
Parameters
filePath
stringThe file path.
options
ImageOptionsBaseThe options.
SaveData(Stream)
protected override void SaveData(Stream stream)
Parameters
stream
Stream
SetResolution(double, double)
Adjust the resolution of this RasterImage with precision using this straightforward method. Ideal for developers looking to tailor image resolution to specific requirements, ensuring optimal display quality and file size management.
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
doubleThe horizontal resolution, in dots per inch, of the RasterImage.
dpiY
doubleThe vertical resolution, in dots per inch, of the RasterImage.
UpdateDimensions(int, int)
protected override void UpdateDimensions(int newWidth, int newHeight)