kaanaksit / odak

Scientific computing library for optics, computer graphics and visual perception.
https://kaanaksit.com/odak
Mozilla Public License 2.0
177 stars 52 forks source link

Loading images with Odak in a normalized manner #41

Closed kaanaksit closed 2 years ago

kaanaksit commented 2 years ago

Odak has two functions to load images as a Numpy and Torch variable. These are odak.tools.load_image and odak.learn.tools.load_image. Given many of the recipes within Odak uses normalized values between zero to one, it makes perfect sense to load images in a normalized way by default rather than having them represented in 8-bit pixel depth.

kaanaksit commented 2 years ago

Commit a04a4bf98af252caae8b9716f12f6646276f976b resolves this issue. Below you can find an example use case:

In [2]: import odak

In [3]: image = odak.learn.tools.load_image('ground_truth.png', normalizeby=255.)

In [4]: image = odak.learn.tools.load_image('ground_truth.png', normalizeby=255., torch_style=True)

In [5]: image.shape
Out[5]: torch.Size([3, 1080, 1920])

In [6]: image = odak.learn.tools.load_image('ground_truth.png', normalizeby=255.)

In [7]: image.shape
Out[7]: torch.Size([1080, 1920, 3])