Skip to content
Snippets Groups Projects
Commit 7032da8c authored by Simon Wittl's avatar Simon Wittl
Browse files

add projection loader

parent ca9a1519
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@
"image": {
"uuid": "d58262dd-a6b2-11ef-a41a-f46d3febaf33",
"timestamp": "2024-11-19 20:14:08.825622",
"image_path": "d58262dd-a6b2-11ef-a41a-f46d3febaf33.tif"
"image_path": "projection_d58262dd-a6b2-11ef-a41a-f46d3febaf33.tif"
},
"detector": {
"image_width_px": 1000,
......
......@@ -22,6 +22,12 @@ detector_validator = "thd_json.detector:detector_cli"
source_validator = "thd_json.source:source_cli"
projection_geometry_validator = "thd_json.projection_geometry:projection_geometry_cli"
[project.optional-dependencies]
load = [
"numpy>=2.1.3",
"pillow>=11.0.0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
from thd_json.load_projection import load_thd_projection
from pathlib import Path
LOAD_PATH = Path('./examples/artist/projection_d58262dd-a6b2-11ef-a41a-f46d3febaf33.json')
def main():
meta_data, projection = load_thd_projection(LOAD_PATH)
print(meta_data)
print(f'Projection Shape: {projection.shape}')
if __name__ == '__main__':
main()
\ No newline at end of file
import numpy as np
from PIL import Image
import json
from pathlib import Path
def load_thd_projection(json_path: Path):
if not json_path.suffix.endswith('json'):
raise ValueError('Wrong data type. Input must be `.json`file.')
meta_data = json.load(json_path.open())
image = np.asarray(Image.open(json_path.parent / meta_data['image']['image_path']))
return meta_data, image
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment