-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
34 lines (31 loc) · 1.09 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using FellowOakDicom;
using FellowOakDicom.Imaging;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace DICOMToJPEGConverter
{
class Program
{
static void Main(string[] args)
{
string inputFolderPath = "path_to_your_dicom_files";
string outputFolderPath = "path_to_save_jpeg_files";
foreach (string file in Directory.EnumerateFiles(inputFolderPath, "*.dcm"))
{
try
{
var dicomImage = new DicomImage(file);
using var image = dicomImage.RenderImage().As<Bitmap>(); // Convert to Bitmap
var jpegPath = Path.Combine(outputFolderPath, Path.GetFileNameWithoutExtension(file) + ".jpeg");
image.Save(jpegPath, ImageFormat.Jpeg); // Save as JPEG
}
catch (Exception ex)
{
Console.WriteLine($"Error processing file {file}: {ex.Message}");
}
}
Console.WriteLine("Conversion complete.");
}
}
}