Class DicomImage
Namespace: Aspose.Imaging.FileFormats.Dicom
Assembly: Aspose.Imaging.dll (25.7.0)
This Class implements Digital Imaging and Communications in Medicine(DICOM) raster image format support and offers a comprehensive solution forprocessing DICOM images with precision and flexibility. You can seamlesslymanipulate image pages, including operations to get, add, or remove pages, andcontrol 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 handleDICOM images effectively while meeting diverse application requirements inmedical imaging contexts.
[JsonObject(MemberSerialization.OptIn)]
public sealed class DicomImage : RasterCachedMultipageImage, IDisposable,
IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader,
IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
{
}
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← DicomImage
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata , IMultipageImageExt , IMultipageImage
Inherited Members
RasterCachedMultipageImage.AdjustBrightness(int) , RasterCachedMultipageImage.AdjustContrast(float) , RasterCachedMultipageImage.AdjustGamma(float, float, float) , RasterCachedMultipageImage.AdjustGamma(float) , RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedMultipageImage.BinarizeFixed(byte) , RasterCachedMultipageImage.BinarizeBradley(double, int) , RasterCachedMultipageImage.BinarizeBradley(double) , RasterCachedMultipageImage.BinarizeOtsu() , RasterCachedMultipageImage.Crop(Rectangle) , RasterCachedMultipageImage.Crop(int, int, int, int) , RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedMultipageImage.Grayscale() , RasterCachedMultipageImage.NormalizeHistogram() , RasterCachedMultipageImage.Rotate(float, bool, Color) , RasterCachedMultipageImage.RotateFlip(RotateFlipType) , RasterCachedMultipageImage.RotateFlipAll(RotateFlipType) , RasterCachedMultipageImage.Resize(int, int, ResizeType) , RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings) , RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType) , RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType) , RasterCachedMultipageImage.ReplaceColor(int, byte, int) , RasterCachedMultipageImage.ReplaceNonTransparentColors(int) , RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase) , RasterCachedMultipageImage.NormalizeAngle(bool, Color) , RasterCachedMultipageImage.CacheData() , RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , RasterCachedMultipageImage.Height , RasterCachedMultipageImage.Width , RasterCachedMultipageImage.BitsPerPixel , RasterCachedMultipageImage.IsCached , RasterCachedMultipageImage.PageCount , RasterCachedMultipageImage.Pages , RasterCachedMultipageImage.HasAlpha , RasterCachedMultipageImage.HasTransparentColor , RasterCachedMultipageImage.ImageOpacity , RasterCachedMultipageImage.BackgroundColor , RasterCachedMultipageImage.XmpData , RasterCachedMultipageImage.PageExportingAction , RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Change Color Type in DICOM compression.
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions() { ColorType = ColorType.Grayscale8Bit };
inputImage.Save("original_8Bit.dcm", options);
}
Use RLE compression in DICOM image.
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions
{
ColorType = ColorType.Rgb24Bit,
Compression = new Compression
{
Type = CompressionType.Rle
}
};
inputImage.Save("original_RLE.dcm", options);
}
Use JPEG 2000 compression in DICOM image.
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions
{
ColorType = ColorType.Rgb24Bit,
Compression = new Compression
{
Type = CompressionType.Jpeg2000,
Jpeg2000 = new Jpeg2000Options
{
Codec = Jpeg2000Codec.Jp2,
Irreversible = false
}
}
};
inputImage.Save("original_JPEG2000.dcm", options);
}
Use JPEG compression in DICOM image.
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions
{
ColorType = ColorType.Rgb24Bit,
Compression = new Compression
{
Type = CompressionType.Jpeg,
Jpeg = new JpegOptions
{
CompressionType = JpegCompressionMode.Baseline,
SampleRoundingMode = SampleRoundingMode.Truncate,
Quality = 50
}
}
};
inputImage.Save("original_JPEG.dcm", options);
}
This example shows how to load a DICOM image from a file stream.
string dir = "c:\\temp\\";
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.dicom"))
{
using (Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = new Aspose.Imaging.FileFormats.Dicom.DicomImage(stream))
{
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
string fileName = string.Format("sample.{0}.png", dicomPage.Index);
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
Create a multi-page Dicom image.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
Graphics graphics = new Graphics(image);
graphics.FillRectangle(new SolidBrush(Color.BlueViolet), image.Bounds);
graphics.FillRectangle(new SolidBrush(Color.Aqua), 10, 20, 50, 20);
graphics.FillEllipse(new SolidBrush(Color.Orange), 30, 50, 70, 30);
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
image.Save("MultiPage.dcm");
}
Constructors
DicomImage(DicomOptions, int, int)
Initialize a fresh instance of the DicomImage class effortlessly with thisconstructor, utilizing dicomOptions parameters. Perfect for developers lookingto dive into Aspose.Imaging.FileFormats.Dicom.DicomImage objects swiftly and efficiently in their projects.
public DicomImage(DicomOptions dicomOptions, int width, int height)
{
}
Parameters
dicomOptions
DicomOptions
The dicom options.
width
int
The width.
height
int
The height.
DicomImage(Stream, LoadOptions)
Initiate a new instance of the DicomImage class smoothly by employing a stream andloadOptions parameters in this constructor. Ideal for developers eager to startworking with Aspose.Imaging.FileFormats.Dicom.DicomImage objects promptly and effectively in their projects.
public DicomImage(Stream stream, LoadOptions loadOptions)
{
}
Parameters
stream
Stream
The stream.
loadOptions
LoadOptions
The load options.
Examples
This example shows how to load a DICOM image from a file stream to stay within the specified memory limit.
string dir = "c:\\temp\\";
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "multiframe.dicom"))
{
Aspose.Imaging.LoadOptions loadOptions = new Aspose.Imaging.LoadOptions();
loadOptions.BufferSizeHint = 256 * 1024;
using (Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = new Aspose.Imaging.FileFormats.Dicom.DicomImage(stream, loadOptions))
{
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
string fileName = string.Format("multiframe.{0}.png", dicomPage.Index);
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
DicomImage(Stream)
Create a new instance of the DicomImage class by utilizing a stream parameterin this constructor. Perfect for developers seeking a streamlined way to initializeAspose.Imaging.FileFormats.Dicom.DicomImage objects from existing data streams in their projects.
public DicomImage(Stream stream)
{
}
Parameters
stream
Stream
The stream.
Examples
This example shows how to load a DICOM image from a file stream.
string dir = "c:\\temp\\";
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.dicom"))
{
using (Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = new Aspose.Imaging.FileFormats.Dicom.DicomImage(stream))
{
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
string fileName = string.Format("sample.{0}.png", dicomPage.Index);
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
Properties
ActivePage
Manage the active page of the image with this intuitive property. Ideal for developersseeking to dynamically switch between pages within multi-page images, ensuring efficientnavigation and processing.
public DicomPage ActivePage
{
get;
set;
}
Property Value
Exceptions
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-pageimages, ensuring efficient navigation and processing.
public int ActivePageIndex
{
get;
}
Property Value
DicomPages
Access the pages of the image with this intuitive property. Ideal for developersseeking to interact with individual pages within the image, ensuring seamlessnavigation and manipulation.
public DicomPage[] DicomPages
{
get;
}
Property Value
DicomPage []
FileFormat
Retrieve the file format value effortlessly with this intuitive property. Ideal fordevelopers seeking quick access to the format of the image file, ensuring efficienthandling and processing based on the file type.
public override FileFormat
{
get;
}
Property Value
FileInfo
Retrieve valuable header information from the DICOM file effortlessly with thisintuitive property. Ideal for developers seeking quick access to essential detailsencapsulated 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 intuitiveproperty. Ideal for developers seeking to determine if the image contains transparencyinformation, ensuring precise handling of alpha channel data in image processing tasks.
public override bool HasAlpha
{
get;
}
Property Value
PageCount
Retrieve the total page count of the image with this intuitive property. Ideal fordevelopers seeking quick access to the number of pages within an image, ensuringefficient navigation and management.
public override int PageCount
{
get;
}
Property Value
Pages
Access the pages of the image with this intuitive property. Ideal for developersseeking to interact with individual pages within the image, ensuring seamless navigationand manipulation.
public override Image[] Pages
{
get;
}
Property Value
Image []
Methods
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
RasterImage
The page to add.
Exceptions
page’ is null.
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 seamlessintegration and organization of image content.
public DicomPage AddPage()
{
}
The given code is already properly formatted according to standard C# conventions. Therefore, no changes are needed in this case.
Returns
The newly created Aspose.Imaging.FileFormats.Dicom.DicomPage.
Examples
Create a multi-page Dicom image.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
Graphics graphics = new Graphics(image);
graphics.FillRectangle(new SolidBrush(Color.BlueViolet), image.Bounds);
graphics.FillRectangle(new SolidBrush(Color.Aqua), 10, 20, 50, 20);
graphics.FillEllipse(new SolidBrush(Color.Orange), 30, 50, 70, 30);
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
image.Save("MultiPage.dcm");
}
AdjustBrightness(int)
Enhance image luminance with the adjustment of brightness’, aparameterized method that allows developers to finely tune the luminosity of images.This user-friendly function empowers developers to seamlessly manipulate imagebrightness, offering flexibility and control over visual aesthetics.
public override void
AdjustBrightness(int brightness)
{
}
Parameters
brightness
int
Brightness value.
Examples
The following example performs brightness correction of a DICOM image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.AdjustBrightness(50);
dicomImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(float)
Enhance Aspose.Imaging.Image contrast with this user-friendly method,which adjusts the disparity between light and dark areas. Improve visual clarity anddefinition effortlessly, providing developers with intuitive control overimage contrast for optimal rendering.
public override void
AdjustContrast(
float
contrast)
{
}
Parameters
contrast
float
Contrast value (in range [-100; 100])
Examples
The following example performs contrast correction of a DICOM image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.AdjustContrast(50f);
dicomImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(float)
Enhance image quality and adjust it with gamma correction, a powerful techniquefor fine-tuning visual appearance. Perfect for developers aiming to optimize imagepresentation, adjust color balance, and ensure consistent rendering across differentdevices and environments.
public override void AdjustGamma(float gamma)
{
}
Parameters
gamma
float
Gamma for red, green and blue channels coefficient
Examples
The following example performs gamma-correction of a DICOM image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.AdjustGamma(2.5f);
dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(float, float, float)
Achieve precise color adjustments by applying gamma correction independentlyto the red, green, and blue components of an image. This method ensures accuratecolor balance and optimal visual output, catering to developers seeking granularcontrol over image rendering and color accuracy.
public override void AdjustGamma(
float gammaRed,
float gammaGreen,
float gammaBlue
)
Parameters
gammaRed
float
Gamma for red channel coefficient
gammaGreen
float
Gamma for green channel coefficient
gammaBlue
float
Gamma for blue channel coefficient
Examples
The following example performs gamma-correction of a DICOM image applying different coefficients for color components.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.AdjustGamma(1.5f, 2.5f, 3.5f);
dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeBradley(double, int)
Binarize images with Bradley’s adaptive thresholding algorithm, leveraging integralimage thresholding for improved performance. Ideal for developers looking toautomatically segment images based on local variations in brightness, ensuringaccurate object detection and extraction in varying lighting conditions.
public override void BinarizeBradley(
double brightnessDifference,
int windowSize)
{
}
Parameters
brightnessDifference
double
The brightness difference between pixel and the average of an s x s window of pixelscentered around this pixel.
windowSize
int
The size of s x s window of pixels centered around this pixel
Examples
The following example binarizes a DICOM image with Bradley’s adaptive thresholding algorithm with the specified window size. Binarized images contain only 2 colors - black and white.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.BinarizeBradley(5, 10);
dicomImage.Save(dir + "sample.BinarizeBradley5_10x10.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeFixed(byte)
Easily convert the image into a binary format using a predefined thresholdwith this straightforward method. Ideal for developers looking to simplify imageprocessing tasks by segmenting the image into foreground and background componentsbased on specified intensity levels.
public override void BinarizeFixed(byte threshold)
{
}
Parameters
threshold
byte
Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of255 will be assigned to it, 0 otherwise.
Examples
The following example binarizes a DICOM image with the predefined threshold. Binarized images contain only 2 colors - black and white.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
var dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.BinarizeFixed(127);
dicomImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
Apply Otsu thresholding to binarize the image, automatically determining the optimalthreshold value based on the image’s histogram. Perfect for developers seekinga reliable method to segment images into foreground and background regions withminimal manual intervention.
public override void BinarizeOtsu()
{
}
Examples
The following example binarizes a DICOM image with Otsu thresholding. Binarized images contain only 2 colors - black and white.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.BinarizeOtsu();
dicomImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
CacheData()
This method efficiently caches data, optimizing performance and ensuring swift accesswhen needed. Ideal for developers seeking to enhance the speed and efficiency of theirapplications by intelligently managing data resources.
public override void CacheData()
{
}
Examples
The following example shows how to cache all pages of a DICOM image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.CacheData();
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage page in image.DicomPages)
{
page.CacheData();
}
}
Crop(Rectangle)
Crop the image to remove unwanted areas and focus on essential content with thissimple method. Ideal for developers seeking to customize the visual composition ofimages, ensuring they convey the desired message effectively.
public override void Crop(Rectangle rectangle)
{
}
Parameters
rectangle
Rectangle
The rectangle.
Examples
The following example crops a DICOM image. The cropping area is be specified via Aspose.Imaging.Rectangle.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(dicomImage.Width / 4, dicomImage.Height / 4, dicomImage.Width / 2, dicomImage.Height / 2);
dicomImage.Crop(area);
dicomImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
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, ensuringthat important details are retained while eliminating unnecessary elements.
public override void Crop(
int leftShift,
int rightShift,
int topShift,
int bottomShift
)
{
}
Parameters
leftShift
int
The left shift.
rightShift
int
The right shift.
topShift
int
The top shift.
bottomShift
int
The bottom shift.
Examples
The following example crops a DICOM image. The cropping area is specified via Left, Top, Right, Bottom margins.
string dir = @"c:\temp\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
int horizontalMargin = dicomImage.Width / 10;
int verticalMargin = dicomImage.Height / 10;
dicomImage.Crop(horizontalMargin, horizontalMargin, verticalMargin, verticalMargin);
dicomImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int, IColorPalette)
Enhance the current image by applying dithering effects with this straightforwardmethod. 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
DitheringMethod
The dithering method.
bitsCount
int
The final bits count for dithering.
customPalette
IColorPalette
The custom palette for dithering.
Examples
The following example loads a DICOM image and performs threshold and floyd dithering using different palette depth.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);
dicomImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
dicomImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Rectangle, FilterOptionsBase)
Effortlessly enhance specific areas of your image by applying filters to designatedrectangles. This method provides developers with precise control overimage manipulation, allowing for targeted adjustments to achieve desiredvisual effects with ease.
public override void Filter(
Rectangle rectangle,
FilterOptionsBase options)
{
}
Parameters
rectangle
Rectangle
The rectangle.
options
FilterOptionsBase
The options.
Examples
The following example applies various types of filters to a DICOM image.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
dicomImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
dicomImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
dicomImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
dicomImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
dicomImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Filter(dicomImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
dicomImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Grayscale()
Easily transform images into their grayscale representation, simplifying visualanalysis and processing tasks. Perfect for developers seeking to enhance image clarity,reduce complexity, and facilitate efficient grayscale-based algorithmsfor diverse applications.
public override void Grayscale()
{
}
Examples
The following example transforms a colored DICOM image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
var dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Grayscale();
dicomImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertPage(int)
Insert a new page into the image’s page list at a specified index with this intuitivemethod. Ideal for developers seeking precise control over the arrangement of pages inmulti-page images, ensuring seamless organization and customization of image content.
public DicomPage InsertPage(int pageIndex)
{
}
I've formatted your C# code to follow standard conventions. The indentation, spacing, and general readability have been improved. Note that I did not modify any variables, methods, classes, or namespaces as per the given instructions.
Parameters
pageIndex
int
Index of the page.
Returns
The newly created Aspose.Imaging.FileFormats.Dicom.DicomPage.
Examples
Create a multi-page Dicom image.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
Graphics graphics = new Graphics(image);
graphics.FillRectangle(new SolidBrush(Color.BlueViolet), image.Bounds);
graphics.FillRectangle(new SolidBrush(Color.Aqua), 10, 20, 50, 20);
graphics.FillEllipse(new SolidBrush(Color.Orange), 30, 50, 70, 30);
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
image.Save("MultiPage.dcm");
}
Exceptions
pageIndex’ is out of range.
ReleaseManagedResources()
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have beenalready released.
protected override void ReleaseManagedResources()
{
base.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
int
Index of the page.
Exceptions
pageIndex’ is out of range.
Resize(int, int, ResizeType)
Adjust the size of the image with this straightforward method. Ideal for developerslooking to dynamically resize images, ensuring they fit seamlessly into variouscontexts and layouts within their applications.
public override void
Resize(
int newWidth,
int newHeight,
ResizeType resizeType
)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
resizeType
ResizeType
The resize type.
Examples
This example loads a DICOM image and resizes it using various resizing methods.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Resize(int, int, ImageResizeSettings)
Adjust the size of your image with this simple resizing method. Whether you need toshrink or enlarge your image, this function ensures that your resizing needs are metefficiently and accurately, making it perfect for developers seeking quick and easyimage size adjustments.
public override void
Resize(
int newWidth,
int newHeight,
ImageResizeSettings settings)
{
}
Parameters
newWidth
int
The new width.
newHeight
int
The new height.
settings
ImageResizeSettings
The resize settings.
Examples
This example loads a DICOM image and resizes it using various resizing settings.
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
resizeSettings.EntriesCount = 256;
resizeSettings.ColorQuantizationMethod = Aspose.Imaging.ColorQuantizationMethod.None;
resizeSettings.ColorCompareMethod = Aspose.Imaging.ColorCompareMethod.Euclidian;
using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;
dicomImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
dicomImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeHeightProportionally(int, ResizeType)
Adjust the height of the image while maintaining its aspect ratio with thisuser-friendly method. Perfect for developers seeking to dynamically resize imageswhile preserving their proportions, ensuring optimal display and usabilityin their applications.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
{
}
Parameters
newHeight
int
The new height.
resizeType
ResizeType
Type of the resize.
Examples
This example loads a DICOM image and resizes it proportionally using various resizing methods. Only the height is specified, the width is calculated automatically.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeHeightProportionally(image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeHeightProportionally(image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeProportional(int, int, ResizeType)
Resize the image while maintaining its aspect ratio with this convenient method. Idealfor developers seeking to adjust the image dimensions proportionally, ensuringconsistency 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
int
The new width.
newHeight
int
The new height.
resizeType
ResizeType
The resize type.
ResizeWidthProportionally(int, ResizeType)
Adjust the width of the image while maintaining its aspect ratio with this convenientmethod. Ideal for developers seeking to resize images proportionally, ensuringconsistent and visually appealing results across different display environment.
public override void
ResizeWidthProportionally(int newWidth, ResizeType resizeType)
{
}
Parameters
newWidth
int
The new width.
resizeType
ResizeType
Type of the resize.
Examples
This example loads a DICOM image and resizes it proportionally using various resizing methods. Only the width is specified, the height is calculated automatically.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeWidthProportionally(image.Width * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeWidthProportionally(image.Width * 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Rotate(float, bool, Color)
Rotate the image around its center with this convenient method. Ideal for developersseeking to adjust image orientation dynamically, ensuring optimal presentation andalignment within their applications.
public override void Rotate(
float angle,
bool resizeProportionally,
Color backgroundColor
)
{
}
Parameters
angle
float
The rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
bool
if set to ’true’ you will have your image size changedaccording to rotated rectangle (corner points) projections in othercase that leaves dimensions untouched and onlyinternal image contents are rotated.
backgroundColor
Color
Color of the background.
Examples
This example shows how to rotate all pages of a DICOM image and save them all to a multi-frame TIFF image.
string dir = "c:\\temp\\";
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "multiframe.dicom"))
{
using (Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = new Aspose.Imaging.FileFormats.Dicom.DicomImage(stream))
{
dicomImage.Rotate(60, true, Aspose.Imaging.Color.Gray);
Aspose.Imaging.ImageOptions.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createOptions.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Deflate;
createOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
createOptions.BitsPerSample = new ushort[] { 8 };
Aspose.Imaging.FileFormats.Tiff.TiffFrame[] tiffFrames = new Aspose.Imaging.FileFormats.Tiff.TiffFrame[dicomImage.DicomPages.Length];
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
tiffFrames[dicomPage.Index] = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(dicomPage, createOptions);
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(tiffFrames))
{
tiffImage.Save(dir + "multiframe.tif");
}
}
}
RotateFlip(RotateFlipType)
Easily manipulate the active frame by rotating, flipping, or performing both actionssimultaneously with this straightforward method. Ideal for developers who need todynamically adjust the orientation of specific frames within their image sequences,ensuring optimal presentation and alignment.
public override void RotateFlip(RotateFlipType rotateFlipType)
{
}
Parameters
rotateFlipType
RotateFlipType
The rotate flip type.
Examples
This example loads a DICOM image, rotates it by 90 degrees clockwise and optionally flips the image horizontally and(or) vertically.
string dir = "c:\\temp\\";
Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
{
Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
Aspose.Imaging.RotateFlipType.Rotate90FlipX,
Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
Aspose.Imaging.RotateFlipType.Rotate90FlipY
};
foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
{
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
image.RotateFlip(rotateFlipType);
image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
}
}
Save(Stream, ImageOptionsBase, Rectangle)
Easily save your image data to a specified stream in the desired file formatusing 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
Stream
The stream to save the image’s data to.
optionsBase
ImageOptionsBase
The save options.
boundsRectangle
Rectangle
The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.
Examples
The following example loads a DICOM image from a file, then saves the image to a PNG file stream.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(0, 0, image.Width / 2, image.Height / 2);
using (System.IO.Stream outputStream = System.IO.File.Open(dir + "output.png", System.IO.FileMode.Create))
{
image.Save(outputStream, saveOptions, 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 tosecurely store data in various formats while maintaining flexibility and control oversaving parameters.
public void SaveAll(
string filePath,
ImageOptionsBase options
)
{
}
Parameters
filePath
string
The file path.
options
ImageOptionsBase
The options.
SaveData(Stream)
Saves the data.
protected override void
SaveData(
Stream stream
)
{
}
Parameters
stream
Stream
The stream to save data to.
SetResolution(double, double)
Adjust the resolution of this Aspose.Imaging.RasterImage with precision using thisstraightforward method. Ideal for developers looking to tailor image resolution tospecific requirements, ensuring optimal display quality and file size management.
public override void
SetResolution(double dpiX, double dpiY)
{
}
Parameters
dpiX
double
The horizontal resolution, in dots per inch, of the Aspose.Imaging.RasterImage.
dpiY
double
The vertical resolution, in dots per inch, of the Aspose.Imaging.RasterImage.
UpdateDimensions(int, int)
Updates the image dimensions.
protected override void
UpdateDimensions(
int newWidth,
int newHeight)
{
}
Parameters
newWidth
int
The new image width.
newHeight
int
The new image height.