gdl icon indicating copy to clipboard operation
gdl copied to clipboard

TIFF_READ does not support complex integers

Open sjfrasier opened this issue 3 years ago • 4 comments

tiff.cxx does not include provision for reading complex integer formats (typical for synthetic aperture radar data). Suggest the below case which interprets them as various integer types that can be decoded by the user later.

      case TIFF::Directory::SampleFormat::ComplexInteger:
            switch(bitsPerSample) {
            case 16: pixelType = GDL_INT;       break;
            case 32: pixelType = GDL_LONG;      break;
            case 64: pixelType = GDL_LONG64;    break;
            default: printf(BPS_ERR_FMT, "COMPLEXINT", bitsPerSample);
      } break;

to then decode complex 32-bit integers (16 bits real, 16 bits imaginary), for example, c = complex(fix(i and 65535), fix(i / 65536)).

sjfrasier avatar Sep 13 '22 17:09 sjfrasier

Thank you @sjfrasier! Let's create a PR for this change. Could you also supply a test code (and test file) that uses the added logic? Thanks, Sylwester

slayoo avatar Sep 15 '22 07:09 slayoo

Haven't done a PR before and don't want to break anything. Any advice?

sjfrasier avatar Sep 15 '22 15:09 sjfrasier

go ahead ! If you broke somethings in the code, the CI system will complain.

alaingdl avatar Sep 15 '22 21:09 alaingdl

I think I did it, though maybe only on my own fork? Realizing I can't truly give you a test image because I cannot actually make a tiff file with the ComplexInteger tiff data type embedded, and I cannot share ones that I have due to data licensing. But it does work...

sjfrasier avatar Sep 16 '22 14:09 sjfrasier

@sjfrasier to create a PR, you need to point Github to a branch where your modifications are stored: https://github.com/gnudatalanguage/gdl/compare

so far, there is no PR from you registered yet

slayoo avatar Oct 19 '22 06:10 slayoo

looks we have a PR today...

GillesDuvert avatar Nov 07 '22 23:11 GillesDuvert