0
votes

This question is regarding the RLE algorithm used to compress images ( in this case encapsulated in a DICOM file)

Say I have a pixel data 50 pixel by 50 pixel. It represents a grayscale image with a single color component of 8 bits ( basically one byte is single 8 bit pixel ... this assumption just for sake of simplicity though has no bearing on question actually - would apply to color images as well)

To perform a run length encoding of this image the "runs" are defined as follows ( as per the standard)

Replicate run ( A sequence of identical bytes) - encoded as a two-byte code < -count + 1 > where count = the number of identical bytes in the run ( 2 <= count <= 128 )

Literal Run ( a non-repetitive sequence of bytes) - encoded as a two byte code < count - 1 > where count = number of bytes in the sequence (1 <= count <= 128 )

The questions:

  1. Can the Replicate run and the Literal Run transcend row and column boundaries ? I mean. In the example of pixel data 50X50 pixels - if we have first two rows of white pixels. Is is legitimate RLE to encode first two rows as a replicate run of 100 bytes ( -99 ,< value of white pixel> ) - or should they broken up in two runs of 50 pixels each ?

  2. Is there any de-facto protocol to start a new run on every new row ?

1
Sure @CodeCaster - I suppose It should be ok to treat image as a one dimensional stream of bytes for sake of RLE encoding - decoding . RLE seems to have no dependency on the two dimensional attributes of image. The two dimensions have a bearing at time of rendering or maybe for those compressions that take these dimentions in account, but not for RLE encode decode. However I am trying to understand if owing to something that I fail to see is there a de-facto practice otherwise.Yogesh Devi

1 Answers

1
votes

As per DICOM PS 3.5 2015-b §G.3.1 The RLE Encoder, you should not cross row boundaries:

Each row of the image shall be encoded separately and not cross a row boundary.

Now this is a restriction for the encoder, if you are implementing a general RLE decoder, pay attention that some vendor do not implement this restriction. Which make it particularly painful to deal with when streaming RLE encoding DICOM file (=partial decoding of a particular region).