Class DicomImage
ชื่อพื้นที่: Aspose.Imaging.FileFormats.Dicom การประกอบ: Aspose.Imaging.dll (25.4.0)
หลักสูตรนี้นําไปใช้ภาพดิจิตอลและการสื่อสารในแพทย์(DICOM) สนับสนุนรูปแบบภาพสกรูและมีโซลูชันที่ครอบคลุมสําหรับการประมวลผลภาพ DICOM ด้วยความแม่นยําและความยืดหยุ่น คุณสามารถการจัดการหน้าภาพรวมถึงการดําเนินการเพื่อรับการเพิ่มหรือลบหน้าและการควบคุมหน้าเริ่มต้นและใช้งาน ด้วยความสามารถในการทํางานกับช่องอัลฟาใส่ XMP metadata, resize, rotate, crop, binarize, ปรับ, ใช้ตัวกรอง,และแปลงเป็นรูปแบบ raster อื่น ๆ API นี้ช่วยให้ผู้พัฒนาจัดการDICOM ภาพได้อย่างมีประสิทธิภาพในขณะที่ตอบสนองความต้องการการใช้งานที่แตกต่างกันในรูปภาพทางการแพทย์
[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
อนุญาโตตุลาการ
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
เปลี่ยนประเภทสีในการบีบอัด DICOM
using (var inputImage = Image.Load("original.jpg"))
{
var options = new DicomOptions { ColorType = ColorType.Grayscale8Bit };
inputImage.Save("original_8Bit.dcm", options);
}
ใช้การบีบอัด RLE ในภาพ 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);
}
ใช้การบีบอัด JPEG 2000 ในภาพ 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);
}
ใช้การบีบอัด JPEG ในภาพ 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);
}
ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ DICOM จากการไหลของไฟล์
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());
}
}
}
สร้างภาพ 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(DicomOptions, int, int)
เริ่มต้นตัวอย่างใหม่ของชั้น DicomImage โดยไม่พยายามด้วยเรื่องนี้constructor, ใช้ dicomOptions พารามิเตอร์ เหมาะสําหรับนักพัฒนาที่มองเห็นการดูดใน Aspose.Imaging.FileFormats.Dicom.DicomImage วัตถุได้อย่างรวดเร็วและมีประสิทธิภาพในโครงการของพวกเขา
public DicomImage(DicomOptions dicomOptions, int width, int height)
Parameters
dicomOptions
DicomOptions
ตัวเลือกไดรฟ์
width
int
ความกว้าง
height
int
ความสูง
DicomImage(แหล่งจ่ายไฟ LoadOptions)
เริ่มต้นตัวอย่างใหม่ของ DicomImage คลาสได้อย่างราบรื่นโดยใช้กระแสและload ตัวเลือกพารามิเตอร์ในเครื่องสร้างนี้ เหมาะสําหรับนักพัฒนาที่ต้องการเริ่มต้นการทํางานร่วมกับ Aspose.Imaging.FileFormats.Dicom.DicomImage วัตถุอย่างรวดเร็วและมีประสิทธิภาพในโครงการของพวกเขา
public DicomImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
กระแส
loadOptions
LoadOptions
ตัวเลือกโหลด
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ DICOM จากการไหลของไฟล์เพื่ออยู่ภายในขอบเขตหน่วยความจําที่ระบุ
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)
สร้างตัวอย่างใหม่ของชั้น DicomImage โดยใช้พารามิเตอร์ไหลใน constructor นี้ เหมาะสําหรับนักพัฒนาที่กําลังมองหาวิธีที่เรียบง่ายในการเริ่มต้นAspose.Imaging.FileFormats.Dicom.DicomImage วัตถุจากการไหลของข้อมูลที่มีอยู่ในโครงการของพวกเขา
public DicomImage(Stream stream)
Parameters
stream
Stream
กระแส
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ DICOM จากการไหลของไฟล์
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
การจัดการหน้าที่มีการใช้งานของภาพด้วยคุณสมบัติการใช้งานนี้เหมาะสําหรับนักพัฒนากําลังมองหาการเปลี่ยนทางไดนามิกระหว่างหน้าภายในภาพหลายหน้าเพื่อให้แน่ใจว่ามีประสิทธิภาพการนําทางและการประมวลผล
public DicomPage ActivePage { get; set; }
คุณสมบัติมูลค่า
Exceptions
หน้าที่ใช้งานไม่สามารถตั้งค่าได้เนื่องจากเป็นภาพอื่น
ActivePageIndex
ปรับตัวเลขของหน้าใช้งานได้อย่างง่ายดายด้วยคุณสมบัติการใช้งานนี้เหมาะสําหรับนักพัฒนาที่กําลังมองหาการเข้าถึงที่รวดเร็วของหน้าปัจจุบันภายในหลายหน้าภาพเพื่อให้แน่ใจว่าการนําทางและประมวลผลได้อย่างมีประสิทธิภาพ
public int ActivePageIndex { get; }
คุณสมบัติมูลค่า
DicomPages
การเข้าถึงหน้าของภาพด้วยคุณสมบัติที่ใช้งานง่ายนี้ เหมาะสําหรับนักพัฒนากําลังมองหาการโต้ตอบกับหน้าส่วนบุคคลภายในภาพเพื่อให้แน่ใจว่าไม่มีรอยต่อการนําทางและการจัดการ
public DicomPage[] DicomPages { get; }
คุณสมบัติมูลค่า
DicomPage [ ]
FileFormat
ปรับปรุงค่ารูปแบบไฟล์ได้อย่างง่ายดายด้วยคุณสมบัติที่ใช้งานง่ายนี้ เหมาะสําหรับผู้พัฒนาที่กําลังมองหาการเข้าถึงอย่างรวดเร็วไปยังรูปแบบไฟล์ภาพเพื่อให้แน่ใจว่ามีประสิทธิภาพการจัดการและการประมวลผลตามประเภทไฟล์
public override FileFormat FileFormat { get; }
คุณสมบัติมูลค่า
FileInfo
รับข้อมูลหัวที่มีค่าจากไฟล์ DICOM ได้อย่างง่ายดายด้วยนี้คุณสมบัติทางวิสัยทัศน์ เหมาะสําหรับนักพัฒนาที่กําลังมองหาการเข้าถึงข้อมูลที่สําคัญอย่างรวดเร็วencapsulated ในไฟล์ DICOM เพื่อให้แน่ใจว่าการสกัดและวิเคราะห์ข้อมูลที่มีประสิทธิภาพ
public DicomImageInfo FileInfo { get; }
คุณสมบัติมูลค่า
HasAlpha
ตรวจสอบว่าภาพมีช่องอัลฟาได้อย่างง่ายดายด้วยอินเทอร์เน็ตนี้คุณสมบัติ เหมาะสําหรับนักพัฒนาที่ต้องการตรวจสอบว่าภาพมีโปร่งใสหรือไม่ข้อมูลให้แน่ใจว่าการจัดการข้อมูลช่องอัลฟาอย่างแม่นยําในการประมวลผลภาพ
public override bool HasAlpha { get; }
คุณสมบัติมูลค่า
PageCount
รับจํานวนหน้าทั้งหมดของภาพด้วยคุณสมบัติที่ใช้งานง่ายนี้ เหมาะสําหรับผู้พัฒนาที่กําลังมองหาการเข้าถึงได้อย่างรวดเร็วจํานวนหน้าภายในภาพเพื่อให้แน่ใจว่าการนําทางและจัดการอย่างมีประสิทธิภาพ
public override int PageCount { get; }
คุณสมบัติมูลค่า
Pages
การเข้าถึงหน้าของภาพด้วยคุณสมบัติที่ใช้งานง่ายนี้ เหมาะสําหรับนักพัฒนาค้นหาการโต้ตอบกับหน้าส่วนบุคคลภายในภาพเพื่อให้แน่ใจว่าการนําทางไร้สายและการจัดการ
public override Image[] Pages { get; }
คุณสมบัติมูลค่า
Image [ ]
Methods
AddPage(RasterImage)
การขยายการเก็บรวบรวมภาพของคุณโดยการเพิ่มหน้าใหม่ด้วยวิธีการที่ใช้งานง่ายนี้เหมาะสําหรับนักพัฒนาที่กําลังมองหาการเชื่อมต่อแบบไดนามิกของหน้าไปยังภาพหลายหน้าเพื่อให้แน่ใจว่ามีการขยายและจัดระเบียบเนื้อหาภาพได้อย่างราบรื่น
public void AddPage(RasterImage page)
Parameters
page
RasterImage
หน้าที่เพิ่ม
Exceptions
page’ is null.
AddPage()
เพิ่มหน้าใหม่ไปยังปลายรายการหน้าของภาพด้วยวิธีการที่เรียบง่ายนี้เหมาะสําหรับนักพัฒนาที่กําลังมองหาการขยายภาพหลายหน้าอย่างไดนามิกเพื่อให้แน่ใจว่าไม่มีรอยต่อการรวมและการจัดเตรียมเนื้อหาภาพ
public DicomPage AddPage()
Returns
ที่สร้างขึ้นใหม่ Aspose.Imaging.FileFormats.Dicom.DicomPage
Examples
สร้างภาพ 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)
ปรับปรุงความสว่างของภาพโดยการปรับตัวของ brightness" วิธีการที่ปรับตัวช่วยให้ผู้พัฒนาสามารถปรับความสว่างของภาพได้อย่างสมบูรณ์แบบ ฟังก์ชั่นที่ใช้งานง่ายนี้ช่วยให้ผู้พัฒนาสามารถจัดการความสว่างของภาพได้อย่างราบรื่นให้มีความยืดหยุ่นและควบคุมความงามภาพ
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
ความสว่าง
Examples
ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขความสว่างของภาพ 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(เฟอร์รี่)
ปรับปรุง Aspose.Imaging.Image contrast กับวิธีการที่ใช้งานง่ายนี้ที่ปรับความแตกต่างระหว่างพื้นที่แสงและสีดํา เพิ่มความชัดเจนของภาพและการกําหนดค่าได้อย่างง่ายดายเพื่อให้ผู้พัฒนามีการควบคุมทางวิสัยทัศน์ภาพ contrast สําหรับ rendering ที่ดีที่สุด
public override void AdjustContrast(float contrast)
Parameters
contrast
float
คะแนนความต้านทาน (ในช่วง [-100; 100])
Examples
ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขข้อตกลงของภาพ 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(เฟอร์รี่)
ปรับปรุงคุณภาพของภาพและปรับได้ด้วยการแก้ไขเกัมม้าเทคนิคที่มีประสิทธิภาพเหมาะสําหรับนักพัฒนาที่มุ่งมั่นที่จะเพิ่มประสิทธิภาพของภาพแสดงการปรับสมดุลสีและให้แน่ใจว่าการแสดงผลที่สอดคล้องกันผ่านการแตกต่างกันอุปกรณ์และสภาพแวดล้อม
public override void AdjustGamma(float gamma)
Parameters
gamma
float
GAMMA สําหรับช่องแดงสีเขียวและสีน้ําเงิน
Examples
ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขแก๊มของภาพ 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(เฟอร์รี่, เฟอร์รี่, เฟอร์รี่)
ได้รับการปรับสีที่แม่นยําโดยใช้การแก้ไขเกัมม้าอย่างอิสระสําหรับส่วนประกอบสีแดงสีเขียวและสีน้ําเงินของภาพ วิธีนี้ให้แน่ใจว่าความแม่นยําความสมดุลสีและผลผลิตภาพที่ดีที่สุดให้ผู้พัฒนาที่กําลังมองหาเม็ดการควบคุมการแสดงภาพและความแม่นยําของสี
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
Gamma สําหรับช่องแดง Coefficient
gammaGreen
float
Gamma สําหรับ Coefficient ช่องสีเขียว
gammaBlue
float
Gamma สําหรับ Coefficient ช่องสีฟ้า
Examples
ตัวอย่างต่อไปนี้จะทําการแก้ไขรูป DICOM โดยใช้ koeficients ที่แตกต่างกันสําหรับองค์ประกอบสี
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(สอง, int)
ภาพไบนารีด้วยอัลลกอริทึมการปรับตัวของ Bradleyภาพข้อ จํากัด สําหรับประสิทธิภาพที่ดีขึ้น เหมาะสําหรับนักพัฒนาที่กําลังมองหาการแบ่งภาพโดยอัตโนมัติขึ้นอยู่กับความแตกต่างในความสว่างในท้องถิ่นเพื่อให้แน่ใจว่าการตรวจจับและสกัดวัตถุที่แม่นยําในเงื่อนไขการสว่างที่แตกต่างกัน
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
double
ความแตกต่างของความสว่างระหว่างพิกเซลและเฉลี่ยของหน้าต่าง s x s ของพิกเซลมุ่งเน้นรอบพิกเซลนี้
windowSize
int
ขนาดหน้าต่าง s x s ของพิกเซลที่มุ่งเน้นรอบพิกเซลนี้
Examples
ตัวอย่างต่อไปนี้ไบนารีภาพ DICOM กับแอลกอริทึมการปรับแต่งของ Bradley กับขนาดหน้าต่างที่ระบุ ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว
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(บิต)
แปลงภาพได้อย่างง่ายดายในรูปแบบไบนารีโดยใช้ข้อ จํากัด ที่กําหนดไว้ด้วยวิธีการที่เรียบง่ายนี้ เหมาะสําหรับนักพัฒนาที่ต้องการทําให้ภาพง่ายขึ้นการประมวลผลงานโดยการแบ่งภาพเป็นส่วนประกอบด้านหน้าและพื้นหลังตามระดับความเข้มที่ระบุ
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
หมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลขหมายเลข255 จะถูกกําหนดไว้กับมัน 0 อื่น ๆ
Examples
ตัวอย่างต่อไปนี้ไบนารีภาพ DICOM กับข้อ จํากัด ที่กําหนดไว้ ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว
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()
ใช้ Otsu เกรดเพื่อไบนารีภาพโดยอัตโนมัติกําหนดที่ดีที่สุดหมายถึงข้อ จํากัด ตาม histogram ของภาพ เหมาะสําหรับนักพัฒนาที่กําลังมองหาวิธีที่เชื่อถือได้ในการแบ่งภาพไปยังพื้นที่ด้านหน้าและพื้นหลังการ intervention มินิ
public override void BinarizeOtsu()
Examples
ตัวอย่างต่อไปนี้ไบนารีภาพ DICOM กับ Otsu เกรด ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว
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()
วิธีการนี้ cache ข้อมูลได้อย่างมีประสิทธิภาพเพิ่มประสิทธิภาพและให้การเข้าถึงได้อย่างรวดเร็วเหมาะสําหรับนักพัฒนาที่ต้องการปรับปรุงความเร็วและประสิทธิภาพของพวกเขาการใช้งานโดยการจัดการทรัพยากรข้อมูลอย่างชาญฉลาด
public override void CacheData()
Examples
ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการเข้ารหัสหน้าทั้งหมดของภาพ 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)
พืชภาพเพื่อกําจัดพื้นที่ที่ไม่พึงประสงค์และมุ่งเน้นไปที่เนื้อหาที่สําคัญด้วยนี้วิธีการง่ายๆ เหมาะสําหรับนักพัฒนาที่ต้องการปรับแต่งองค์ประกอบภาพของภาพให้แน่ใจว่าพวกเขาส่งข้อความที่ต้องการได้อย่างมีประสิทธิภาพ
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
ตุ๊กตา
Examples
ตัวอย่างต่อไปนี้จะปลูกภาพ DICOM พื้นที่ปลูกจะระบุผ่าน 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)
การปรับพื้นที่การกัดกร่อนของภาพโดยใช้การเปลี่ยนแปลงด้วยวิธีการที่หลากหลายนี้เหมาะสําหรับนักพัฒนาที่ต้องการการควบคุมอย่างแม่นยําของกระบวนการเก็บเกี่ยวเพื่อให้แน่ใจว่าที่รายละเอียดที่สําคัญจะถูกเก็บไว้ในขณะที่กําจัดองค์ประกอบที่ไม่จําเป็น
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
เปลี่ยนด้านซ้าย
rightShift
int
เปลี่ยนที่เหมาะสม
topShift
int
เปลี่ยนด้านบน
bottomShift
int
เปลี่ยนด้านล่าง
Examples
ตัวอย่างต่อไปนี้จะปลูกรูปภาพ 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;
// 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)
ปรับปรุงภาพปัจจุบันโดยใช้ผลกระทบไทเทรี่ด้วยเรื่องนี้ได้อย่างง่ายดายวิธีการ เหมาะสําหรับนักพัฒนาที่มุ่งมั่นที่จะเพิ่มโครงสร้างและความลึกให้กับภาพการปรับปรุงคุณภาพภาพและดึงดูดโดยรวม
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
วิธีการไดร์เวอร์
bitsCount
int
บิตสุดท้ายคํานวณสําหรับ dithering
customPalette
IColorPalette
แพลิเคชันที่กําหนดเองสําหรับ dithering
Examples
ตัวอย่างต่อไปนี้โหลดภาพ DICOM และดําเนินการขอบเขตและลอย dithering โดยใช้ความลึกของแถบที่แตกต่างกัน
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(Rectangle, FilterOptionsBase)
ปรับปรุงพื้นที่ที่เฉพาะเจาะจงของภาพของคุณโดยใช้ตัวกรองโหมดนี้ช่วยให้ผู้พัฒนามีการควบคุมที่แม่นยําการจัดการภาพช่วยให้การปรับเป้าหมายเพื่อบรรลุความต้องการที่ต้องการผลลัพธ์ภาพได้อย่างง่ายดาย
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
ตุ๊กตา
options
FilterOptionsBase
ตัวเลือก
Examples
ตัวอย่างต่อไปนี้ใช้ประเภทต่างๆของกรองสําหรับภาพ 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()
แปลงภาพได้อย่างง่ายดายในการแสดงสีเทาของพวกเขาโดยการซับซ้อนภาพการวิเคราะห์และงานประมวลผล เหมาะสําหรับนักพัฒนาที่ต้องการปรับปรุงความชัดเจนของภาพลดความซับซ้อนและช่วยให้การ algorithms grayscale ที่มีประสิทธิภาพสําหรับการใช้งานที่แตกต่างกัน
public override void Grayscale()
Examples
ตัวอย่างต่อไปนี้จะแปลงภาพ DICOM สีเป็นภาพสีเทา รูปภาพ Grayscale ประกอบด้วยภาพสีเทาและมีข้อมูลความเข้มเท่านั้น
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)
ใส่หน้าใหม่ลงในรายการหน้าของภาพในตัวเลขที่ระบุด้วยตัวอักษรนี้วิธีการ เหมาะสําหรับนักพัฒนาที่กําลังมองหาการควบคุมที่แม่นยําเกี่ยวกับการจัดเรียงของหน้าภาพหลายหน้าเพื่อให้แน่ใจว่าการจัดเรียงและกําหนดเองของเนื้อหาภาพ
public DicomPage InsertPage(int pageIndex)
Parameters
pageIndex
int
หมายเลขของหน้า
Returns
ที่สร้างขึ้นใหม่ Aspose.Imaging.FileFormats.Dicom.DicomPage
Examples
สร้างภาพ 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()
เปิดตัวทรัพยากรที่จัดการ ตรวจสอบให้แน่ใจว่าไม่มีทรัพยากรที่ไม่ได้จัดการจะเปิดตัวที่นี่เพราะพวกเขาอาจมีอิสระแล้ว
protected override void ReleaseManagedResources()
RemovePage(int)
ลบหน้าใน index ที่ระบุจากรายการหน้าด้วยวิธีการที่สะดวกนี้เหมาะสําหรับนักพัฒนาที่กําลังมองหาการควบคุมที่แม่นยําในการจัดการภาพหลายหน้าการให้แน่ใจว่าการจัดระเบียบและปรับแต่งเนื้อหาภาพได้อย่างราบรื่น
public void RemovePage(int pageIndex)
Parameters
pageIndex
int
หมายเลขของหน้า
Exceptions
pageIndex’ is out of range.
Resize(int, int, resizeType)
การปรับขนาดของภาพด้วยวิธีการที่เรียบง่ายนี้ เหมาะสําหรับนักพัฒนากําลังมองหาการรีไซเคิลภาพแบบไดนามิกเพื่อให้แน่ใจว่าพวกเขาเหมาะอย่างราบรื่นกับภาพต่างๆcontexts และ layouts ในแอพพลิเคชันของพวกเขา
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทการรีไซเคิล
Examples
ตัวอย่างนี้โหลดภาพ DICOM และรีไซเคิลโดยใช้วิธีการรีไซเคิลต่างๆ
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)
ปรับขนาดของภาพของคุณด้วยวิธีการรีไซเคิลที่เรียบง่ายนี้ ไม่ว่าคุณต้องการลดหรือขยายภาพของคุณฟังก์ชั่นนี้ให้แน่ใจว่าความต้องการการรีไซเคิลของคุณได้รับการตอบสนองประสิทธิภาพและแม่นยําทําให้เหมาะสําหรับนักพัฒนาที่กําลังมองหาได้อย่างรวดเร็วและง่ายดายการปรับขนาดภาพ
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
settings
ImageResizeSettings
การตั้งค่ารีไซเคิล
Examples
ตัวอย่างนี้โหลดภาพ DICOM และรีไซเคิลโดยใช้การตั้งค่ารีไซเคิลต่างๆ
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(int, ResizeType)
ปรับความสูงของภาพในขณะที่รักษาความสัมพันธ์ด้านของมันกับนี้วิธีการที่เป็นมิตรกับผู้ใช้ เหมาะสําหรับนักพัฒนาที่ต้องการรีไซเคิลภาพแบบไดนามิกในขณะที่รักษาความสัมพันธ์ของพวกเขาเพื่อให้แน่ใจว่าการแสดงผลและใช้งานที่ดีที่สุดในแอพลิเคชันของพวกเขา
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทของ Resize
Examples
ตัวอย่างนี้โหลดภาพ DICOM และรีไซเคิลได้โดยใช้วิธีการรีไซเคิลที่แตกต่างกัน เพียงความสูงจะระบุความกว้างจะคํานวณโดยอัตโนมัติ
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)
การรีไซเคิลภาพในขณะที่รักษาความสัมพันธ์ด้านของมันด้วยวิธีการที่สะดวก เหมาะสําหรับนักพัฒนาที่ต้องการปรับขนาดภาพอย่าง proportional เพื่อให้มั่นใจถึงความสม่ําเสมอและรักษาความสัมพันธ์ของเนื้อหาเดิม การรีไซเคิลแบบ proportional จะรีไซเคิลแต่ละกรอบตามความสัมพันธ์ของ newWidth’/width และ
newHeight’/height
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทการรีไซเคิล
ResizeWidthProportionally(int, ResizeType)
ปรับความกว้างของภาพในขณะที่รักษาความสัมพันธ์ด้านของมันกับเรื่องนี้สะดวกวิธีการ เหมาะสําหรับนักพัฒนาที่กําลังมองหาการรีไซเคิลภาพอย่างเหมาะสมเพื่อให้แน่ใจว่าผลลัพธ์ที่สม่ําเสมอและดูน่าสนใจทั่วสภาพแวดล้อมการแสดงผลที่แตกต่างกัน
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
resizeType
ResizeType
ประเภทของ Resize
Examples
ตัวอย่างนี้โหลดภาพ DICOM และรีไซเคิลได้ตามความเหมาะสมโดยใช้วิธีการรีไซเคิลที่แตกต่างกัน ความกว้างเท่านั้นที่ระบุความสูงจะคํานวณโดยอัตโนมัติ
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(บอล, บอล, สี)
รอบภาพรอบศูนย์กลางด้วยวิธีการที่สะดวกนี้ เหมาะสําหรับนักพัฒนามุ่งมั่นที่จะปรับทิศทางภาพอย่างไดนามิกเพื่อให้แน่ใจว่าการนําเสนอที่ดีที่สุดและการปรับแต่งภายในแอพลิเคชันของพวกเขา
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
มุมหมุนในเกรด หมายเลขเชิงบวกจะหมุนตามชั่วโมง
resizeProportionally
bool
ถ้าตั้งค่าเป็น “จริง” คุณจะมีการเปลี่ยนแปลงขนาดภาพของคุณตามแนวตั้งหมุน (จุดมุม) projections ในกรณีอื่น ๆ ที่ปล่อยให้มิติไม่สัมผัสและเพียงภายใน เนื้อหาภาพจะหมุน
backgroundColor
Color
สีของพื้นหลัง
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการหมุนหน้าทั้งหมดของภาพ DICOM และบันทึกพวกเขาทั้งหมดไปยังภาพ TIFF มัลติเฟรม
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)
ง่ายต่อการจัดการกรอบที่ใช้งานโดยการหมุนฟิล์มหรือดําเนินการทั้งสองในเวลาเดียวกันกับวิธีการที่เรียบง่ายนี้ เหมาะสําหรับนักพัฒนาที่ต้องการปรับมือแบบไดนามิกของทิศทางของเฟรมที่เฉพาะเจาะจงภายในช่วงภาพของพวกเขาเพื่อให้แน่ใจว่าการนําเสนอและการปรับตัวที่เหมาะสม
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
ประเภทหมุน flip
Examples
ตัวอย่างนี้โหลดภาพ DICOM, รอบมันด้วย 90 องศาตามนาฬิกาและตัวเลือกฟิล์มภาพแนวนอนและ/หรือแนวตั้ง
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(กระแส, ImageOptionsBase, Rectangle)
บันทึกข้อมูลภาพของคุณได้อย่างง่ายดายไปยังไหลที่กําหนดในรูปแบบไฟล์ที่ต้องการใช้วิธีการที่สะดวกนี้ ไม่ว่าคุณจะทํางานกับ JPEG, PNG หรือรูปแบบอื่น ๆฟังก์ชั่นนี้ให้แน่ใจว่าข้อมูลภาพของคุณจะถูกบันทึกได้อย่างมีประสิทธิภาพและถูกต้องทําให้มันเหมาะสําหรับนักพัฒนาที่กําลังมองหาที่จะปรับปรุงกระบวนการบันทึกไฟล์ของพวกเขา
public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
กระแสเพื่อบันทึกข้อมูลของภาพ
optionsBase
ImageOptionsBase
ตัวเลือกการประหยัด
boundsRectangle
Rectangle
ภาพจุดหมายปลายทางขอบขอบขอบ ปรับขอบขอบที่ว่างเปล่าเพื่อใช้ขอบแหล่ง
Examples
ตัวอย่างต่อไปนี้โหลดภาพ DICOM จากไฟล์แล้วบันทึกภาพไปยังไฟล์ 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(รั้ว, ImageOptionsBase)
บันทึกข้อมูลของวัตถุโดยบันทึกไว้ในไฟล์ที่กําหนด (ตัวชี้วัด + ชื่อไฟล์)ตําแหน่งพร้อมกับรูปแบบไฟล์ที่ระบุและตัวเลือก เหมาะสําหรับนักพัฒนาที่ต้องการการจัดเก็บข้อมูลได้อย่างปลอดภัยในรูปแบบต่างๆในขณะที่รักษาความยืดหยุ่นและการควบคุมพารามิเตอร์การประหยัด
public void SaveAll(string filePath, ImageOptionsBase options)
Parameters
filePath
string
เส้นทางไฟล์
options
ImageOptionsBase
ตัวเลือก
SaveData(Stream)
เก็บข้อมูล
protected override void SaveData(Stream stream)
Parameters
stream
Stream
กระแสเพื่อบันทึกข้อมูล
SetResolution(คู่, คู่)
การปรับความละเอียดของ Aspose.Imaging.RasterImage นี้ด้วยความแม่นยําโดยใช้วิธีการที่เรียบง่าย เหมาะสําหรับนักพัฒนาที่ต้องการปรับความละเอียดของภาพความต้องการที่เฉพาะเจาะจงเพื่อให้แน่ใจว่าคุณภาพการแสดงผลและการจัดการขนาดไฟล์ได้ดีที่สุด
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
double
ความละเอียดแนวนอนในจุดต่อ นิ้วของ Aspose.Imaging.RasterImage
dpiY
double
ความละเอียดแนวตั้งในจุดต่อ นิ้วของ Aspose.Imaging.RasterImage
UpdateDimensions(int, int)
ปรับปรุงขนาดภาพ
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
ความกว้างของภาพใหม่
newHeight
int
ความสูงของภาพใหม่