本文整理汇总了C#中DicomUncompressedPixelData.AppendFrame方法的典型用法代码示例。如果您正苦于以下问题:C# DicomUncompressedPixelData.AppendFrame方法的具体用法?C# DicomUncompressedPixelData.AppendFrame怎么用?C# DicomUncompressedPixelData.AppendFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomUncompressedPixelData
的用法示例。
在下文中一共展示了DicomUncompressedPixelData.AppendFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecodeFrame
public void DecodeFrame(int frame, DicomCompressedPixelData oldPixelData, DicomUncompressedPixelData newPixelData, DicomCodecParameters parameters)
{
if (oldPixelData.UncompressedFrameSize%2 == 1)
{
using (var stream = new MemoryStream(oldPixelData.GetFrameFragmentData(frame)))
{
var data = new byte[oldPixelData.UncompressedFrameSize];
stream.Read(data, 0, data.Length);
newPixelData.AppendFrame(data);
}
}
else
{
newPixelData.AppendFrame(oldPixelData.GetFrameFragmentData(frame));
}
}
示例2: DecodeFrame
public void DecodeFrame(int frame, DicomCompressedPixelData oldPixelData, DicomUncompressedPixelData newPixelData, DicomCodecParameters parameters)
{
using (var input = new MemoryStream(oldPixelData.GetFrameFragmentData(frame)))
using (var gzipStream = new GZipStream(input, CompressionMode.Decompress, false))
{
var data = new byte[oldPixelData.UncompressedFrameSize];
gzipStream.Read(data, 0, data.Length);
newPixelData.AppendFrame(data);
}
}
示例3: CreateColorPixelData
protected static void CreateColorPixelData(DicomUncompressedPixelData pd)
{
int rows = pd.ImageHeight;
int cols = pd.ImageWidth;
int minValue = pd.IsSigned ? -(1 << (pd.BitsStored - 1)) : 0;
int maxValue = (1 << pd.BitsStored) + minValue - 1;
const byte noOpByteMask = 0xFF;
var byteMask = (byte)(noOpByteMask >> (pd.BitsAllocated - pd.BitsStored));
// Create a small block of pixels in the test pattern in an integer,
// then copy/tile into the full size frame data
int smallRows = (rows * 3) / 8;
int smallColumns = rows / 4;
int stripSize = rows / 16;
int[] smallPixels = new int[smallRows * smallColumns * 3];
float slope = (float)(maxValue - minValue) / smallColumns;
int pixelOffset = 0;
for (int i = 0; i < smallRows; i++)
{
if (i < stripSize)
{
for (int j = 0; j < smallColumns; j++)
{
smallPixels[pixelOffset] = (int)((j * slope) + minValue);
pixelOffset++;
smallPixels[pixelOffset] = 0;
pixelOffset++;
smallPixels[pixelOffset] = 0;
pixelOffset++;
}
}
else if (i > (smallRows - stripSize))
{
for (int j = 0; j < smallColumns; j++)
{
smallPixels[pixelOffset] = 0;
pixelOffset++;
smallPixels[pixelOffset] = (int)(maxValue - (j * slope));
pixelOffset++;
smallPixels[pixelOffset] = 0;
pixelOffset++;
}
}
else
{
int pixel = minValue + (int)((i - stripSize) * slope);
if (pixel < minValue) pixel = minValue + 1;
if (pixel > maxValue) pixel = maxValue - 1;
int start = (smallColumns / 2) - (i - stripSize) / 2;
int end = (smallColumns / 2) + (i - stripSize) / 2;
for (int j = 0; j < smallColumns; j++)
{
smallPixels[pixelOffset] = 0;
pixelOffset++;
smallPixels[pixelOffset] = 0;
pixelOffset++;
if (j < start)
smallPixels[pixelOffset] = minValue;
else if (j > end)
smallPixels[pixelOffset] = maxValue;
else
smallPixels[pixelOffset] = pixel;
pixelOffset++;
}
}
}
// Now create the actual frame
for (int frame = 0; frame < pd.NumberOfFrames; frame++)
{
// Odd length frames are automatically dealt with by DicomUncompressedPixelData
byte[] frameData = new byte[pd.UncompressedFrameSize];
pixelOffset = 0;
for (int i = 0; i < rows; i++)
{
int smallOffset = (i%smallRows)*smallColumns*3;
for (int j = 0; j < cols*3; j++)
{
frameData[pixelOffset] = (byte) smallPixels[smallOffset + j%(smallColumns*3)];
frameData[pixelOffset] &= byteMask;
pixelOffset++;
}
}
pd.AppendFrame(frameData);
}
}
示例4: DecodeFrame
public void DecodeFrame(int frame, DicomCompressedPixelData oldPixelData,
DicomUncompressedPixelData newPixelData, DicomCodecParameters parameters)
{
DicomRleCodecParameters rleParams = parameters as DicomRleCodecParameters;
if (rleParams == null)
throw new DicomCodecException("Unexpected RLE Codec parameters");
int pixelCount = oldPixelData.ImageWidth * oldPixelData.ImageHeight;
int numberOfSegments = oldPixelData.BytesAllocated * oldPixelData.SamplesPerPixel;
int segmentLength = (pixelCount & 1) == 1 ? pixelCount + 1 : pixelCount;
byte[] segment = new byte[segmentLength];
byte[] frameData = new byte[oldPixelData.UncompressedFrameSize];
IList<DicomFragment> rleData = oldPixelData.GetFrameFragments(frame);
RLEDecoder decoder = new RLEDecoder(rleData);
if (decoder.NumberOfSegments != numberOfSegments)
throw new DicomCodecException("Unexpected number of RLE segments!");
for (int s = 0; s < numberOfSegments; s++)
{
decoder.DecodeSegment(s, segment);
int sample = s / oldPixelData.BytesAllocated;
int sabyte = s % oldPixelData.BytesAllocated;
int pos;
int offset;
if (newPixelData.PlanarConfiguration == 0)
{
pos = sample * oldPixelData.BytesAllocated;
offset = oldPixelData.SamplesPerPixel * oldPixelData.BytesAllocated;
}
else
{
pos = sample * oldPixelData.BytesAllocated * pixelCount;
offset = oldPixelData.BytesAllocated;
}
if (rleParams.ReverseByteOrder)
pos += sabyte;
else
pos += oldPixelData.BytesAllocated - sabyte - 1;
for (int p = 0; p < pixelCount; p++)
{
frameData[pos] = segment[p];
pos += offset;
}
}
newPixelData.AppendFrame(frameData);
}