当前位置:网站首页>C # - C # process and convert pixeldata of CT images with fo DICOM
C # - C # process and convert pixeldata of CT images with fo DICOM
2022-06-30 06:33:00 【sinolover】
from :c# - C# use fo-dicom Yes CT Graphic PixelData Process and transform - IT Tool network
For some tests , I tried to manipulate PixelData With dicom Format stored CT The elements of the image , And use C# Medium Fellow Oak Dicom Write it back to the file . After some research , I found that the matrix I wanted to deal with was Buffer in . Of PixelData Stored in byte - Large numbers . So I wrote the following code :
DicomFile ctFile = DicomFile.Open(image); var pixDat = ctFile.Dataset.Get<byte[]>(DicomTag.PixelData); for (int i = 0; i < pixData.Length; i++) { pixDat[i] = Convert.ToByte(200); } ctFile.Dataset.AddOrUpdate<byte[]>(DicomTag.PixelData, pixDat); ctFile.Save("new file folder"); This is my first attempt , I got it.
Exception stay AddOrUpdate command , Because it can't convert byte - Array to OB.Read for example Pianykh About DICOM The book of ,OB Represents other byte strings . But so far I can't convert the manipulated
byte - Array to OB. When I try this code snippet :DicomOtherByte dob = new DicomOtherByte(DicomTag.PixelData, pixDat); ctFile.Dataset.AddOrUpdate<DicomOtherByte>(DicomTag.PixelData, dob); Exception Still calling AddOrUpdate Because the project cannot be converted to OB. stay stackoverflow、git or google Medium fo-dicom I still don't know how to deal with it . So I want to know how to convert my manipulation matrix into OB, Because I think DicomOtherByte yes OB.edit :
Exception yes “ Can't use Dicom.DicomOtherByte Value creation of type OB Type of DICOM Elements ” - System.InvalidOperationExceptionThank you in advance .
The best answer
Dicom The pixel data in the dataset is very special . It cannot be easily read or written as a single tag . Fo-Dicom Special functions and classes for processing pixel data .
Here is an example :
DicomFile ctFile = DicomFile.Open(@"C:\Temp\original.dcm"); // Create PixelData object to represent pixel data in dataset DicomPixelData pixelData = DicomPixelData.Create(ctFile.Dataset); // Get Raw Data byte[] originalRawBytes = pixelData.GetFrame(0).Data; // Create new array with modified data byte[] modifiedRawBytes = new byte[originalRawBytes.Length]; for (int i = 0; i < originalRawBytes.Length; i++) { modifiedRawBytes[i] = (byte)(originalRawBytes[i] + 100); } // Create new buffer supporting IByteBuffer to contain the modified data MemoryByteBuffer modified = new MemoryByteBuffer(modifiedRawBytes); // Write back modified pixel data ctFile.Dataset.AddOrUpdatePixelData(DicomVR.OB, modified); ctFile.Save(@"C:\Temp\Modified.dcm"); Please note that , There are more helper classes that can directly process pixel data in a specific format , for example
PixelDataConverter and PixelDataFactory .Besides , If you want to use actual images , Please use
DicomImage class (class).DicomImage image = new DicomImage(ctFile.Dataset); About c# - C# use fo-dicom Yes CT Graphic PixelData Process and transform , We are Stack Overflow Find a similar problem on : type conversion - Manipulating and Converting PixelData of CT Image with fo-dicom in C# - Stack Overflow
边栏推荐
- Introduction to neural networks
- Thread safe solutions, communication between threads (classic examples of producers and consumers)
- Ten years' miscellaneous thoughts
- Gazebo model modification
- Network basics
- Traitement d'images 7 - amélioration d'images
- Is it safe to open an account online? Can you open an account to speculate on the Internet?
- 关于Glide加载图片模糊不清楚
- Detailed description of methods in the interface
- File operation io-part1
猜你喜欢

图像处理7-图像增强

JS prototype chain object function relationship

Use and principle of completionservice (source code analysis)

Learn fpga---ram IP core and key parameters from the bottom structure

gazebo/set_ model_ State topic driving UAV model through posture
一个完整的性能测试流程

Use of observer mode and status mode in actual work

Loading class `com. mysql. jdbc. Driver‘. This is deprecated. The new driver class is `com. mysql. cj. jdb

My experience in functional testing for so many years

RSA and AES
随机推荐
How does Altium designer hide some temporarily unnecessary classes, such as GND
Common mistakes daily practice 01
判断h5在两端是在微信环境还是企业微信环境
Collections tool class (V)
ES6 deconstruction assignment
Multithreading advanced level
46. 全排列-dfs双百代码
To: k210 realizes face recognition (code interpretation attached)
Gazebo model modification
Who doesn't want a blog site of their own - build a blog site WordPress
High performance distributed execution framework ray
Record a problem tracking of excessive load
多线程进阶篇
2020-10-06
Application of redis client list in practice
Base64详解:玩转图片Base64编码
Notes of the first week of 2021 Chengdu Arts and Sciences cloud computing intensive training class
反编译正常回编译出现问题自己解决办法
Unable to read file for extraction: gdx64. dll
c# - C#用fo-dicom对CT图像的PixelData进行处理和转换