• 大小: 0.80M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-05-02
  • 语言: C#
  • 标签: 图像处理  DC  图像  

资源简介

DCM文件转图像,并高清处理图像

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {


        }

        #region DicomHandler 医学图像解析
        class DicomHandler
        {
            string fileName = ““;
            Dictionary tags = new Dictionary();//dicom文件中的标签
            BinaryReader dicomFile;//dicom文件流

            //文件元信息
            public Bitmap gdiImg;//转换后的gdi图像
            UInt32 fileHeadLen;//文件头长度
            long fileHeadOffset;//文件数据开始位置
            UInt32 pixDatalen;//像素数据长度
            long pixDataOffset = 0;//像素数据开始位置
            bool isLitteEndian = true;//是否小字节序(小端在前 、大端在前)
            bool isExplicitVR = true;//有无VR

            //像素信息
            int colors;//颜色数 RGB为3 黑白为1
            public int windowWith = 2048 windowCenter = 2048 / 2;//窗宽窗位
            int rows cols;
            public void readAndShow(out string textBox1)
            {
                textBox1 = ““;
                if (fileName == string.Empty)
                {
                    textBox1 = “请选择文件“;
                }
                else
                {
                    dicomFile = new BinaryReader(File.OpenRead(fileName));

                    //跳过128字节导言部分
                    dicomFile.baseStream.Seek(128 SeekOrigin.Begin);

                    if (new string(dicomFile.ReadChars(4)) != “DICM“)
                    {
                        textBox1 = “没有dicom标识头,文件格式错误“;
                    }
                    else
                    {
                        tagRead();
                        IDictionaryEnumerator enor = tags.GetEnumerator();
                        while (enor.MoveNext())
                        {
                            if (enor.Key.ToString().Length > 9)
                            {
                                textBox1 += enor.Key.ToString() + “\r\n“;
                                textBox1 += enor.Value.ToString().Replace(‘\0‘ ‘ ‘);
                            }
                            else
                                textBox1 += enor.Key.ToString() + enor.Value.ToString().Replace(‘\0‘ ‘ ‘) + “\r\n“;
                        }
                        dicomFile.Close();
                    }
                }
            }
            public DicomHandler(string _filename)
            {
                fileName = _filename;
            }

            public void saveAs(string filename)
            {
                switch (filename.Substring(filename.LastIndexO

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     32768  2021-01-28 10:32  dcm图像\.vs\dcm图像处理\v15\.suo

     文件          0  2021-01-28 10:29  dcm图像\.vs\dcm图像处理\v15\Server\sqlite3\db.lock

     文件       4096  2021-01-28 10:29  dcm图像\.vs\dcm图像处理\v15\Server\sqlite3\storage.ide

     文件      32768  2021-01-28 10:29  dcm图像\.vs\dcm图像处理\v15\Server\sqlite3\storage.ide-shm

     文件     951752  2021-01-28 10:32  dcm图像\.vs\dcm图像处理\v15\Server\sqlite3\storage.ide-wal

     文件       1146  2021-01-28 10:29  dcm图像\dcm图像处理.sln

     文件        178  2021-01-28 09:40  dcm图像\WindowsFormsApp1\App.config

     文件     986136  2021-01-27 13:42  dcm图像\WindowsFormsApp1\bin\Debug\ImageFileName.dcm

     文件    1963974  2021-01-28 09:41  dcm图像\WindowsFormsApp1\bin\Debug\ImageFileName.png

     文件    1963974  2021-01-27 13:52  dcm图像\WindowsFormsApp1\bin\Debug\test.png

     文件      19968  2021-01-28 10:32  dcm图像\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe

     文件        178  2021-01-28 09:40  dcm图像\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe.config

     文件      40448  2021-01-28 10:32  dcm图像\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb

     文件      24018  2021-01-28 10:32  dcm图像\WindowsFormsApp1\Form1.cs

     文件       4714  2021-01-28 10:31  dcm图像\WindowsFormsApp1\Form1.Designer.cs

     文件       6020  2021-01-28 10:31  dcm图像\WindowsFormsApp1\Form1.resx

     文件        987  2021-01-28 09:40  dcm图像\WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7240  2021-01-28 10:30  dcm图像\WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2021-01-26 18:55  dcm图像\WindowsFormsApp1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2021-01-26 18:55  dcm图像\WindowsFormsApp1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2021-01-26 18:55  dcm图像\WindowsFormsApp1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件         42  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache

     文件       2191  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.FileListAbsolute.txt

     文件       1012  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.GenerateResource.cache

     文件      19968  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe

     文件        180  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Form1.resources

     文件      40448  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.pdb

     文件        180  2021-01-28 10:32  dcm图像\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Properties.Resources.resources

     文件        528  2021-01-26 18:55  dcm图像\WindowsFormsApp1\Program.cs

     文件       1344  2021-01-26 18:55  dcm图像\WindowsFormsApp1\Properties\AssemblyInfo.cs

............此处省略27个文件信息

评论

共有 条评论