C#を介してDICOMをフィルタリングします
サーバー側APIを使用してDICOMファイルをフィルタリングする独自の.NETアプリを作成します。
C#を使用してDICOMファイルをフィルタリングする方法
最も完璧な画像であっても、さらに強化したり、まったく異なるユニークな芸術作品に変換したりすることができます。フィルターを適用して、さまざまな画像効果を実現します。たとえば、画像を鮮明にしたり、逆に、ぼかしを追加したり、滑らかにしたり、色のノイズを除去したりできます。フィルターは、画像に独自性を与えたい場合にも非常に役立ちます。これを実現するには、目的のエフェクトを適用するか、さまざまなエフェクトを組み合わせます。このアプローチにより、色のグラデーションを調整し、ノイズを除去し、同時に写真内のオブジェクトのエッジの鮮明さを高めることができます。 DICOM ファイルをフィルタリングするには、次を使用します。 Aspose.Imaging for .NET 機能が豊富で強力で使いやすいC#プラットフォーム用の画像操作および変換APIであるAPI。開ける NuGet パッケージマネージャー、検索 ** Aspose.Imaging ** とインストールします。パッケージマネージャーコンソールから次のコマンドを使用することもできます。
パッケージマネージャーコンソールコマンド
PM> Install-Package Aspose.Imaging
C#を介してDICOMをフィルタリングする手順
あなたは aspose.imaging.dll 自分の環境で次のワークフローを試してください。
+Image.Loadメソッドを使用してDICOMファイルをロードします +画像をフィルタリングします。 +Aspose.Imaging形式でサポートされているディスクに圧縮画像を保存します
システム要求
Aspose.Imaging for .NETは、すべての主要なオペレーティングシステムでサポートされています。次の前提条件があることを確認してください。
-Microsoft Windows、または.NET Framework、.NET Core、Windowsアプリケーション、ASP.NETWebアプリケーションと互換性のあるOS。 -Microsoft VisualStudioのような開発環境。 -プロジェクトで参照されているAspose.Imagingfor.NET。
DICOM画像のフィルタリング-.NET
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Dicom; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Jpeg; | |
using Aspose.Imaging.FileFormats.Jpeg2000; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageFilters.FilterOptions; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Masking; | |
using Aspose.Imaging.Masking.Options; | |
using Aspose.Imaging.Masking.Result; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads"; | |
MedianFilter(); | |
void SmallRectangularFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/smallrectangularfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new SmallRectangularFilterOptions()); | |
}, "smallrectangular"); | |
} | |
void BigRectangularFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/bigrectangularfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new BigRectangularFilterOptions()); | |
}, "bigrectangular"); | |
} | |
void SharpenFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/sharpenfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new SharpenFilterOptions()); | |
}, "sharpen"); | |
} | |
void MotionWienerFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/motionwienerfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new MotionWienerFilterOptions(20, 2, 0)); | |
}, "motionwiener"); | |
} | |
void BilateralSmoothingFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/bilateralsmoothingfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new BilateralSmoothingFilterOptions()); | |
}, "bilateralsmoothing"); | |
} | |
void GaussBlurFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/gaussianblurfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new GaussianBlurFilterOptions(5, 4)); | |
}, "gaussblur"); | |
} | |
void GaussWienerFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/gausswienerfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new GaussWienerFilterOptions(5, 5)); | |
}, "gausswiener"); | |
} | |
void MedianFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/medianfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new MedianFilterOptions(20)); | |
}, "median"); | |
} | |
void FilterImages(Action<RasterImage> doFilter, string filterName) | |
{ | |
List<string> rasterFormats = new List<string>() { "jpg", "png", "bmp", "apng", "dicom", | |
"jp2", "j2k", "tga", "webp", "tif", "gif","ico" }; | |
List<string> vectorFormats = new List<string>() { "svg", "otg", "odg", "eps", "wmf", "emf", "wmz", "emz", "cmx", "cdr" }; | |
List<string> allFormats = new List<string>(rasterFormats); | |
allFormats.AddRange(vectorFormats); | |
allFormats.ForEach( | |
formatExt => | |
{ | |
var inputFile = Path.Combine(templatesFolder, $"template.{formatExt}"); | |
bool isVectorFormat = vectorFormats.IndexOf(formatExt) > -1; | |
//Need to rasterize vector formats before background remove | |
if (isVectorFormat) | |
{ | |
inputFile = RasterizeVectorImage(formatExt, inputFile); | |
} | |
var outputFile = Path.Combine(templatesFolder, $"{filterName}_{formatExt}.png"); | |
Console.WriteLine($"Processing {formatExt}"); | |
using (var image = (RasterImage)Image.Load(inputFile)) | |
{ | |
doFilter(image); | |
//If image is multipage save each page to png to demonstrate results | |
if (image is IMultipageImage multiPage && multiPage.PageCount > 1) | |
{ | |
for (var pageIndex = 0; pageIndex < multiPage.PageCount; pageIndex++) | |
{ | |
string fileName = $"{filterName}_page{pageIndex}_{formatExt}.png"; | |
multiPage.Pages[pageIndex].Save(templatesFolder + fileName, new PngOptions()); | |
File.Delete(templatesFolder + fileName); | |
} | |
} | |
else | |
{ | |
image.Save(outputFile, new PngOptions()); | |
File.Delete(outputFile); | |
} | |
} | |
//Remove rasterized vector image | |
if (isVectorFormat) | |
{ | |
File.Delete(inputFile); | |
} | |
} | |
); | |
} | |
string RasterizeVectorImage(string formatExt, string inputFile) | |
{ | |
string outputFile = Path.Combine(templatesFolder, $"rasterized.{formatExt}.png"); | |
using (var image = Image.Load(inputFile)) | |
{ | |
image.Save(outputFile, new PngOptions()); | |
} | |
return outputFile; | |
} |
Aspose.Imaging for .NET APIについて
Aspose.Imaging APIは、アプリケーション内で画像(写真)を作成、変更、描画、または変換するための画像処理ソリューションです。クロスプラットフォームの画像処理(さまざまな画像形式間の変換(均一なマルチページまたはマルチフレームの画像処理を含む)、描画などの変更、グラフィックプリミティブの操作、変換(サイズ変更、トリミング、反転、回転)を含むがこれらに限定されない) 、2値化、グレースケール、調整)、高度な画像操作機能(フィルタリング、ディザリング、マスキング、デスキュー)、およびメモリ最適化戦略。これはスタンドアロンライブラリであり、画像操作をソフトウェアに依存しません。プロジェクト内のネイティブAPIを使用して、高性能の画像変換機能を簡単に追加できます。これらは100%プライベートのオンプレミスAPIであり、画像はサーバーで処理されます。オンラインアプリでDICOMをフィルタリングする
[Live Demos Webサイト](https://products.aspose.app/imaging/image-Filter)にアクセスして、DICOMドキュメントをフィルタリングします。 ライブデモには次の利点があります
DICOM とは DICOM ファイル形式
DICOMは、Medical Imaging and Communications in Medicineの頭字語であり、医療情報学の分野に関係しています。 DICOMは、ファイル形式の定義とネットワーク通信プロトコルを組み合わせたものです。 DICOMは.DCM拡張子を使用します。 .DCMは、フォーマット1.xとフォーマット2.xの2つの異なるフォーマットで存在します。 DCMフォーマット1.xは、通常と拡張の2つのバージョンでさらに利用できます。 DICOMは、さまざまなベンダーのプリンター、サーバー、スキャナーなどの医用画像装置の統合に使用され、一意性のために各患者の識別データも含まれています。 DICOMファイルは、DICOM形式の画像データを受信できる場合、2者間で共有できます。 DICOMの通信部分はアプリケーション層プロトコルであり、TCP / IPを使用してエンティティ間で通信します。 HTTPおよびHTTPSプロトコルは、DICOMのWebサービスに使用されます。 Webサービスでサポートされているバージョンは、1.0、1.1、2以降です。
続きを読むその他のサポートされているフィルター形式
C#を使用すると、を含むさまざまな形式を簡単にフィルタリングできます。