Reputation: 61
I have a txt file containing the pixel values. How can I make it into an image.
Upvotes: 0
Views: 102
Reputation: 207465
I struggling to understand what the issue is, and what you mean by "normal" methods and "normal" quality.
Your data doesn't appear to match your code. If you run this command to print the line number and number of fields on the line:
awk '{print NR,NF}' *txt
1 1
2 1
3 2
4 2
5 2
6 2
7 1393
8 1393
9 1393
10 1393
11 1393
12 1393
13 1393
...
...
1043 1393
1044 1393
1045 1393
1046 1393
You will note that:
If you want the values saved/represented as true floating point numbers, you can save them as a TIFF file which can represent floats, alternatively use a PFM file which is understood by GIMP, Photoshop and ImageMagick at least.
import cv2
... your existing code ...
# Make data frame into Numpy array
data = data.iloc[:, :]
na = np.array(data)
# Save as TIFF
cv2.imwrite('result.tif', na)
Upvotes: 1