Down Sampling an Image

This is a very small and quick example to show how to down size an image to an 8 bit image and resize down to ¼ of the size (50% each dimension).

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


We use cookies to give you the best possible experience on our website. By continuing to use this website, you agree with our use of cookies. for more information please click HERE