Description
Describe the bug
Tested in SimpleITK 2.3.1 and calling sitk.ProcessObject_SetGlobalWarningDisplay(False) does not suppress TIFFReadDirectory warning messages such as TIFFReadDirectory: Warning, Unknown field with tag 51123 (0xc7b3) encountered.
To Reproduce
Steps to reproduce the behavior:
- Operating system, version, and architecture
- OS: [Rocky Linux 9 ]
- Architecture: [x86]
- Programming language, and version [Python 3.10.13].
- Version of SimpleITK [2.3.1], output of the SimpleITK Version() function.
- How was SimpleITK installed?
- binary distribution [e.g. python -m pip install SimpleITK]
- A minimal working example which causes the error.
Duplicate any image and load them in ImageJ as an image stack, then save as a tif file. The tif stack file will contain a custom tag of 50838 (0xc696). Then the SimpleITK.ReadImage function call will produce warning messages. Calling the ProcessObject_SetGlobalWarningDisplay(False) won't stop it. See the example below.
$ python
Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import SimpleITK as sitk
sitk.ReadImage('/data/home/test.tif')
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
<SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'itk::simple::Image *' at 0x7f1eaaea1680> >
sitk.ProcessObject_SetGlobalWarningDisplay(False)
sitk.ReadImage('/data/home/test.tif')
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
<SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'itk::simple::Image *' at 0x7f1eaae57bd0> >
sitk.version
'2.3.1'
tiffinfo output of the test tiff stack:
$ tiffinfo /data/home/test.tif
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
=== TIFF directory 0 ===
TIFF Directory at offset 0x8 (8)
Subfile Type: (0 = 0x0)
Image Width: 1200 Image Length: 600
Bits/Sample: 8
Compression Scheme: None
Photometric Interpretation: RGB color
Samples/Pixel: 3
Rows/Strip: 600
Planar Configuration: single image plane
ImageDescription: ImageJ=1.54f
images=10
slices=10
loop=false
Tag 50838: 12,24,24,26,26,26,26,26,26,26,26
Tag 50839: 73,74,73,74,108,97,98,108,0,0,0,10,0,100,0,101,0,108,0,116,0,97,0,95,0,50,0,50,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,51,0,49,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,49,0,56,0,52,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,50,0,52,0,55,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,50,0,53,0,52,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,52,0,53,0,51,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,53,0,48,0,48,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,53,0,52,0,49,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,54,0,54,0,57,0,46,0,112,0,110,0,103,0,100,0,101,0,108,0,116,0,97,0,95,0,57,0,55,0,50,0,46,0,112,0,110,0,103
Expected behavior
Based on the SimpleITK documentation, calling sitk.ProcessObject_SetGlobalWarningDisplay(False) should suppress TIFFReadDirectory warning messages such as TIFFReadDirectory: Warning, Unknown field with tag 51123 (0xc7b3) encountered.
Activity
blowekamp commentedon Feb 24, 2025
Hello @yliu7366,
This have been fix in upstream ITK. This was ported back to the ITK 5.4.1 release and is incorporated into the recent SimpleITK 2.4.1.
Additional libtiff error reporting improvements have been incorporated into the ITK 6.0 development branch, and may shortly be available in the SimpleITK master/nightly build.
Please let me know if the solutions work for you.