If I run in a Release mode (NDEBUG) I get my file read all right, I have no problem with it. Please guide me understanding what is happening, why and how I should go on doing things right (I need to work in debug mode).
It appears that the assert fails because it checks that the pixel format has not been changed between here and here if this condition is false, meaning if the image is not `gdcm::PhotometricInterpretation::PALETTE_COLOR.
However, the pixel format can be modified here because inside GetBufferInternal(), the correct codec is called to decode the image and inside the TryJPEG2000Codec function the HighBit (at least in the case of your image) can be modified.
So, the assert in itkGDCMImageIO is a little to strict. The simple solution would be to remove it, but maybe there is a way to keep it and make the if statement around it more restrictive to avoid this type of issues.
@fbudin You forgot one item in your demonstration. The PixelFormat == operator only checks the ScalarType (uint16 vs uint32). So we should not care about the HighBit value here. See:
@mathieu.malaterre , I ran the program step by step in debug mode and it was going in the operator== function that @mihail.isakov pointed out. To reproduce the problem, I actually simply downloaded the code from an ITK example here and downloaded the dataset provided by @Dominik_Szczerba. The reader works for some of the dcm files and fails for some. Maybe they use a different codec? But if you want to reproduce the problem, you can use the example I pointed to and create a repository with only the IM-0001-0520.dcm file.