Closed HarmvZ closed 5 years ago
For the BMES fundus images with dimension 3888 x 2592 the value is set to:
ElementSpacing = 0.0093382352941176472 0.0093382352941176472
I looked into the JPEG specification for these files (JFIF 1.01) there are some parameters in there which define pixel density. For these files they are defined as:
Density units: 01
=Pixels per inch
Xdensity: 0A A0
=2720
Ydensity: 0A A0
=2720
Converting these values to a pixel size/spacing in mm (= the unit for ElementSpacing in MHD files) gives:
1/2720 pixels/inch = 3.676e-4 inch/pixel
3.676e-4 inch/pixel * 25,4 mm/inch = 0.0093382... mm/pixel
Which is indeed the value that SimpleITK used as the ElementSpacing
.
The actual size of the image would then be 36.31 x 24.20mm which sound like reasonable numbers to me. I will check if these values correspond with the study data.
The other BMES images with dimensions 4992 x 3328 en 4243 x 3294 both have values of:
ElementSpacing = 0.16933333333333334 0.16933333333333334
The JPEG data (JFIF 1.00) reveals these values come from a pixel density of 150 ppi. These values are obviously not realistic. I need to find the correct pixelsize/spacing and set these in the MHD header or, if those do not exist, change it to the default of 1 1
and make my application return estimated spacing/size values when the MHD header is 1 1
.
Next, I need to check the TIFF and PNG images in the other datasets (RS1/2/3 and kappa).
I looked into the TIFF specification. It defines a ResolutionUnit
, XResolution
and YResolution
. The PNG specification does not define pixel density. I analyzed (almost) all files in the archives. This is a summary of the results:
Archive | Imagetype | Dimensions | ResolutionUnit | XResolution | YResolution | ElementSpacing | Corresponds | Realistic |
---|---|---|---|---|---|---|---|---|
Kappadata | TIFF | 768 x 576 | PPI | 150 | 150 | 0.16933333333333334 0.16933333333333334 | Yes | No |
RS 1 | TIFF | 1620 x 1080 | PPI | 150 | 150 | 0.16933333333333334 0.16933333333333334 | Yes | No |
RS 1 (HRA) | TIFF | 768 x 868 | PPI | 96 | 96 | 0.26458333333333334 0.26458333333333334 | Yes | No |
RS 3 | TIFF | 768 x 576 | PPI | 150 | 150 | 0.16933333333333334 0.16933333333333334 | Yes | No |
RS 1 | TIFF | 1009 x 775, 881 x 749, 1027 x 783, 911 x 765, 913 x 783, 917 x 747, 901 x 767, 897 x 761, ... | PPI | 3000 | 3000 | 0.0084666838921791422 0.0084666838921791422 | Yes | No |
RS 1 | PNG | 931 x 701 | - | - | - | 1 1 | Yes (Default) | No |
So it appears that SimpleITK gets the ElementSpacing
value from the pixel density in the TIFF and JPEG files. These values do not seem to be correct however.
Interesting, could cause some nasty bugs. Please add this to the agenda at the RSE meeting on Monday.
I noticed that all of my images that are saved by SimpleITK as MHD files contain a
ElementSpacing
header entry (=voxel spacing) that is not1 1
which is the default value. SimpleITK apparently gets the value from somewhere.I need to find out where it gets the value from and if the value is realistic/correct.