public override DICOMImage Parse() { // Read the pixel data from the image, frame 0 IPixelData pixelData = PixelDataFactory.Create(image.PixelData, 0); // Get the pixels from the pixel data ushort[] pixels = ((GrayscalePixelDataU16)pixelData).Data; // Get the multiplier int min = image.PixelData.BitDepth.MinimumValue; int max = image.PixelData.BitDepth.MaximumValue; if (min != 0) { throw new FormatException("Error in the minimum value of the pixel data"); } float multiplier = ushort.MaxValue / max; // Apply the multiplier to the pixels for (int i = 0; i < pixels.Length; i++) { pixels[i] = (ushort)(pixels[i] * multiplier); } return(DICOMImage.FromData(image.Width, image.Height, pixels)); }
protected ImageAnalyser(DICOMImage image) { this.image = image; // Init some "constants" Init(); }
/// <summary> /// Gets the values of the pixels at the given positions /// </summary> /// <param name="image">The image to get the pixels from</param> /// <returns>An array containing the pixel values</returns> public ushort[] GetPixels(DICOMImage image) { Point[] pixels = BresenhamLine.GetLine(start, end); List <ushort> pixelValues = new List <ushort>(); foreach (Point pixel in pixels) { pixelValues.Add(image.GetPixel(pixel)); } return(pixelValues.ToArray()); }
static void Main(string[] args) { Console.WriteLine("Read DICOM image file"); Stopwatch sw = new Stopwatch(); sw.Start(); ImageParser parser = new DICOMParser(filename); DICOMImage image = parser.Parse(); sw.Stop(); Console.WriteLine("\n" + sw.ElapsedMilliseconds + " ms"); sw.Reset(); Console.WriteLine("Start Phantom detection"); sw.Start(); ImageAnalyser analyser = new PIX13Analyser(image); analyser.AnalyseImage(); //analyser.IsCorrectPhantom(); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds + " ms"); sw.Reset(); Console.WriteLine("Writing output image"); sw.Start(); //image.AddMarking(new CircleMarking(Color.FromArgb(255, 0, 0), new Point(100, 100), 30)); image.SaveImage(filename, ImageFormat.PNG); sw.Stop(); Console.WriteLine("\n" + sw.ElapsedMilliseconds + " ms"); Console.WriteLine("Done!"); Console.ReadKey(); }
public override DICOMImage Parse() { ReadData(); return(DICOMImage.FromData(width, height, pixelData)); }
public PIX13Analyser(DICOMImage image) : base(image) { }