Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display DICOM monochrome2 having bits stored less than bits allocated

Tags:

c#

vtk

dicom

gdcm

I want to display DICOM file having photometric interpretation MONOCHROME2.

some of the specifications of image are-

Rows:           1024
Columns:        1024
No of Frames:   622
Bits Allocated: 16
Bits Stored:    10
High Bit:       9
Pixel Representation: 0
Sample per pixel: 1

I am using gdcmRegionReader to extract single frames byte array in the following way.

 gdcm.ImageRegionReader _regionReader = new gdcm.ImageRegionReader();
 _regionReader.SetRegion(_boxRegion);  // _boxRegion is some region
 _regionReader.ReadIntoBuffer(Result, (uint)Result.Length);
 Marshal.Copy(Result.ToArray(), 0, _imageData.GetScalarPointer(), 
 Result.ToArray().Length);
 _viewer.SetInput(_imageData);  // _viewer = vtkImageViewer

But when i display that file it is displaying like this..MONOCHROME2 dicom when I display using gdcmRegionReader

but the original image is like this..Original Image

So can someone help me on how to load and display MONOCHROME2 dicom images.

like image 338
Namrata Avatar asked Oct 30 '22 07:10

Namrata


2 Answers

Disclaimer: I never used the toolkit in question. I am attempting to answer based on my understanding of DICOM. In my experience about DICOM, syntax was rarely was the problem. Real problem was the concept and terms.

I see two problems in output.

One is about part of the image rendered. Notice that entire data is not rendered in your output. Check the toolkit document to see how to set the dimensions/bounds while rendering image.

Other problem is about output quality. Initially, I suspected the Transfer Syntax might be the issue. I do not think it is but just make sure you are uncompromising the image before rendering. I am not sure how your toolkit handles compression while rendering.

There is other way available to render pixel data in the toolkit.

_ImageViewer.SetRenderWindow(renderWindow);
_ImageViewer.GetRenderer().AddActor2D(sliceStatusActor);
_ImageViewer.GetRenderer().AddActor2D(usageTextActor);
_ImageViewer.SetSlice(_MinSlice);
_ImageViewer.Render();

Above code is copied from "http://www.vtk.org/Wiki/VTK/Examples/CSharp/IO/ReadDICOMSeries". Detailed code is available there.

Following links may also be helpful:
http://vtk.1045678.n5.nabble.com/How-to-map-negative-grayscale-to-color-td5737080.html

https://www.codeproject.com/Articles/31581/Displaying-bit-Images-Using-C

like image 68
Amit Joshi Avatar answered Nov 15 '22 11:11

Amit Joshi


You should really use vtkGDCMImageReader2 instead in your code. vtkGDCMImageReader2 precisely encapsulate gdcm::RegionReader for binding with VTK.

If for some reason you cannot use directly this class, simply copy/paste the C++ code from within the main function, into your C# code.

See:

  • http://gdcm.sourceforge.net/2.6/html/classvtkGDCMImageReader2.xhtml
  • http://gdcm.sourceforge.net/2.6/html/classgdcm_1_1ImageRegionReader.xhtml
like image 33
malat Avatar answered Nov 15 '22 13:11

malat