protected override byte[] CreateNormalizedPixelData() { string photometricInterpretation; byte[] pixelData = _framePixelData.GetUncompressedPixelData(out photometricInterpretation); string photometricInterpretationCode = photometricInterpretation ?? Parent[DicomTags.PhotometricInterpretation].ToString(); PhotometricInterpretation pi = PhotometricInterpretation.FromCodeString(photometricInterpretationCode); if (pi.IsColor) { pixelData = ToArgb(this.Parent, pixelData, pi); } else { var overlayPlaneModuleIod = new OverlayPlaneModuleIod(Parent); foreach (var overlayPlane in overlayPlaneModuleIod) { if (!overlayPlane.HasOverlayData && _overlayData[overlayPlane.Index] == null) { // if the overlay is embedded in pixel data and we haven't cached it yet, extract it now before we normalize the frame pixel data var overlayData = OverlayData.UnpackFromPixelData(overlayPlane.OverlayBitPosition, Parent[DicomTags.BitsAllocated].GetInt32(0, 0), false, pixelData); _overlayData[overlayPlane.Index] = overlayData; } } NormalizeGrayscalePixels(this.Parent, pixelData); } return(pixelData); }
protected override byte[] CreateNormalizedPixelData() { byte[] pixelData = _framePixelData.GetUncompressedPixelData(); string photometricInterpretationCode = this.Parent[DicomTags.PhotometricInterpretation].ToString(); PhotometricInterpretation pi = PhotometricInterpretation.FromCodeString(photometricInterpretationCode); TransferSyntax ts = TransferSyntax.GetTransferSyntax(this.Parent.TransferSyntaxUid); if (pi.IsColor) { if (ts == TransferSyntax.Jpeg2000ImageCompression || ts == TransferSyntax.Jpeg2000ImageCompressionLosslessOnly || ts == TransferSyntax.JpegExtendedProcess24 || ts == TransferSyntax.JpegBaselineProcess1) { pi = PhotometricInterpretation.Rgb; } pixelData = ToArgb(this.Parent, pixelData, pi); } else { OverlayPlaneModuleIod opmi = new OverlayPlaneModuleIod(this.Parent); foreach (OverlayPlane overlayPlane in opmi) { if (IsOverlayEmbedded(overlayPlane) && _overlayData[overlayPlane.Index] == null) { byte[] overlayData = OverlayData.UnpackFromPixelData(overlayPlane.OverlayBitPosition, this.Parent[DicomTags.BitsAllocated].GetInt32(0, 0), false, pixelData); _overlayData[overlayPlane.Index] = overlayData; } else if (!overlayPlane.HasOverlayData) { Platform.Log(LogLevel.Warn, "The image {0} appears to be missing OverlayData for group 0x{1:X4}.", this.Parent.SopInstanceUid, overlayPlane.Group); } } NormalizeGrayscalePixels(this.Parent, pixelData); } return(pixelData); }
protected override byte[] CreateNormalizedPixelData() { byte[] pixelData = _framePixelData.GetUncompressedPixelData(); string photometricInterpretationCode = this.Parent[DicomTags.PhotometricInterpretation].ToString(); PhotometricInterpretation pi = PhotometricInterpretation.FromCodeString(photometricInterpretationCode); TransferSyntax ts = TransferSyntax.GetTransferSyntax(this.Parent.TransferSyntaxUid); if (pi.IsColor) { if (ts == TransferSyntax.Jpeg2000ImageCompression || ts == TransferSyntax.Jpeg2000ImageCompressionLosslessOnly || ts == TransferSyntax.JpegExtendedProcess24 || ts == TransferSyntax.JpegBaselineProcess1) { pi = PhotometricInterpretation.Rgb; } pixelData = ToArgb(this.Parent, pixelData, pi); } else { var overlayPlaneModuleIod = new OverlayPlaneModuleIod(Parent); foreach (var overlayPlane in overlayPlaneModuleIod) { if (!overlayPlane.HasOverlayData && _overlayData[overlayPlane.Index] == null) { // if the overlay is embedded in pixel data and we haven't cached it yet, extract it now before we normalize the frame pixel data var overlayData = OverlayData.UnpackFromPixelData(overlayPlane.OverlayBitPosition, Parent[DicomTags.BitsAllocated].GetInt32(0, 0), false, pixelData); _overlayData[overlayPlane.Index] = overlayData; } } NormalizeGrayscalePixels(this.Parent, pixelData); } return(pixelData); }