Javaを介してDICOMをフィルタリングします
サーバー側APIを使用してDICOMファイルをフィルタリングする独自のJavaアプリを作成します。
Javaを使用してDICOMファイルをフィルタリングする方法
最も完璧な画像であっても、さらに強化したり、まったく異なるユニークな芸術作品に変換したりすることができます。フィルターを適用して、さまざまな画像効果を実現します。たとえば、画像を鮮明にしたり、逆に、ぼかしを追加したり、滑らかにしたり、色のノイズを除去したりできます。フィルターは、画像に独自性を与えたい場合にも非常に役立ちます。これを実現するには、目的のエフェクトを適用するか、さまざまなエフェクトを組み合わせます。このアプローチにより、色のグラデーションを調整し、ノイズを除去し、同時に写真内のオブジェクトのエッジの鮮明さを高めることができます。 DICOM ファイルをフィルタリングするには、次を使用します。 Aspose.Imaging for Java 機能豊富で強力で使いやすいJava ラットフォーム用の画像操作および変換APIであるAPI。最新バージョンはから直接ダウンロードできます Maven 次の構成をpom.xmlに追加して、Mavenベースのプロジェクトにインストールします。
Repository
<repository>
<id>Aspose Java API</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging</artifactId>
<version>version of aspose-imaging API</version>
<classifier>jdk16</classifier>
</dependency>
Javaを介してDICOMをフィルタリングする手順
あなたは aspose-imaging-version-jdk16.jar 自分の環境で次のワークフローを試してください。
+Image.Loadメソッドを使用してDICOMファイルをロードします +画像をフィルタリングします。 +Aspose.Imaging形式でサポートされているディスクに圧縮画像を保存します
システム要求
Aspose.Imaging for Javaは、すべての主要なオペレーティングシステムでサポートされています。次の前提条件があることを確認してください。
-JDK1.6以降がインストールされています。
DICOM画像のフィルタリング-Java
import com.aspose.imaging.IMultipageImage; | |
import com.aspose.imaging.Image; | |
import com.aspose.imaging.RasterImage; | |
import com.aspose.imaging.imageoptions.PngOptions; | |
import java.io.File; | |
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.function.Consumer; | |
medianfilter(); | |
public static void smallRectangularfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/SmallRectangularFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new SmallRectangularFilterOptions()); | |
}, "smallrectangular"); | |
} | |
public static void bigRectangularfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/BigRectangularFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new BigRectangularFilterOptions()); | |
}, "bigrectangular"); | |
} | |
public static void sharpenfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/SharpenFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new SharpenFilterOptions()); | |
}, "sharpen"); | |
} | |
public static void motionWienerfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/MotionWienerFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new MotionWienerFilterOptions(20, 2, 0)); | |
}, "motionwiener"); | |
} | |
public static void bilateralSmoothingfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/BilateralSmoothingFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new BilateralSmoothingFilterOptions()); | |
}, "bilateralsmoothing"); | |
} | |
public static void gaussBlurfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/GaussianBlurFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new GaussianBlurFilterOptions(5, 4)); | |
}, "gaussblur"); | |
} | |
public static void gaussWienerfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/GaussWienerFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new GaussWienerFilterOptions(5, 5)); | |
}, "gausswiener"); | |
} | |
public static void medianfilter() | |
{ | |
filterImages(image -> | |
{ | |
// https://apireference.aspose.com/imaging/java/com.aspose.imaging.imagefilters.filteroptions/MedianFilterOptions | |
Rectangle filterRect = new Rectangle(image.getWidth() / 6, image.getHeight() / 6, image.getWidth() * 2 / 3, image.getHeight() * 2 / 3); | |
image.filter(filterRect, new MedianFilterOptions(20)); | |
}, "median"); | |
} | |
static String templatesFolder = "D:\\"; | |
public static void filterImages(Consumer<RasterImage> doFilter, String filterName) | |
{ | |
List<String> rasterFormats = Arrays.asList("jpg", "png", "bmp", "apng", "dicom", | |
"jp2", "j2k", "tga", "webp", "tif", "gif", "ico"); | |
List<String> vectorFormats = Arrays.asList("svg", "otg", "odg", "eps", "wmf", "emf", "wmz", "emz", "cmx", "cdr"); | |
List<String> allFormats = new LinkedList<>(rasterFormats); | |
allFormats.addAll(vectorFormats); | |
allFormats.forEach( | |
formatExt -> | |
{ | |
String inputFile = templatesFolder + "template." + formatExt; | |
boolean isVectorFormat = vectorFormats.contains(formatExt); | |
//Need to rasterize vector formats before background remove | |
if (isVectorFormat) | |
{ | |
inputFile = rasterizeVectorImage(formatExt, inputFile); | |
} | |
String outputFile = templatesFolder + String.format("%s_%s.png", filterName, formatExt); | |
System.out.println("Processing " + formatExt); | |
try (RasterImage image = (RasterImage) Image.load(inputFile)) | |
{ | |
doFilter.accept(image); | |
//If image is multipage save each page to png to demonstrate results | |
if (image instanceof IMultipageImage && ((IMultipageImage) image).getPageCount() > 1) | |
{ | |
IMultipageImage multiPage = (IMultipageImage) image; | |
final int pageCount = multiPage.getPageCount(); | |
final Image[] pages = multiPage.getPages(); | |
for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) | |
{ | |
String fileName = String.format("%s_page%d_%s.png", filterName, pageIndex, formatExt); | |
pages[pageIndex].save(fileName, new PngOptions()); | |
} | |
} | |
else | |
{ | |
image.save(outputFile, new PngOptions()); | |
} | |
} | |
//Remove rasterized vector image | |
if (isVectorFormat) | |
{ | |
new File(inputFile).delete(); | |
} | |
} | |
); | |
} | |
private static String rasterizeVectorImage(String formatExt, String inputFile) | |
{ | |
String outputFile = templatesFolder + "rasterized."+ formatExt + ".png"; | |
try (Image image = Image.load(inputFile)) | |
{ | |
image.save(outputFile, new PngOptions()); | |
} | |
return outputFile; | |
} |
Aspose.Imaging for Java 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以降です。
続きを読むその他のサポートされているフィルター形式
Javaを使用すると、を含むさまざまな形式を簡単にフィルタリングできます。