简体   繁体   中英

How can I read single-channel 32-bit integer images with python?

I want to read single-channel 32-bit integer image saved as ssv file. I have tried so far(see the following code) but without much success.

Here is the code

Please let me know if you have any idea of what is missing?

You as user should have the necessary information about this image-data which is needed. I can only assume things and work on that.

Opening the file it seems it's:

  • text-based (supported by your ImageJ-comment)
  • using uint32 (numbers too big for uint8; the classic case)

Follwing above and ImageJ's docs:

Opens a tab-delimited text file as a 32-bit real image

i would do:

import numpy as np
import matplotlib.pyplot as plt                      # just for demo

img_raw = np.loadtxt('test.ssv', dtype=float)        # casting-early to float
img_float_01 = img_raw / 4294967295.  # max uint32   # normalize to float in [0, 1]

plt.imshow(img_raw, cmap='gray')
plt.show()

which outputs:

在此处输入图片说明

So it seems we successfully read that image into a numpy-array.

You need now to:

  • think what steps you need to use that array in QT
  • think if you will use above code or look for some more safe route like using scikit-image for example (if you need [0,1] normalization; reading will always be done by numpy's loadtxt)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM