Skip to content

Commit d98210e

Browse files
committed
Solve maximum representable value.
1 parent b3acd55 commit d98210e

File tree

1 file changed

+116
-4
lines changed

1 file changed

+116
-4
lines changed

notebooks/gamut_mapping_compression_functions_01.ipynb

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"* [Clang 11.0.0 (clang-1100.0.33.16)] *\n",
4444
"* *\n",
4545
"* colour-science.org : *\n",
46-
"* colour : v0.3.15-132-g8ed24e8e *\n",
46+
"* colour : v0.3.15-141-g3bebd7e9 *\n",
4747
"* *\n",
4848
"* Runtime : *\n",
4949
"* imageio : 2.8.0 *\n",
@@ -128,7 +128,7 @@
128128
{
129129
"data": {
130130
"application/vnd.jupyter.widget-view+json": {
131-
"model_id": "2b308d2eb0af46088af0942ed25426fc",
131+
"model_id": "0682438225404555bcfc31ffbf717986",
132132
"version_major": 2,
133133
"version_minor": 0
134134
},
@@ -197,7 +197,7 @@
197197
{
198198
"data": {
199199
"application/vnd.jupyter.widget-view+json": {
200-
"model_id": "444b6201127a401283c81573e1c28c86",
200+
"model_id": "5026406f51784d0887ab0f01eeec1781",
201201
"version_major": 2,
202202
"version_minor": 0
203203
},
@@ -210,7 +210,7 @@
210210
}
211211
],
212212
"source": [
213-
"X, A, I = 1.2, 0.8, 1\n",
213+
"X, A, I = 65504, 0.8, 1\n",
214214
"\n",
215215
"figure, axes = colour.plotting.plot_multi_functions(\n",
216216
" {\n",
@@ -221,6 +221,7 @@
221221
" },\n",
222222
" **{\n",
223223
" 'standalone': False,\n",
224+
" 'bounding_box': [0, 2, 0, 2],\n",
224225
" 'samples':\n",
225226
" np.linspace(0, 2, 1000),\n",
226227
" 'plot_kwargs': [\n",
@@ -236,6 +237,117 @@
236237
"\n",
237238
"axes.scatter(X, I, c='b', s=50, zorder=4);"
238239
]
240+
},
241+
{
242+
"cell_type": "code",
243+
"execution_count": 6,
244+
"metadata": {},
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"[1, 1.0009766, 1.0019531, 1.0029297, 1.0039062, 1.0048828, 1.0058594, 1.0068359, 1.0078125, 1.0087891]\n"
251+
]
252+
}
253+
],
254+
"source": [
255+
"HFD = [1]\n",
256+
"\n",
257+
"while True:\n",
258+
" HFD.append(np.nextafter(HFD[-1], +np.inf, dtype=np.float16))\n",
259+
" if HFD[-1] > 65504:\n",
260+
" break\n",
261+
"\n",
262+
"print(HFD[:10])"
263+
]
264+
},
265+
{
266+
"cell_type": "code",
267+
"execution_count": 7,
268+
"metadata": {},
269+
"outputs": [
270+
{
271+
"name": "stdout",
272+
"output_type": "stream",
273+
"text": [
274+
"[ Threshold 0.0 ]\n",
275+
"tanh 6.58594\n",
276+
"atan 7376.0\n",
277+
"simple 23168.0\n",
278+
"\n",
279+
"\n",
280+
"[ Threshold 0.1 ]\n",
281+
"tanh 6.02734\n",
282+
"atan 6636.0\n",
283+
"simple 14744.0\n",
284+
"\n",
285+
"\n",
286+
"[ Threshold 0.2 ]\n",
287+
"tanh 5.46875\n",
288+
"atan 5900.0\n",
289+
"simple 13104.0\n",
290+
"\n",
291+
"\n",
292+
"[ Threshold 0.3 ]\n",
293+
"tanh 4.91016\n",
294+
"atan 3650.0\n",
295+
"simple 8108.0\n",
296+
"\n",
297+
"\n",
298+
"[ Threshold 0.4 ]\n",
299+
"tanh 4.35156\n",
300+
"atan 3130.0\n",
301+
"simple 6952.0\n",
302+
"\n",
303+
"\n",
304+
"[ Threshold 0.5 ]\n",
305+
"tanh 3.61914\n",
306+
"atan 1844.0\n",
307+
"simple 5792.0\n",
308+
"\n",
309+
"\n",
310+
"[ Threshold 0.6 ]\n",
311+
"tanh 3.0957\n",
312+
"atan 1476.0\n",
313+
"simple 3278.0\n",
314+
"\n",
315+
"\n",
316+
"[ Threshold 0.7 ]\n",
317+
"tanh 2.57227\n",
318+
"atan 783.0\n",
319+
"simple 1738.0\n",
320+
"\n",
321+
"\n",
322+
"[ Threshold 0.8 ]\n",
323+
"tanh 1.97852\n",
324+
"atan 369.5\n",
325+
"simple 820.0\n",
326+
"\n",
327+
"\n",
328+
"[ Threshold 0.9 ]\n",
329+
"tanh 1.48926\n",
330+
"atan 93.0625\n",
331+
"simple 205.625\n",
332+
"\n",
333+
"\n",
334+
"[ Threshold 1.0 ]\n",
335+
"tanh 1\n",
336+
"atan 1\n",
337+
"simple 1\n",
338+
"\n",
339+
"\n"
340+
]
341+
}
342+
],
343+
"source": [
344+
"for t in np.linspace(0, 1, 11):\n",
345+
" print(f'[ Threshold {np.around(t, 1)} ]')\n",
346+
" for func in (tanh_compression_function, atan_compression_function, simple_compression_function):\n",
347+
" print(func.__name__.split('_')[0],\n",
348+
" HFD[np.argmax((func(HFD[:-1], t, 1 - t) - func(HFD[1:], t, 1 - t)).astype(np.float16))])\n",
349+
" print('\\n')"
350+
]
239351
}
240352
],
241353
"metadata": {

0 commit comments

Comments
 (0)