using ClearCanvas.Dicom; DicomFile dicomFile = new DicomFile(dicomFileName); |
int bitsPerPixel = dicomFile.DataSet.GetAttribute(DicomTags.BitsStored).GetInt32(0, 0); |
int width = dicomFile.DataSet.GetAttribute(DicomTags.Columns).GetInt32(0, 0); |
int height = dicomFile.DataSet.GetAttribute(DicomTags.Rows).GetInt32(0, 0); |
// note, this only works if bitsPerPixel is > 8 and <=16 |
int stride = width * 2; |
byte[] bitmapBuffer = (byte[])dicomFile.DataSet.GetAttribute(DicomTags.PixelData).Values; |
BitmapSource bitmapSource = BitmapImage.Create(width, height, 96, 96, System.Windows.Media.PixelFormats.Gray16, null, bitmapBuffer, stride); |
image1.Source = bitmapSource; |
I have a piece of code to run with this code and the code in its entirety is posted below.
string filename = @"C:\fluro.dcm";
DicomFile dicomFile = new DicomFile(filename); dicomFile.Load(DicomReadOptions.Default); foreach (DicomAttribute attribute in dicomFile.DataSet) { Console.WriteLine("Tag: {0}, Value: {1}", attribute.Tag.Name, attribute.ToString()); } int bitsPerPixel = dicomFile.DataSet.GetAttribute(DicomTags.BitsStored).GetInt32(0, 0); int width = dicomFile.DataSet.GetAttribute(DicomTags.Columns).GetInt32(0, 0); int height = dicomFile.DataSet.GetAttribute(DicomTags.Rows).GetInt32(0, 0); int stride = width * 2; byte[] bitmapBuffer = (byte[])dicomFile.DataSet.GetAttribute(DicomTags.PixelData).Values; BitmapSource bitmapSource = BitmapImage.Create(width, height, 96, 96, System.Windows.Media.PixelFormats.Gray16, null, bitmapBuffer, stride); image1.Source = bitmapSource;
However, I'm encountering a single error on the lastline
image1.Source = bitmapSource;
The error states that
Error 1 The name 'image1' does not exist in the current context
How is image1 defined and how can I fix this error. I will be grateful for any information. Thank you verymuch
|
Search This Blog
Tuesday, 10 September 2013
About a Dicom image with ClearCanvas wit C#
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Most filters are designed to work with 24bpp RGB images or with grayscale images. In the case of grayscale images, we use PixelFormat.Fo...
-
Introduction DICOM stands for Digital Imaging and COmmunication in Medicine. The DICOM standard addresses the basic connectivity betwee...
-
Converting a DICOM image to a common graphic format and vice versa with DCMTK and CxImage Introduction This article presents a...
-
amespaces required view plain copy to clipboard print ? using System.Data.OleDb; OleDb is used to connect the web site form...
-
Introduction Here I will explain how to bind Datagridview in windows application using c#.net. Description I have started worki...
-
Introduction The class presented here will place a watermark on an image. It takes a Bitmap object and returns another Bitmap with a...
-
DICOM ( Digital Imaging and Communications in Medicine ) is a standard for handling, storing, printing, and transmitting information in m...
-
using ClearCanvas.Dicom; DicomFile dicomFile = new DicomFile(dicomFileName); int bitsPerPixel = dicomFile .DataSet.GetAttr...
No comments:
Post a Comment