• 大小: 7KB
    文件类型: .cs
    金币: 2
    下载: 2 次
    发布日期: 2021-06-18
  • 语言: C#
  • 标签: c#,vtk  

资源简介

c# vtk 读取dicom文件!

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClearCanvas.ImageViewer;
using ClearCanvas.ImageViewer.StudyManagement;
using JXDWNav;
using Kitware.VTK;

namespace VTKTest
{
    public partial class 读取CT : Form
    {
        public 读取CT()
        {
            InitializeComponent();
        }

        short[] _dicomAlldata;
        vtkImageMapper mapper;
        string msg;
        vtkRenderWindow window;
        vtkTextMapper sliceTextMapper;
        private void 读取CT_Load(object sender EventArgs e)
        {

           
            
                vtkDICOMImageReader reader = vtkDICOMImageReader.New();
                reader.SetFileName(@“D:\GdcmDirectory\106.dcm“);
                //reader.SetDirectoryName(@“D:\GdcmDirectory\“);
                reader.Update();

                vtkImageData imageData = new vtkImageData();
                imageData = reader.GetOutput();
          
                FastImageDataFetcherShort _fastImageDataFetcher = new FastImageDataFetcherShort(imageData);
                _dicomAlldata = _fastImageDataFetcher.GetAllScalar();
            
           
                mapper = vtkImageMapper.New();
                mapper.SetInput(imageData);
                //mapper.SetZSlice(100);
                mapper.SetColorLevel(-400); 
                mapper.SetColorWindow(1500);

                vtkTextProperty sliceTextProp = vtkTextProperty.New();
                sliceTextProp.SetFontFamilyToCourier();
                sliceTextProp.SetFontSize(20);
                sliceTextProp.SetVerticalJustificationToBottom();
                sliceTextProp.SetJustificationToLeft();

                sliceTextMapper = vtkTextMapper.New();
                msg = string.Format(hScrollBar1.Value + “/“ + mapper.GetWholeZMax() ““);
                sliceTextMapper.SetInput(msg);
                sliceTextMapper.SetTextProperty(sliceTextProp);


                vtkActor2D sliceTextActor = vtkActor2D.New();
                sliceTextActor.SetMapper(sliceTextMapper);
                sliceTextActor.SetPosition(15 10);



                vtkActor2D actor = new vtkActor2D();
                actor.SetMapper(mapper);
                actor.SetPosition(100 0);


                vtkRenderer renderer = vtkRenderer.New();
                renderer.AddActor(actor);
                renderer.AddActor(sliceTextActor);

                window = vtkRenderWindow.New();

                window.SetParentId(pictureBox1.Handle);
                window.SetSize(pictureBox1.Width pictureBox1.Height);
                window.AddRenderer(renderer);
                window.Render();
                vtkRenderWindowInteractor renderWindowInteractor = vtkRenderWindowInteractor.New();
                rend

评论

共有 条评论

相关资源