Skip to content

Commit c650028

Browse files
committed
Tweak delta text to include uniformity metrics
1 parent 3cdcc5c commit c650028

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

viscm/gui.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ def label(ax, s):
189189
horizontalalignment="right",
190190
verticalalignment="bottom",
191191
transform=ax.transAxes)
192+
def title(ax, s):
193+
ax.text(0.98, 0.98, s,
194+
horizontalalignment="right",
195+
verticalalignment="top",
196+
transform=ax.transAxes)
192197

193198
Jpapbp = self._sRGB1_to_uniform(RGB)
194199

@@ -197,10 +202,14 @@ def delta_ymax(values):
197202

198203
ax = axes['deltas']
199204
local_deltas = N * np.sqrt(np.sum((Jpapbp[:-1, :] - Jpapbp[1:, :]) ** 2, axis=-1))
200-
print("perceptual delta peak-to-peak: %0.2f" % (np.ptp(local_deltas),))
205+
#print("perceptual delta peak-to-peak: %0.2f" % (np.ptp(local_deltas),))
201206
ax.plot(x[1:], local_deltas)
202207
arclength = np.sum(local_deltas) / N
203-
label(ax, "Perceptual deltas (total: %0.2f)" % (arclength,))
208+
rmse = np.std(local_deltas)
209+
title(ax, "Perceptual deltas")
210+
label(ax,
211+
"Length: %0.1f\nRMS deviation from flat: %0.1f (%0.1f%%)"
212+
% (arclength, rmse, 100 * rmse / arclength))
204213
ax.set_ylim(-delta_ymax(-local_deltas), delta_ymax(local_deltas))
205214
ax.get_xaxis().set_visible(False)
206215

@@ -214,9 +223,15 @@ def delta_ymax(values):
214223
ax.axhline(0, linestyle="--", color="grey")
215224
lightness_deltas = N * np.diff(Jpapbp[:, 0])
216225
ax.plot(x[1:], lightness_deltas)
226+
title(ax,
227+
"Perceptual lightness deltas")
228+
lightness_arclength = np.sum(np.abs(lightness_deltas)) / N
229+
lightness_rmse = np.std(lightness_deltas)
217230
label(ax,
218-
"Perceptual lightness deltas (total: %0.2f)"
219-
% (np.sum(np.abs(lightness_deltas)) / N,))
231+
"Length: %0.1f\nRMS deviation from flat: %0.1f (%0.1f%%)"
232+
% (lightness_arclength,
233+
lightness_rmse,
234+
100 * lightness_rmse / np.mean(lightness_deltas)))
220235
#ax.set_ylim(0, ax.get_ylim()[1])
221236
ax.set_ylim(-delta_ymax(-lightness_deltas), delta_ymax(lightness_deltas))
222237
ax.get_xaxis().set_visible(False)

0 commit comments

Comments
 (0)