Closed vucenovic closed 2 years ago
Hello @vucenovic,
I've transferred your issue to the Mitsuba 3 repo, hopefully this is correct. If not, I strongly encourage you to upgrade, as Mitsuba 3 has many improvements and bugfixes over Mitsuba 2.
Here's a good way to do it with the Python API:
>>> b
Bitmap[
pixel_format = rgba,
component_format = uint8,
size = [500, 656],
srgb_gamma = 1,
struct = Struct<4>[
uint8 R; // @0, normalized, gamma
uint8 G; // @1, normalized, gamma
uint8 B; // @2, normalized, gamma
uint8 A; // @3, normalized, alpha
],
data = [ 1.25 MiB of image data ]
]
>>> mi.TensorXf(b)
TensorXf(shape=(656, 500, 4))
>>> mi.TensorXf(b).array
[0.0, 0.0, 0.0, 0.0, 0.0, .. 1311990 skipped .., 0.0, 0.0, 0.0, 0.0, 0.0]
>>>
On the last line, you can see that the tensor is just a wrapper around a Float
object. We recommend keeping the TensorXf
though, since it maintains the shape of the data as well.
Thanks for the quick response! Sadly I am not able to upgrade for the time being, would this also work on Mitsuba2? And could you maybe add the required imports to the solution (what is 'mi')?
Here would be an option for Mitsuba 2:
>>> import numpy as np
>>> import mitsuba
>>> mitsuba.set_variant('cuda_ad_rgb')
>>> b = mitsuba.core.Bitmap('path/to/image.exr')
>>> mitsuba.core.Float(np.array(b).ravel())
KeyboardInterrupt
>>> mitsuba.core.Float(np.array(b).ravel())
[0.0, 0.0, 0.0, 0.0, 0.0, .. 1311990 skipped .., 0.0, 0.0, 0.0, 0.0, 0.0]
mi
is just the recommended alias we use in Mitsuba 3.
Unfortunately, we most likely won't have the bandwidth to provide support for Mitsuba 2. The migration shouldn't be too hard (majority of changes are components having moved around and some renames), and would be well worth it.
Thank you! I will look into Mitsuba3 and the migration process soon :)
Kind regards
Hello,
I am trying to use synthetic reference images for my optimization but I am struggling to find a way to convert my Bitmap object to a Float32 representation, is there any way to do it via the python core API?
Kind regards