Class DicomImage
Tên không gian: Aspose.Imaging.FileFormats.Dicom Tổng hợp: Aspose.Imaging.dll (25.4.0)
Khóa học này thực hiện hình ảnh kỹ thuật số và truyền thông trong y học(DICOM) hỗ trợ định dạng hình ảnh raster và cung cấp một giải pháp toàn diện choxử lý hình ảnh DICOM với độ chính xác và linh hoạt.thao túng các trang hình ảnh, bao gồm các hoạt động để nhận, thêm hoặc xóa trang, vàkiểm soát các trang mặc định và hoạt động. với khả năng làm việc với các kênh alpha,nhúng XMP metadata, resize, rotate, crop, binaris, điều chỉnh, áp dụng bộ lọc,và chuyển đổi sang các định dạng raster khác. API này cho phép các nhà phát triển để xử lýDICOM hình ảnh hiệu quả trong khi đáp ứng các yêu cầu ứng dụng khác nhau trongHình ảnh hình ảnh y tế.
[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
Thành viên thừa kế
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
Thay đổi kiểu màu trong DICOM Compression.
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions { ColorType = ColorType.Grayscale8Bit };
inputImage.Save("original_8Bit.dcm", options);
}
Sử dụng RLE compression trong hình ảnh DICOM.
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);
}
Sử dụng JPEG 2000 trong hình ảnh DICOM.
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);
}
Sử dụng JPEG trong hình ảnh DICOM.
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);
}
Ví dụ này cho thấy làm thế nào để tải một hình ảnh DICOM từ một dòng tệp.
string dir = "c:\\temp\\";
// Load a DICOM image from a file stream.
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))
{
// Save each page as an individual PNG image.
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
// Generate a file name based on the page index.
string fileName = string.Format("sample.{0}.png", dicomPage.Index);
// A DICOM page is a raster image, so all allowed operations with a raster image are applicable to a DICOM page.
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
Tạo một hình ảnh đa trang Dicom.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
// Draw something using vector graphics
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);
// Save the pixels of the drawn image. They are now on the first page of the Dicom image.
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
// Add a few pages after, making them darker
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
// Add a few pages in front of the main page, making them brighter
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
// Save the created multi-page image to the output file
image.Save("MultiPage.dcm");
}
Constructors
DicomImage(Ưu điểm: int, int)
Bắt đầu một ví dụ mới của lớp DicomImage mà không cố gắng với điều nàynhà xây dựng, sử dụng các thông số dicomOptions. hoàn hảo cho các nhà phát triển xemđể lướt vào các đối tượng Aspose.Imaging.FileFormats.Dicom.Thuyết minh nhanh chóng và hiệu quả trong các dự án của họ.
public DicomImage(DicomOptions dicomOptions, int width, int height)
Parameters
dicomOptions
DicomOptions
Các tùy chọn dicom.
width
int
Chiều rộng .
height
int
Độ cao .
DicomImage(LoadOptions, LoadOptions)
Khởi động một trường hợp mới của lớp DicomImage một cách dễ dàng bằng cách sử dụng một dòng vàtải tùy chọn thông số trong nhà xây dựng này. lý tưởng cho các nhà phát triển mong muốn bắt đầulàm việc với Aspose.Imaging.FileFormats.Dicom.Thuyết minh đối tượng một cách nhanh chóng và hiệu quả trong các dự án của họ.
public DicomImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
dòng chảy
loadOptions
LoadOptions
Các tùy chọn tải.
Examples
Ví dụ này cho thấy làm thế nào để tải một hình ảnh DICOM từ một dòng tệp để ở trong giới hạn bộ nhớ được chỉ định.
string dir = "c:\\temp\\";
// Load a DICOM image from a file stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "multiframe.dicom"))
{
// The max allowed size for all internal buffers is 256KB.
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))
{
// Save each page as an individual PNG image.
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
// Generate a file name based on the page index.
string fileName = string.Format("multiframe.{0}.png", dicomPage.Index);
// A DICOM page is a raster image, so all allowed operations with a raster image are applicable to a DICOM page.
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
DicomImage(Stream)
Tạo một ví dụ mới của lớp DicomImage bằng cách sử dụng một thông số dònghoàn hảo cho các nhà phát triển tìm kiếm một cách nhanh chóng để bắt đầuAspose.Imaging.FileFormats.Dicom.Thuyết minh các đối tượng từ các dữ liệu hiện có trong các dự án của họ.
public DicomImage(Stream stream)
Parameters
stream
Stream
dòng chảy
Examples
Ví dụ này cho thấy làm thế nào để tải một hình ảnh DICOM từ một dòng tệp.
string dir = "c:\\temp\\";
// Load a DICOM image from a file stream.
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))
{
// Save each page as an individual PNG image.
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
// Generate a file name based on the page index.
string fileName = string.Format("sample.{0}.png", dicomPage.Index);
// A DICOM page is a raster image, so all allowed operations with a raster image are applicable to a DICOM page.
dicomPage.Save(dir + fileName, new Aspose.Imaging.ImageOptions.PngOptions());
}
}
}
Properties
ActivePage
Quản lý trang hoạt động của hình ảnh với tài sản trực quan này. lý tưởng cho các nhà phát triểntìm cách chuyển đổi năng động giữa các trang trong hình ảnh nhiều trang, đảm bảo hiệu quảNavigation và xử lý.
public DicomPage ActivePage { get; set; }
Giá trị bất động sản
Exceptions
Trang hoạt động không thể được thiết lập vì nó thuộc về một hình ảnh khác.
ActivePageIndex
Khôi phục chỉ số của trang hoạt động một cách dễ dàng với tài sản trực quan này.Lý tưởng cho các nhà phát triển tìm kiếm truy cập nhanh đến chỉ số trang hiện tại trong nhiều tranghình ảnh, đảm bảo điều hướng và xử lý hiệu quả.
public int ActivePageIndex { get; }
Giá trị bất động sản
DicomPages
Truy cập các trang của hình ảnh với tài sản trực quan này. lý tưởng cho các nhà phát triểntìm cách tương tác với các trang cá nhân trong hình ảnh, đảm bảo không có dấu hiệuNavigation và Manipulation.
public DicomPage[] DicomPages { get; }
Giá trị bất động sản
DicomPage [ ]
FileFormat
Khôi phục lại giá trị định dạng tệp một cách dễ dàng với tài sản trực quan này.các nhà phát triển tìm kiếm truy cập nhanh đến định dạng của tệp hình ảnh, đảm bảo hiệu quảQuản lý và xử lý dựa trên loại tệp.
public override FileFormat FileFormat { get; }
Giá trị bất động sản
FileInfo
Khôi phục thông tin tiêu đề có giá trị từ tệp DICOM một cách dễ dàng với điều nàytài sản trực quan. lý tưởng cho các nhà phát triển tìm kiếm truy cập nhanh đến các chi tiết thiết yếuđược tích hợp trong tệp DICOM, đảm bảo thu thập và phân tích dữ liệu hiệu quả.
public DicomImageInfo FileInfo { get; }
Giá trị bất động sản
HasAlpha
Xác định xem hình ảnh có một kênh alpha không cố gắng với trực quan này hay khônglý tưởng cho các nhà phát triển tìm cách xác định xem hình ảnh có chứa minh bạch hay khôngthông tin, đảm bảo việc xử lý chính xác dữ liệu kênh alpha trong các nhiệm vụ xử lí hình ảnh.
public override bool HasAlpha { get; }
Giá trị bất động sản
PageCount
Đặt lại tổng số trang của hình ảnh với tài sản trực quan này. lý tưởng chocác nhà phát triển tìm kiếm truy cập nhanh đến số trang trong một hình ảnh, đảm bảoQuản lý và vận hành hiệu quả.
public override int PageCount { get; }
Giá trị bất động sản
Pages
Truy cập các trang của hình ảnh với tài sản trực quan này. lý tưởng cho các nhà phát triểntìm cách tương tác với các trang cá nhân trong hình ảnh, đảm bảo điều hướng không dâyvà thao túng.
public override Image[] Pages { get; }
Giá trị bất động sản
Image [ ]
Methods
AddPage(RasterImage)
Mở rộng bộ sưu tập hình ảnh của bạn bằng cách thêm một trang mới với phương pháp trực quan này.Lý tưởng cho các nhà phát triển tìm cách bổ sung năng động các trang đến hình ảnh nhiều trang,đảm bảo sự mở rộng và tổ chức không ngừng của nội dung hình ảnh.
public void AddPage(RasterImage page)
Parameters
page
RasterImage
Trang để thêm.
Exceptions
page’ is null.
AddPage()
Thêm một trang mới vào cuối danh sách trang của hình ảnh với phương pháp đơn giản này.Lý tưởng cho các nhà phát triển muốn mở rộng hình ảnh đa trang một cách năng động, đảm bảo không có dấu vếtKết hợp và tổ chức nội dung hình ảnh.
public DicomPage AddPage()
Returns
Tạo mới Aspose.Imaging.FileFormats.Dicom.Page.
Examples
Tạo một hình ảnh đa trang Dicom.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
// Draw something using vector graphics
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);
// Save the pixels of the drawn image. They are now on the first page of the Dicom image.
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
// Add a few pages after, making them darker
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
// Add a few pages in front of the main page, making them brighter
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
// Save the created multi-page image to the output file
image.Save("MultiPage.dcm");
}
AdjustBrightness(int)
Cải thiện độ sáng của hình ảnh bằng cách điều chỉnh brightness", một phương pháp đo lường cho phép các nhà phát triển để làm sáng hoàn hảo của các bức ảnh.Tính năng thân thiện với người sử dụng này trao quyền cho người phát minh để thao túng khả năng sáng hình, cung cấp sự linh hoạt và kiểm soát về thẩm mỹ thị giác.
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
Giá trị ánh sáng
Examples
Ví dụ sau đây thực hiện điều chỉnh độ sáng của một hình ảnh DICOM.
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;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
dicomImage.AdjustBrightness(50);
dicomImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(Sông)
Cải thiện Aspose.Imaging.Image contrast với phương pháp dễ sử dụng này,điều chỉnh sự khác biệt giữa các khu vực ánh sáng và bóng tối, cải thiện độ sáng thị giác vàđịnh nghĩa nhanh chóng, cung cấp cho các nhà phát triển kiểm soát trực quanHình ảnh tương phản cho rendering tối ưu
public override void AdjustContrast(float contrast)
Parameters
contrast
float
Giá trị tương phản (trong phạm vi [-100; 100])
Examples
Ví dụ sau đây thực hiện điều chỉnh tương phản của một hình ảnh DICOM.
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;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
dicomImage.AdjustContrast(50f);
dicomImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(Sông)
Cải thiện chất lượng hình ảnh và điều chỉnh nó với sửa chữa gamma, một kỹ thuật mạnh mẽhoàn hảo cho các nhà phát triển nhằm tối ưu hóa hình ảnhtrình bày, điều chỉnh sự cân bằng màu sắc, và đảm bảo rendering liên tục qua các khác nhauthiết bị và môi trường.
public override void AdjustGamma(float gamma)
Parameters
gamma
float
Gamma cho các kênh đỏ, xanh và xanh coefficient
Examples
Ví dụ sau đây thực hiện chỉnh sửa gamma của một hình ảnh DICOM.
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;
// Set gamma coefficient for red, green and blue channels.
dicomImage.AdjustGamma(2.5f);
dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(float, float và float)
Thực hiện điều chỉnh màu sắc chính xác bằng cách áp dụng sửa đổi gamma độc lậpvới các thành phần màu đỏ, xanh và xanh của một hình ảnh. phương pháp này đảm bảo chính xáccân bằng màu sắc và kết quả thị giác tối ưu, phục vụ cho các nhà phát triển tìm kiếm granularkiểm soát rendering hình ảnh và độ chính xác màu sắc.
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
Gamma cho Red Channel Coefficient
gammaGreen
float
Gamma cho Green Channel Coefficient
gammaBlue
float
Gamma cho Blue Channel Coefficient
Examples
Ví dụ sau đây thực hiện chỉnh sửa gamma của một hình ảnh DICOM áp dụng các đồng bộ khác nhau cho các thành phần màu.
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;
// Set individual gamma coefficients for red, green and blue channels.
dicomImage.AdjustGamma(1.5f, 2.5f, 3.5f);
dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeBradley(Đôi, int)
Binarize hình ảnh với thuật toán giới hạn thích ứng của Bradley, thả toàn bộhình ảnh giới hạn cho hiệu suất cải thiện. lý tưởng cho các nhà phát triển đang tìm kiếmtự động phân đoạn hình ảnh dựa trên sự thay đổi địa phương trong độ sáng, đảm bảoxác định và khai thác chính xác đối tượng trong các điều kiện chiếu sáng khác nhau.
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
double
Sự khác biệt độ sáng giữa pixel và trung bình của một s x s cửa sổ của pixelstập trung xung quanh pixel này.
windowSize
int
Kích thước của s x s cửa sổ của các pixel tập trung xung quanh pixel này
Examples
Ví dụ sau đây nhị phân một hình ảnh DICOM với thuật toán giới hạn thích ứng của Bradley với kích thước cửa sổ được chỉ định.
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;
// Binarize the image with a brightness difference of 5. The brightness is a difference between a pixel and the average of an 10 x 10 window of pixels centered around this pixel.
dicomImage.BinarizeBradley(5, 10);
dicomImage.Save(dir + "sample.BinarizeBradley5_10x10.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeFixed(byte)
Dễ dàng chuyển đổi hình ảnh thành định dạng nhị phân bằng cách sử dụng một giới hạn được xác định trướcvới phương pháp đơn giản này. lý tưởng cho các nhà phát triển muốn đơn thuần hóa hình ảnhxử lý các nhiệm vụ bằng cách phân loại hình ảnh thành các thành phần trước và nềndựa trên mức độ cường độ cụ thể.
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
Giá trị ranh giới: Nếu giá trị màu xám tương ứng của một pixel lớn hơn so với giới hạn, một255 sẽ được phân bổ cho nó, 0 khác.
Examples
Ví dụ sau đây nhị phân một hình ảnh DICOM với ranh giới được xác định trước. Hình ảnh binary chỉ chứa 2 màu - đen và trắng.
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;
// Binarize the image with a threshold value of 127.
// If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
dicomImage.BinarizeFixed(127);
dicomImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
Ứng dụng Otsu thang để nhị phân hình ảnh, tự động xác định tối ưugiá trị giới hạn dựa trên histogram của hình ảnh. hoàn hảo cho các nhà phát triển tìm kiếmmột phương pháp đáng tin cậy để phân đoạn hình ảnh vào các khu vực phía trước và nền vớiPhản ứng thủ công tối thiểu
public override void BinarizeOtsu()
Examples
Ví dụ sau đây nhị phân một hình ảnh DICOM với Otsu thang. Hình ảnh nhí chứa chỉ 2 màu - đen và trắng.
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;
// Binarize the image with Otsu thresholding.
dicomImage.BinarizeOtsu();
dicomImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
CacheData()
Phương pháp này cache dữ liệu một cách hiệu quả, tối ưu hóa hiệu suất và đảm bảo truy cập nhanhlý tưởng cho các nhà phát triển tìm cách tăng tốc độ và hiệu quả củaứng dụng bằng cách quản lý thông minh các nguồn dữ liệu.
public override void CacheData()
Examples
Ví dụ sau đây cho thấy cách cache tất cả các trang của một hình ảnh DICOM.
string dir = "c:\\temp\\";
// Load an image from a DICOM file.
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
// This call caches all the pages so that no additional data loading will be performed from the underlying data stream.
image.CacheData();
// Or you can cache the pages individually.
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage page in image.DicomPages)
{
page.CacheData();
}
}
Crop(Rectangle)
trồng hình ảnh để loại bỏ các khu vực không mong muốn và tập trung vào nội dung thiết yếu với điều nàyphương pháp đơn giản. lý tưởng cho các nhà phát triển tìm cách tùy chỉnh thành phần thị giác củahình ảnh, đảm bảo họ truyền tải tin nhắn mong muốn một cách hiệu quả.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
Vòng thẳng.
Examples
Ví dụ sau đây trồng một hình ảnh DICOM. khu vực trồng được chỉ định thông qua 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;
// Crop the image. The cropping area is the rectangular central area of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(dicomImage.Width / 4, dicomImage.Height / 4, dicomImage.Width / 2, dicomImage.Height / 2);
dicomImage.Crop(area);
// Save the cropped image to PNG
dicomImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Crop(int, int, int, int, int)
Tùy chỉnh khu vực đào của hình ảnh bằng cách áp dụng thay đổi với phương pháp đa dạng này.Tốt cho các nhà phát triển cần kiểm soát chính xác quá trình khai thác, đảm bảonhững chi tiết quan trọng được giữ lại trong khi loại bỏ các yếu tố không cần thiết.
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
bên trái thay đổi.
rightShift
int
Chuyển đổi đúng
topShift
int
Thay đổi hàng đầu
bottomShift
int
Thay đổi bên dưới.
Examples
Ví dụ sau đây trồng một hình ảnh DICOM. khu vực trồng được chỉ định thông qua bên trái, trên, bên phải, dưới cùng.
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;
// Crop again. Set a margin of 10% of the image size.
int horizontalMargin = dicomImage.Width / 10;
int verticalMargin = dicomImage.Height / 10;
dicomImage.Crop(horizontalMargin, horizontalMargin, verticalMargin, verticalMargin);
// Save the cropped image to PNG.
dicomImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int, IColorPalette)
Cải thiện hình ảnh hiện tại bằng cách áp dụng hiệu ứng dithering với điều này đơn giảnPhương pháp. hoàn hảo cho các nhà phát triển nhằm mục đích thêm cấu trúc và độ sâu vào hình ảnh,cải thiện chất lượng thị giác và hấp dẫn tổng thể của họ.
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
Phương pháp di chuyển.
bitsCount
int
Các bit cuối cùng đếm cho dithering.
customPalette
IColorPalette
Thói quen của palette cho dithering.
Examples
Ví dụ sau đây tải một hình ảnh DICOM và thực hiện giới hạn và chảy chảy bằng cách sử dụng độ sâu palette khác nhau.
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;
// Perform threshold dithering using 4-bit color palette which contains 16 colors.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
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;
// Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
dicomImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
dicomImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Xác định, FilterOptionsBase)
Tăng cường nhanh chóng các khu vực cụ thể của hình ảnh của bạn bằng cách áp dụng các bộ lọc chophương pháp này cung cấp cho các nhà phát triển kiểm soát chính xácthao tác hình ảnh, cho phép các điều chỉnh nhắm mục tiêu để đạt được mong muốnHiệu ứng thị giác dễ dàng
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
Vòng thẳng.
options
FilterOptionsBase
Các tùy chọn.
Examples
Ví dụ sau đây áp dụng các loại bộ lọc khác nhau cho một hình ảnh DICOM.
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;
// Apply a median filter with a rectangle size of 5 to the entire 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;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire 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;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire 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;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire 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;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire 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;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire 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()
Dễ dàng chuyển đổi hình ảnh thành đại diện grayscale của họ, đơn giản hóa thị giáccông việc phân tích và xử lý. hoàn hảo cho các nhà phát triển tìm cách cải thiện độ rõ rệt của hình ảnh,Giảm sự phức tạp và tạo điều kiện cho các thuật toán dựa trên grayscale hiệu quảcho các ứng dụng khác nhau.
public override void Grayscale()
Examples
Ví dụ sau đây chuyển đổi một hình ảnh màu DICOM thành đại diện màu xám của nó. Hình ảnh Grayscale được tạo thành độc quyền từ bóng màu xanh và chỉ mang thông tin cường độ.
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.Grayscale();
dicomImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertPage(int)
Nhập một trang mới vào danh sách trang của hình ảnh trên một chỉ số cụ thể với trực quan nàyphương pháp. lý tưởng cho các nhà phát triển tìm kiếm sự kiểm soát chính xác về việc sắp xếp các trang trongHình ảnh nhiều trang, đảm bảo tổ chức không thể bỏ qua và tùy chỉnh nội dung hình ảnh.
public DicomPage InsertPage(int pageIndex)
Parameters
pageIndex
int
Index của trang.
Returns
Tạo mới Aspose.Imaging.FileFormats.Dicom.Page.
Examples
Tạo một hình ảnh đa trang Dicom.
using (DicomImage image = (DicomImage)Image.Create(
new DicomOptions() { Source = new StreamSource(new MemoryStream()) },
100,
100))
{
// Draw something using vector graphics
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);
// Save the pixels of the drawn image. They are now on the first page of the Dicom image.
int[] pixels = image.LoadArgb32Pixels(image.Bounds);
// Add a few pages after, making them darker
for (int i = 1; i < 5; i++)
{
DicomPage page = image.AddPage();
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(i * 30);
}
// Add a few pages in front of the main page, making them brighter
for (int i = 1; i < 5; i++)
{
DicomPage page = image.InsertPage(0);
page.SaveArgb32Pixels(page.Bounds, pixels);
page.AdjustBrightness(-i * 30);
}
// Save the created multi-page image to the output file
image.Save("MultiPage.dcm");
}
Exceptions
pageIndex’ is out of range.
ReleaseManagedResources()
Hãy chắc chắn rằng không có tài nguyên không được quản lý được phát hành ở đây, vì chúng có thể đã đượcđã được phát hành.
protected override void ReleaseManagedResources()
RemovePage(int)
Xóa trang trên chỉ mục cụ thể từ danh sách trang bằng phương pháp thuận tiện này.Lý tưởng cho các nhà phát triển tìm kiếm sự kiểm soát chính xác về việc quản lý hình ảnh nhiều trang,đảm bảo tổ chức không ngừng và tùy chỉnh nội dung hình ảnh.
public void RemovePage(int pageIndex)
Parameters
pageIndex
int
Index của trang.
Exceptions
pageIndex’ is out of range.
Resize(int, int, resizeType)
Điều chỉnh kích thước của hình ảnh với phương pháp đơn giản này. lý tưởng cho các nhà phát triểntìm cách khôi phục lại hình ảnh một cách năng động, đảm bảo chúng phù hợp không ngừng với các loại hình khác nhaubối cảnh và bố trí trong các ứng dụng của họ.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
Chiều rộng mới
newHeight
int
Độ cao mới
resizeType
ResizeType
Loại Resize
Examples
Ví dụ này tải một hình ảnh DICOM và resize nó bằng cách sử dụng các phương pháp resizing khác nhau.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
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"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
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"))
{
// Scale up by 2 times using Bilinear resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
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"))
{
// Scale down by 2 times using Bilinear resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Resize(int, int, ImageResizeSettings)
Điều chỉnh kích thước của hình ảnh của bạn với phương pháp resizing đơn giản này.cắt giảm hoặc mở rộng hình ảnh của bạn, chức năng này đảm bảo rằng nhu cầu tái tạo của mình được đáp ứnghiệu quả và chính xác, làm cho nó hoàn hảo cho các nhà phát triển tìm kiếm nhanh chóng và dễ dàngTùy chỉnh kích thước hình ảnh
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
Chiều rộng mới
newHeight
int
Độ cao mới
settings
ImageResizeSettings
Các thiết lập resize.
Examples
Ví dụ này tải một hình ảnh DICOM và resize nó bằng cách sử dụng các cài đặt resizing khác nhau.
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
// The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
// The small rectangular filter
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
// The number of colors in the palette.
resizeSettings.EntriesCount = 256;
// The color quantization is not used
resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;
// The euclidian method
resizeSettings.ColorCompareMethod = 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;
// Scale down by 2 times using adaptive resampling.
dicomImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
// Save to PNG
dicomImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeHeightProportionally(Nhãn hiệu: ResizeType)
Điều chỉnh chiều cao của hình ảnh trong khi duy trì tỷ lệ khía cạnh của nó với điều nàyphương pháp thân thiện với người dùng. hoàn hảo cho các nhà phát triển tìm cách khôi phục hình ảnh một cách năng độngtrong khi duy trì tỷ lệ của chúng, đảm bảo hiển thị tối ưu và khả năng sử dụngtrong các ứng dụng của họ.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
Độ cao mới
resizeType
ResizeType
Loại của resize.
Examples
Ví dụ này tải một hình ảnh DICOM và resize nó tương đối bằng cách sử dụng các phương pháp resizing khác nhau. chỉ chiều cao được chỉ định, chiều rộng được tính toán tự động.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
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"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
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"))
{
// Scale up by 2 times using Bilinear resampling.
image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
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"))
{
// Scale down by 2 times using Bilinear resampling.
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeProportional(int, int, resizeType)
Tạo lại hình ảnh trong khi duy trì tỷ lệ khía cạnh của nó với phương pháp thuận tiện này. lý tưởng cho các nhà phát triển tìm cách điều chỉnh các kích cỡ ảnh một cách tương đối, đảm bảo sự tuân thủ và bảo tồn các tỉ lệ của nội dung ban đầu.Điều chỉnh tương tự sẽ làm lại mỗi khung theo tỷ số của newWidth’/width và <các code class=parama>newHeight’ / height.
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
Chiều rộng mới
newHeight
int
Độ cao mới
resizeType
ResizeType
Loại Resize
ResizeWidthProportionally(Nhãn hiệu: ResizeType)
Điều chỉnh chiều rộng của hình ảnh trong khi duy trì tỷ lệ khía cạnh của nó với điều này thuận tiệnphương pháp. lý tưởng cho các nhà phát triển tìm cách khôi phục hình ảnh một cách tương đối, đảm bảokết quả liên tục và hấp dẫn trực quan trên các môi trường hiển thị khác nhau.
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
Chiều rộng mới
resizeType
ResizeType
Loại của resize.
Examples
Ví dụ này tải một hình ảnh DICOM và resize nó tương đối bằng cách sử dụng các phương pháp resizing khác nhau. chỉ có chiều rộng được chỉ định, chiều cao được tính toán tự động.
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Dicom.DicomImage image = (Aspose.Imaging.FileFormats.Dicom.DicomImage)Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
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"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
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"))
{
// Scale up by 2 times using Bilinear resampling.
image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
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"))
{
// Scale down by 2 times using Bilinear resampling.
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Rotate(Float, Bool, Màu sắc)
xoay hình ảnh xung quanh trung tâm của nó với phương pháp thuận tiện này. lý tưởng cho các nhà phát triểntìm cách điều chỉnh định hướng hình ảnh một cách năng động, đảm bảo trình bày tối ưu vàphù hợp trong các ứng dụng của họ.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
góc xoay trong độ. giá trị tích cực sẽ xoay theo cách đồng hồ.
resizeProportionally
bool
Nếu được thiết lập để ’truyền’ bạn sẽ có kích thước hình ảnh của bạn thay đổi theo các dự án thẳng góc (các điểm góc) quay trong trường hợp khác để lại các kích cỡ không bị chạm và chỉ nội bộ nội dung ảnh được quay.
backgroundColor
Color
Màu sắc của nền
Examples
Ví dụ này cho thấy làm thế nào để xoay tất cả các trang của một hình ảnh DICOM và tiết kiệm chúng hết cho một Hình ảnh TIFF đa khung.
string dir = "c:\\temp\\";
// Load a DICOM image from a file stream.
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))
{
// Rotate the image around the center by 60 degrees clockwise.
// Use gray as the background color.
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;
// Note that if the image is colorful, it will be automatically converted to the grayscale format according to the options below
createOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
createOptions.BitsPerSample = new ushort[] { 8 };
// Create an array of TIFF frames.
// The number of the frames is equal to the number of the DJVU pages.
Aspose.Imaging.FileFormats.Tiff.TiffFrame[] tiffFrames = new Aspose.Imaging.FileFormats.Tiff.TiffFrame[dicomImage.DicomPages.Length];
// Save each page as an individual TIFF frame.
foreach (Aspose.Imaging.FileFormats.Dicom.DicomPage dicomPage in dicomImage.DicomPages)
{
// Create a TIFF frame based on the DICOM page.
tiffFrames[dicomPage.Index] = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(dicomPage, createOptions);
}
// Compose a TIFF image from the frames.
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(tiffFrames))
{
// Save to a file.
tiffImage.Save(dir + "multiframe.tif");
}
}
}
RotateFlip(RotateFlipType)
Dễ dàng thao túng khung hoạt động bằng cách xoay, trượt hoặc thực hiện cả hai hành độngđồng thời với phương pháp đơn giản này. lý tưởng cho các nhà phát triển cầnnăng động điều chỉnh định hướng của các khung cụ thể trong chuỗi hình ảnh của họ,đảm bảo sự trình bày và phù hợp tối ưu.
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
Loại Flip Rotate
Examples
Ví dụ này tải một hình ảnh DICOM, xoay nó bằng 90 độ theo chiều đồng hồ và tùy chọn nhấp vào hình dạng ngang và/hoặc dọc.
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)
{
// Rotate, flip and save to the output file.
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)
Dễ dàng lưu dữ liệu hình ảnh của bạn vào một dòng cụ thể trong định dạng tệp mong muốnsử dụng phương pháp thuận tiện này. cho dù bạn đang làm việc với JPEG, PNG, hoặc định dạng khác,chức năng này đảm bảo rằng dữ liệu hình ảnh của bạn được lưu trữ một cách hiệu quả và chính xác,làm cho nó lý tưởng cho các nhà phát triển muốn làm nhanh hơn các quá trình lưu trữ tệp của họ.
public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
Stream để lưu dữ liệu của hình ảnh đến.
optionsBase
ImageOptionsBase
Các tùy chọn tiết kiệm
boundsRectangle
Rectangle
Mục đích hình ảnh giới hạn trực tiếp. thiết lập trực tiếp trống để sử dụng giới hạn nguồn.
Examples
Ví dụ sau đây tải lên một hình ảnh DICOM từ một tệp, sau đó lưu ảnh vào một dòng file PNG.
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))
{
// Save the upper-left quarter of the image to a file stream.
image.Save(outputStream, saveOptions, bounds);
}
}
SaveAll(Thẻ, ImageOptionsBase)
Lưu dữ liệu của đối tượng bằng cách lưu nó vào tệp được chỉ định (indexer + file name)vị trí cùng với định dạng tệp cụ thể và tùy chọn. lý tưởng cho các nhà phát triển tìm kiếmbảo mật lưu trữ dữ liệu trong các định dạng khác nhau trong khi duy trì tính linh hoạt và kiểm soátCác thông số tiết kiệm
public void SaveAll(string filePath, ImageOptionsBase options)
Parameters
filePath
string
đường file.
options
ImageOptionsBase
Các tùy chọn.
SaveData(Stream)
Tiết kiệm dữ liệu
protected override void SaveData(Stream stream)
Parameters
stream
Stream
Stream để lưu dữ liệu đến.
SetResolution(đôi, double)
Điều chỉnh độ phân giải của Aspose.Imaging.RasterImage với độ chính xác bằng cách sử dụng điều nàyphương pháp đơn giản. lý tưởng cho các nhà phát triển muốn điều chỉnh độ phân giải hình ảnh đểyêu cầu cụ thể, đảm bảo chất lượng hiển thị tối ưu và quản lý kích thước tệp.
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
double
Độ phân giải ngang, ở điểm mỗi inch, của Aspose.Imaging.RasterImage.
dpiY
double
Độ phân giải dọc, ở điểm mỗi inch, của Aspose.Imaging.RasterImage.
UpdateDimensions(int, int)
Cập nhật kích thước hình ảnh.
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
Hình ảnh mới rộng.
newHeight
int
Độ cao hình ảnh mới.