Skip to content

Commit 164c1cb

Browse files
PtiLukyhjmjohnson
authored andcommitted
BUG: Allow rescaling int to uint of same size
Dicomfile with signed int data (pixel rep=1) can be decoded as uint with the correct intercept. The assertion blocking this behavior has been changed to a more meaningful check. Closes #5290
1 parent 43ea92d commit 164c1cb

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Modules/IO/GDCM/src/itkGDCMImageIO.cxx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,32 @@ GDCMImageIO::InternalReadImageInformation()
533533
outputpt = r.ComputeInterceptSlopePixelType();
534534
}
535535

536-
if (pixeltype > outputpt)
536+
bool ptLarger = false;
537+
switch (outputpt)
538+
{
539+
// Default comparison uses the > operator and the order in ScalarType enum
540+
// INT types needs to be adjusted so signed input is allowed to produce unsigned output
541+
case gdcm::PixelFormat::UINT8:
542+
ptLarger = pixeltype > gdcm::PixelFormat::INT8;
543+
break;
544+
case gdcm::PixelFormat::UINT12:
545+
ptLarger = pixeltype > gdcm::PixelFormat::INT12;
546+
break;
547+
case gdcm::PixelFormat::UINT16:
548+
ptLarger = pixeltype > gdcm::PixelFormat::INT16;
549+
break;
550+
case gdcm::PixelFormat::UINT32:
551+
ptLarger = pixeltype > gdcm::PixelFormat::INT32;
552+
break;
553+
case gdcm::PixelFormat::UINT64:
554+
ptLarger = pixeltype > gdcm::PixelFormat::INT64;
555+
break;
556+
default:
557+
ptLarger = pixeltype > outputpt;
558+
break;
559+
}
560+
561+
if (ptLarger)
537562
{
538563
itkAssertInDebugOrThrowInReleaseMacro("Pixel type larger than output type")
539564
}

0 commit comments

Comments
 (0)