Down Sampling an Image

A quick example on how to down size an image to an 8 bit image and resize down to 1/4 of the pixels.

 

DicomImage NewImage = (DicomImage)OrigImage.Clone(true);  // copy the image
           
DicomImage TempImage = OrigImage.PrinterImage(8, 1, false, ((float)0.5), new Rectangle(new Point(0,0),OrigImage.Size), true);
 for each (DicomAttribute a in TempImage.DataSet)            // copy the attributes of the Temp image into the new image 
    NewImage.DataSet.Add(a.Group, a.Element, a.Value);      // including the pixel data
           
NewImage.InstanceUID = DicomGlobal.NewUID();    // MUST have a NEW UID
NewImage.DataSet.Add(0x0028, 0x1050, 0x80);     // Must reset width and level attributes  
NewImage.DataSet.Add(0x0028, 0x1051, 0xff);
NewImage.SetDefaultWindows();                   // Sets width and level from above values for display
Relevance: