ITK icon indicating copy to clipboard operation
ITK copied to clipboard

ImageIOFactory read tiff image get error pixel type.

Open Hconk opened this issue 3 years ago • 10 comments

Description

I use Photoshop/ImageJ open the test image , both get real pixel type of 16bit. But ITK TIFFIO get UCHAR( 8bit ).

tiffinfo : image

Fiji: image

Steps to Reproduce

#include <itkImageFileReader.h>

int
main(int, char**)
{
  std::string filename = "../tiff_bug_1.tif";
  itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
    filename.c_str(), itk::ImageIOFactory::ReadMode);

  if (imageIO.IsNull()) {
    std::cout << "fail create Image io." << std::endl;
    return false;
  }

  imageIO->SetFileName(filename);
  imageIO->ReadImageInformation();

  const auto pixelType = imageIO->GetComponentType();
  std::cout << "image pixel type: " << pixelType << std::endl;
  std::cout << "image pixel type: "
            << imageIO->GetComponentTypeAsString(pixelType) << std::endl;
  std::cout << "image dim: " << imageIO->GetNumberOfDimensions() << std::endl;
  return 0;
}

Expected behavior

Test image real pixel type is unsigned shot(16bit).

Actual behavior

image pixel type: 1
image pixel type: unsigned_char
image dim: 2

Reproducibility

everytime.

Versions

ITK Version: 5.1.0/5.2.0/master latest

Environment

CMake: 3.21.1 Compiler: gcc4.8.5/vs2017

Additional Information

test data 1: https://drive.google.com/file/d/1O3PCYt6nz1HKuvnZxtbI_U3fox582yAt/view?usp=sharing sha256: 9201f1ac5888d6c3efbf3055fd6505c84e100383e4f5bb14d7237b1187f77186

test data 2: https://drive.google.com/file/d/17I1ua6HOtIKV7jQId-10ioJCra6s6i9Z/view?usp=sharing sha256: b693140a8fdd76765b5091732a0b7db902621b7873588819c783282d9598dd73

Hconk avatar Dec 15 '21 08:12 Hconk