How to save HDR file with numpy array?

197 Views Asked by At

I try to save HDR file with numpy array as follows.

numpy array like this (dtype:np.float32)

# hdr_file_data
[[[0.32543945, 0.38671875, 0.44213867],
  [0.30029297, 0.34204102, 0.3737793 ],
  [0.2697754,  0.28515625, 0.28295898],
  [0.2388916,  0.23449707, 0.20837402]],

 [[0.35668945, 0.4309082,  0.49853516],
  [0.32495117, 0.37939453, 0.4230957 ],
  [0.2836914,  0.3059082,  0.3088379 ],
  [0.2454834,  0.24353027, 0.21777344]],

 [[0.46069336, 0.54248047, 0.6040039 ],
  [0.4128418,  0.47705078, 0.51708984],
  [0.33666992, 0.3684082,  0.3713379 ],
  [0.28027344, 0.2854004,  0.26000977]],

 [[0.64697266, 0.7270508,  0.7607422 ],
  [0.60302734, 0.6665039,  0.67871094],
  [0.49047852, 0.52783203, 0.515625  ],
  [0.38598633, 0.40063477, 0.37036133]]]

I use imageio lib to save HDR file like:

imageio.imwrite(filenameA,hdr_data, format='HDR-FI')

And then i try to use

imageio.imread(filenameA,format='HDR-FI') 

to check the value is correct. However, the pixel values as follows are different with above hdr_data. How can I make sure the values are correct?

[[[0.32421875, 0.38671875, 0.44140625],
  [0.29882812, 0.34179688, 0.37304688],
  [0.26953125, 0.28515625, 0.28125   ],
  [0.23828125, 0.234375,   0.20800781]],

 [[0.35546875, 0.4296875,  0.49804688],
  [0.32421875, 0.37890625, 0.421875  ],
  [0.28320312, 0.3046875,  0.30859375],
  [0.24511719, 0.24316406, 0.21777344]],

 [[0.45703125, 0.5390625,  0.6015625 ],
  [0.41015625, 0.4765625,  0.515625  ],
  [0.3359375,  0.3671875,  0.37109375],
  [0.27929688, 0.28515625, 0.25976562]],

 [[0.64453125, 0.7265625,  0.7578125 ],
  [0.6015625,  0.6640625,  0.67578125],
  [0.48828125, 0.52734375, 0.515625  ],
  [0.38476562, 0.40039062, 0.36914062]]]
0

There are 0 best solutions below