Estou tentando usar o ffmpeg para decodificar um buffer de imagem de uma imagem DICOM usando a codificação YBR_FULL_422. De acordo com a definição:
Two Y values shall be stored followed by one CB and one CR value. The
CB and CR values shall be sampled at the location of the first of the
two Y values. For each Row of Pixels, the first CB and CR samples
shall be at the location of the first Y sample. The next CB and CR
samples shall be at the location of the third Y sample etc.
Vamos supor que eu tenha:
$ gdcminfo YBR_FULL_422.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.7 [Secondary Capture Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (600,430,1)
SamplesPerPixel :3
BitsAllocated :8
BitsStored :8
HighBit :7
PixelRepresentation:0
ScalarType found :UINT8
PhotometricInterpretation: YBR_FULL_422
PlanarConfiguration: 0
...
Então eu simplesmente tentei extrair o buffer bruto:
$ gdcmraw YBR_FULL_422.dcm YBR_FULL_422.raw
$ du -sb YBR_FULL_422.raw
516000 YBR_FULL_422.raw
Qual é compatível com o tamanho da imagem: 600 * 430 * 2 = 516000
Mas não consigo convertê-lo em rgb24 comum:
$ ffmpeg -y -f rawvideo -pix_fmt yuv422p -s:v 600x430 -i YBR_FULL_422.raw rgb24.ppm
Input #0, rawvideo, from 'YBR_FULL_422.raw':
Duration: 00:00:00.04, start: 0.000000, bitrate: 103200 kb/s
Stream #0:0: Video: rawvideo (Y42B / 0x42323459), yuv422p, 600x430, 103200 kb/s, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'rgb24.ppm':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: ppm, rgb24, 600x430, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 ppm
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> ppm (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=36.9x
video:756kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
A imagem de saída é esverdeada com passos pretos.