Recently I have seen some color DICOM files with big endian transfer syntax, where pixel data had OW (Other Word) value representation. Byte order in file is
R1G1B1R2G2B2 etc
AFAIK, according to DICOM standard (part 5, Section 8.1, The only difference between OW and OB being that OB, a string of bytes, shall be unaffected by Byte Ordering), when converting this image to little endian, the byte order should be changed so that it will become
G1R1R2B2B2G2 etc
but this does not make any sense! This image was obviously intended to have Other Byte value representation. As interesting detail, the image also contained an Icon Image Sequence with a smaller version of pixeldata, that also had OW VR, but here the bytes were actually swapped! (in this manner: G1R1R2B2B2G2). So it's not even consistent...
My question is: is it even legal? And how should I change the endianness of such an image?
EDIT: for cdeszaq: acording to DICOM standard part 5, section 7.3:
VRs that are not a string of characters and consist of multiple bytes are:
2-byte US, SS, OW and each component of AT
4-byte OF, UL, SL, and FL
8 byte FD
this suggests that the word size is already specified by VR.
In order to change the endianness of the OW image data, you need to know the size of the words. If you don't know the word size, it is impossible to change the endiannes.
To go into a bit more detail, the endianness of a word refers to the ordering of the bytes within the word, either larger-to-smaller, or smaller-to-larger. If you don't know where the word boundaries are in a stream of bytes, it is impossible to re-order them, since you don't know what byte is currently in what position within the word.
The lack of words (ie. being nothing more than a stream / string of bytes) is what allows OB objects to be unaffected by the endiannness, since the words are effectively 1 byte long.
I would suggest referencing Annex A of PS 3.5 of the DICOM Standard. A.2 covers explicit VR little endian and states:
Data Element (7FE0,0010) Pixel Data - where Bits Allocated (0028,0100) has a value greater than 8 shall have Value Representation OW and shall be encoded in Little Endian; - where Bits Allocated (0028,0100) has a value less than or equal to 8 shall have the Value Representation OB or OW and shall be encoded in Little Endian.
So a VR of OW is acceptable for images with 8 bits allocated (such as RGB where 8 bits are allocated and there are 3 samples per pixel).
The standard also defines how pixels values that use less or more bits than the word they are packed in are aligned in the word, so I think it is legal to have OW as VR (part 5 Annex D)