public void FromDataset_WindowCenterWidth_ReturnsSameAsFromWindowLevel( ushort bitsAllocated, ushort bitsStored, ushort pixelRepresentation, double rescaleSlope, double rescaleIntercept, double windowWidth, double windowCenter, string voiLutFunction) { var dataset = new DicomDataset( new DicomCodeString(DicomTag.PhotometricInterpretation, "MONOCHROME1"), new DicomUnsignedShort(DicomTag.BitsAllocated, bitsAllocated), new DicomUnsignedShort(DicomTag.BitsStored, bitsStored), new DicomUnsignedShort(DicomTag.PixelRepresentation, pixelRepresentation), new DicomDecimalString(DicomTag.RescaleSlope, (decimal)rescaleSlope), new DicomDecimalString(DicomTag.RescaleIntercept, (decimal)rescaleIntercept), new DicomDecimalString(DicomTag.WindowWidth, (decimal)windowWidth), new DicomDecimalString(DicomTag.WindowCenter, (decimal)windowCenter), new DicomCodeString(DicomTag.VOILUTFunction, voiLutFunction)); var expected = GrayscaleRenderOptions.FromWindowLevel(dataset); var actual = GrayscaleRenderOptions.FromDataset(dataset); Assert.Equal(expected.WindowWidth, actual.WindowWidth); Assert.Equal(expected.WindowCenter, actual.WindowCenter); }
private void OnKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right) { _frame++; if (_frame >= _image.NumberOfFrames) { _frame--; } DisplayImage(_image); return; } if (e.KeyCode == Keys.Left) { _frame--; if (_frame < 0) { _frame++; } DisplayImage(_image); return; } if (e.KeyCode == Keys.O) { _image.ShowOverlays = !_image.ShowOverlays; DisplayImage(_image); return; } GrayscaleRenderOptions options = null; if (e.KeyCode == Keys.D0) { options = GrayscaleRenderOptions.FromDataset(_image.Dataset); } else if (e.KeyCode == Keys.D1) { options = GrayscaleRenderOptions.FromWindowLevel(_image.Dataset); } else if (e.KeyCode == Keys.D2) { options = GrayscaleRenderOptions.FromImagePixelValueTags(_image.Dataset); } else if (e.KeyCode == Keys.D3) { options = GrayscaleRenderOptions.FromMinMax(_image.Dataset); } else if (e.KeyCode == Keys.D4) { options = GrayscaleRenderOptions.FromBitRange(_image.Dataset); } else if (e.KeyCode == Keys.D5) { options = GrayscaleRenderOptions.FromHistogram(_image.Dataset, 90); } if (options != null) { _image.WindowWidth = options.WindowWidth; _image.WindowCenter = options.WindowCenter; DisplayImage(_image); } }