Commit ·
85440a5
1
Parent(s): 032400a
original window bounds fixed
Browse files
app.py
CHANGED
|
@@ -210,6 +210,10 @@ def get_metric_reference_labels(mode_label: str) -> tuple[str, str]:
|
|
| 210 |
return label_map[left_key], label_map[right_key]
|
| 211 |
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
def metric_explainer(title: str, latex: str, text: str) -> None:
|
| 214 |
with st.expander(f"About {title}"):
|
| 215 |
st.latex(latex)
|
|
@@ -568,6 +572,14 @@ def main() -> None:
|
|
| 568 |
"quantized_windowed": quantized_raw,
|
| 569 |
}
|
| 570 |
histogram_left, histogram_right = get_metric_reference_pair(metric_mode, histogram_images)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
|
| 572 |
mse_value = mean_squared_error(metric_left, metric_right)
|
| 573 |
psnr_value = peak_signal_to_noise_ratio(metric_left, metric_right, data_range=value_range.span)
|
|
@@ -636,8 +648,8 @@ def main() -> None:
|
|
| 636 |
histogram_right,
|
| 637 |
top_label=left_label,
|
| 638 |
bottom_label=right_label,
|
| 639 |
-
|
| 640 |
-
|
| 641 |
),
|
| 642 |
clear_figure=True,
|
| 643 |
)
|
|
|
|
| 210 |
return label_map[left_key], label_map[right_key]
|
| 211 |
|
| 212 |
|
| 213 |
+
def get_metric_reference_keys(mode_label: str) -> tuple[str, str]:
|
| 214 |
+
return METRIC_COMPARISONS[mode_label]
|
| 215 |
+
|
| 216 |
+
|
| 217 |
def metric_explainer(title: str, latex: str, text: str) -> None:
|
| 218 |
with st.expander(f"About {title}"):
|
| 219 |
st.latex(latex)
|
|
|
|
| 572 |
"quantized_windowed": quantized_raw,
|
| 573 |
}
|
| 574 |
histogram_left, histogram_right = get_metric_reference_pair(metric_mode, histogram_images)
|
| 575 |
+
histogram_left_key, histogram_right_key = get_metric_reference_keys(metric_mode)
|
| 576 |
+
|
| 577 |
+
histogram_bounds = {
|
| 578 |
+
"original": (float(np.min(raw_image)), float(np.max(raw_image))),
|
| 579 |
+
"quantized": (float(np.min(quantized_raw)), float(np.max(quantized_raw))),
|
| 580 |
+
"windowed": (low, high),
|
| 581 |
+
"quantized_windowed": (low, high),
|
| 582 |
+
}
|
| 583 |
|
| 584 |
mse_value = mean_squared_error(metric_left, metric_right)
|
| 585 |
psnr_value = peak_signal_to_noise_ratio(metric_left, metric_right, data_range=value_range.span)
|
|
|
|
| 648 |
histogram_right,
|
| 649 |
top_label=left_label,
|
| 650 |
bottom_label=right_label,
|
| 651 |
+
top_bounds=histogram_bounds[histogram_left_key],
|
| 652 |
+
bottom_bounds=histogram_bounds[histogram_right_key],
|
| 653 |
),
|
| 654 |
clear_figure=True,
|
| 655 |
)
|
utils.py
CHANGED
|
@@ -418,14 +418,20 @@ def create_histogram_figure(
|
|
| 418 |
image_bottom: np.ndarray,
|
| 419 |
top_label: str,
|
| 420 |
bottom_label: str,
|
| 421 |
-
|
| 422 |
-
|
| 423 |
) -> plt.Figure:
|
| 424 |
stacked = np.concatenate([np.asarray(image_top).ravel(), np.asarray(image_bottom).ravel()])
|
| 425 |
bins = np.linspace(float(stacked.min()), float(stacked.max()), 129)
|
| 426 |
|
| 427 |
fig, axes = plt.subplots(2, 1, figsize=(6, 5.0), sharex=True)
|
| 428 |
-
for ax, image, label in zip(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
ax.hist(np.asarray(image).ravel(), bins=bins, color="#4C6A92", alpha=0.9)
|
| 430 |
ax.axvline(low, color="#B85450", linestyle="--", linewidth=1.4, label="Lower bound")
|
| 431 |
ax.axvline(high, color="#B85450", linestyle="--", linewidth=1.4, label="Upper bound")
|
|
|
|
| 418 |
image_bottom: np.ndarray,
|
| 419 |
top_label: str,
|
| 420 |
bottom_label: str,
|
| 421 |
+
top_bounds: tuple[float, float],
|
| 422 |
+
bottom_bounds: tuple[float, float],
|
| 423 |
) -> plt.Figure:
|
| 424 |
stacked = np.concatenate([np.asarray(image_top).ravel(), np.asarray(image_bottom).ravel()])
|
| 425 |
bins = np.linspace(float(stacked.min()), float(stacked.max()), 129)
|
| 426 |
|
| 427 |
fig, axes = plt.subplots(2, 1, figsize=(6, 5.0), sharex=True)
|
| 428 |
+
for ax, image, label, bounds in zip(
|
| 429 |
+
axes,
|
| 430 |
+
[image_top, image_bottom],
|
| 431 |
+
[top_label, bottom_label],
|
| 432 |
+
[top_bounds, bottom_bounds],
|
| 433 |
+
):
|
| 434 |
+
low, high = bounds
|
| 435 |
ax.hist(np.asarray(image).ravel(), bins=bins, color="#4C6A92", alpha=0.9)
|
| 436 |
ax.axvline(low, color="#B85450", linestyle="--", linewidth=1.4, label="Lower bound")
|
| 437 |
ax.axvline(high, color="#B85450", linestyle="--", linewidth=1.4, label="Upper bound")
|