Skip to content
Snippets Groups Projects
Commit 50ba6993 authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

start adding script to visualize correlation as a 2d histogram

parent 1e918e65
No related branches found
No related tags found
No related merge requests found
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
import pydicom
from mu_map.dataset.util import load_dcm_img, align_images
from mu_map.util import to_grayscale
mu_map = load_dcm_img("./data/second/images/0085-stress-mu_map.dcm")
# mu_map_syn = load_dcm_img("./tmp/0085-stress-mu_map-dl.dcm")
mu_map_syn = load_dcm_img("./data/second/images/0084-stress-mu_map.dcm")
mu_map, mu_map_syn = align_images(mu_map, mu_map_syn)
_max = max(mu_map.max(), mu_map_syn.max())
_mu_map = to_grayscale(mu_map[mu_map.shape[0] // 2], max_val=_max, min_val=0)
_mu_map_syn = to_grayscale(mu_map_syn[mu_map_syn.shape[0] // 2], max_val=_max, min_val=0)
_mu_map = cv.resize(_mu_map, (512, 512))
_mu_map_syn = cv.resize(_mu_map_syn, (512, 512))
s = np.full((512, 10), 239, np.uint8)
# cv.imshow("Test", np.hstack((_mu_map, s, _mu_map_syn)))
# cv.waitKey(0)
fig, axs = plt.subplots(1, 2)
for ax in axs:
ax.set_xlabel(r"μ-Map CT (cm$^{-1}$)")
ax.set_ylabel(r"μ-Map DL (cm$^{-1}$)")
hist, _, _, _ = axs[0].hist2d(mu_map.flatten(), mu_map_syn.flatten(), bins=[100, 100], range=((0.0, 0.2), (0.0, 0.2)))
hist[0, 0] = 0
axs[1].imshow(hist, origin="lower")
plt.tight_layout()
plt.show()
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