When reading the Pixel Data with dcm4che, it returns an object of type Fragment, which has a byte array with a size of 219576 bytes, however the image size is 512x512 with each pixel occupying 16 bits, so the expected would be 524288 bytes if the image was not compressed. Because of that I'm sure the image is compressed/encapsulated (not sure about the difference) and I want to unzip it.
How could I transform that 219576 bytes in expected 524288 bytes? (I want to have access every pixel color)
File file = new File(filename);
DicomInputStream dis = new DicomInputStream(file);
Attributes attrs = dis.readDataset();
Object image = attrs.getValue(Tag.PixelData);
if (image.getClass() == Fragments.class) {
//decompress here
}
dis.close();
This is the DICOM file I'm working and his tags and values: https://pastecode.io/s/ofmt5uf1
"0008|0021" -> "20230619"
"0008|0020" -> "20230619"
"0008|3010" -> "1.3.12.2.1107.5.1.7.107544.30000023061909300914900000089"
"0008|0023" -> "20230619"
"0008|0022" -> "20230619"
"0029|1024" -> "Spine "
"0029|1022" -> "16"
"0029|1028" -> "0\48.3151"
"0010|0020" -> "72918 "
"0029|1027" -> "150.63"
"0029|1026" -> "150.63"
"0018|9323" -> "ELLIP_ZEC "
"0020|1041" -> "-1240.06"
"0018|1200" -> "20230619"
"0020|1040" -> ""
"0018|1201" -> "081456.000000 "
"0018|1160" -> "None"
"0029|100f" -> "1"
"0029|100e" -> "UNDEFINED "
"0029|100d" -> "FFSNONE "
"0040|0245" -> "093956.911773 "
"0040|0244" -> "20230619"
"0029|1014" -> "FALSE "
"0029|1013" -> "FALSE "
"0029|1011" -> "SAFIRE2 "
"0008|0016" -> "1.2.840.10008.5.1.4.1.1.2"
"0029|1018" -> "FALSE "
"0029|1017" -> "FALSE "
"0008|0018" -> "1.3.12.2.1107.5.1.7.107544.30000023061909300914900001296"
"0029|1016" -> "FALSE "
"0029|1015" -> "FALSE "
"0010|0010" -> "PIETRO LEVY SETUBAL "
"0018|1210" -> "Br60f\3 "
"0028|0030" -> "0.294203125\0.294203125 "
"0029|1019" -> "0"
"0021|0010" -> "SIEMENS MED "
"0018|1170" -> "8 "
"0008|0090" -> ""
"0019|0010" -> "SIEMENS CT EXAM APP SHARED"
"0008|1010" -> "CT107544"
"0029|1043" -> "3"
"0028|0301" -> "NO"
"0029|1046" -> "0.5"
"0008|0201" -> "-0300 "
"0029|1045" -> "0.4"
"0029|1048" -> "NONE"
"0018|9345" -> "10.8698"
"0020|0052" -> "1.3.12.2.1107.5.1.7.107544.30000023061909300914900000087"
"0029|1209" -> "VA10A 971201"
"0018|1100" -> "150.632589502953"
"0029|1208" -> "SOM 5 "
"0018|0015" -> "SPINE "
"0029|102a" -> "CHILD "
"0008|002a" -> "20230619094136.916000 "
"0029|102e" -> "FALSE "
"0029|102c" -> "16"
"0029|102b" -> "3"
"0018|0090" -> "499.799988"
"0029|102f" -> "c0bf3ca5-a91b-43d9-b4ec-483d516b3e38"
"0008|0030" -> "093956.911773 "
"0029|1031" -> "450"
"0008|0032" -> "094136.916000 "
"0029|1030" -> "ALGOSLIDE "
"0008|0031" -> "094156.128805 "
"0008|0033" -> "094136.916000 "
"0028|0011" -> "512"
"0029|1039" -> "TRUE"
"0029|1038" -> "-1240.06"
"0028|0010" -> "512"
"0029|1037" -> "1000"
"0018|1110" -> "983 "
"0018|1111" -> "535 "
"0018|1190" -> "1.6\1.6 "
"0029|101d" -> "134"
"0029|101b" -> "0"
"0029|101a" -> "ITR_Off "
"0029|101f" -> "0"
"0029|101e" -> "16"
"0028|0004" -> "MONOCHROME2 "
"0029|0012" -> "SIEMENS CSA HEADER"
"0028|0002" -> "1"
"0029|0010" -> "SIEMENS CT EXAM IMAGE "
"0029|0011" -> "SIEMENS CT EXAM EQUIPMENT "
"0010|1030" -> ""
"0029|1106" -> "3.84984"
"0010|2000" -> ""
"0020|0032" -> "-75.1688984375\-132.8538984375\-1240.06 "
"0028|1054" -> "HU"
"0029|1104" -> "435234"
"0018|1120" -> "0 "
"0028|1055" -> ""
"0018|1000" -> "107544"
"0028|1052" -> "-8192 "
"0028|1053" -> "1 "
"0029|1109" -> "P81A"
"0028|1050" -> "450 "
"0028|1051" -> "1500"
"0021|1011" -> "0\48.3151045659296"
"0029|104f" -> "Bone"
"0029|104e" -> "Manual"
"0008|0060" -> "CT"
"0029|1052" -> "130.0 kV"
"0020|4000" -> ""
"0029|1051" -> "80.0 kV "
"0010|2110" -> ""
"0018|1130" -> "106.000 "
"0010|1020" -> ""
"0029|103b" -> "213"
"0020|0037" -> "1\0\0\0\1\0 "
"0029|1050" -> "236.0 mAs "
"0008|0050" -> "188828"
"0028|0107" -> "10006"
"0028|0106" -> "6869"
"0018|9309" -> "8.9"
"0028|0103" -> "0"
"0028|0101" -> "16"
"0018|0050" -> "1 "
"0028|0102" -> "15"
"0008|0005" -> "ISO_IR 100"
"0010|0040" -> "M "
"0018|9305" -> "1"
"0020|0012" -> "200 "
"0029|1007" -> "1000"
"0018|1140" -> "CW"
"0018|9306" -> "0.7"
"0020|0011" -> "3 "
"0028|0100" -> "16"
"0029|1006" -> "1587"
"0010|1010" -> "007Y"
"0018|1020" -> "syngo CT VA30A"
"0018|9307" -> "11.2"
"0020|0010" -> "230619085613"
"0018|5100" -> "HFS "
"0008|0008" -> "ORIGINAL\PRIMARY\AXIAL\CT_SOM5 SPI"
"0029|1009" -> "STANDARD"
"0008|103e" -> "VOL OSSO"
"0020|000e" -> "1.3.12.2.1107.5.1.7.107544.30000023061909300914900000197"
"0020|000d" -> "1.2.826.1.1.3680043.2.1396.11123.88282918.2306190855"
"0018|1150" -> "1250"
"0018|1030" -> "COLUNA TORACICA-LOMBAR"
"0018|1151" -> "107 "
"0018|1152" -> "134 "
"0018|9318" -> "0\-57.685\-1240.06"
"0010|0030" -> "20160315"
"0028|2110" -> "00"
"0018|9313" -> "0\-106\-1240.06"
"0018|9310" -> "8.96"
"0018|9311" -> "0.8"
"0020|0013" -> "549 "
"0018|0060" -> "110 "
"0019|1002" -> "283"
"0019|1003" -> "Br60fS3n0.:02644:0HhAAL1aaA "
"0008|0070" -> "Siemens Healthineers"
"0008|1040" -> "Centro de Imagem"
Pixel data decoding and encoding in dcm4che is provided through the Java Image I/O API. A set of image readers and writers are automatically recorded so that it supports reading DICOM files, as well as translating a supported set of transfer syntaxes.
The easiest way to obtain an image is through
ImageIO:The outcome is a rendered form of the pixel data, including Modality LUT and VOI LUT. You can skip these transformations by requesting the raster instead. This may require you to fill in some blanks if you want to turn it into a rendered image, but it is closer to a native pixel data form.
This is supported by dcm4che since at least v2, although the details on how to register custom image readers and writers depending on transfer syntax may differ.
You can find the difference between native pixel data and encapsulated pixel data in the standard, part 5, section 8.2. In short, Pixel Data comprising a list of fragments means that the pixel data is encapsulated, and the transfer syntax dictates how the pixels are encoded in them.
See also: