5

I can import 70000 x 2MB TIFF images (~140GB) using

Image`ImportExportDump`ImageReadTIFF

in about 3 minutes based on @Szabolcs solution to this question by @Kagaratsch which is fantastic.

However, the image data is converted to floating point numbers <1.

Is there an option for Image`ImportExportDump`ImageReadTIFF which will preserve the original integer image data?

I tried using the options "Data", "Bit16", "Automatic" which returned $Failed.

DrBubbles
  • 1,391
  • 9
  • 17
  • Hard to help without the actual file. Can you upload your image somewhere and post a link? – M.R. Oct 30 '18 at 17:15
  • Please try to put a TIFF file somewhere we can access it, then include code that shows what you expect to get back and what you actually get back. – Jason B. Oct 30 '18 at 18:26
  • @DrBubbles you posted a PNG not a TIFF – M.R. Oct 30 '18 at 18:34
  • Sorry, I will generate one inline when I get back to my desk – DrBubbles Oct 30 '18 at 18:37
  • Generating the code to create the image data and re-display it highlighted the issue and solved the question :-) Thanks Jason and M.R. – DrBubbles Oct 30 '18 at 19:10
  • But maybe there is a way to speed things up further as I only need the ImageData so once imported it would be fine to stay as data and not an image. – DrBubbles Oct 30 '18 at 19:12
  • 1
    @DrBubbles - if you solved your problem, consider moving the Update section to a self-answer if you think this will help someone in the future. – Jason B. Oct 30 '18 at 19:18

1 Answers1

5

Update: Just found the problem was my use of ImageData[]. I thought I needed to export the data with "Bit16", I didn't realize (or forgot) I needed to use it with ImageData[] too. Now I get the expected 16 bit integers in import using Image`ImportExportDump`ImageReadTIFF :

SetDirectory[NotebookDirectory[]];
im1 = Image[RandomInteger[{0, 65535}, {512, 512}], "Bit16"];
Export["im1.tiff", im1];
im2 = Image`ImportExportDump`ImageReadTIFF[
AbsoluteFileName["im1.tiff"]][[1]];
ImageData[im1, "Bit16"][[1, 1]]
ImageData[im2, "Bit16"][[1, 1]]
Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309
DrBubbles
  • 1,391
  • 9
  • 17